Pattern for recent deal changes

When using the api to receive recent deal changes:

/deals/v1/deal/recent/modified

and paging the results it appears that the offset and count paging system could mean that new changes effectively shift the paging window:

If I initially have 20 recently modified deals, and the calling code fetches the most recent 10 in a first batch; the offset gets returned as 10

Then someone in the system modifies the deals (so there are 21 recently modified deals)

And then the calling code asks for the second batch using offset starting at 10

It seems that the first deal of the second batch would actually be the last deal from the first batch.

It comes up because I was thinking of long gaps between paged requests and concerned about extreme cases like 11 deals get modified so I miss one rather than get duplicates.

Am I misunderstanding this call? Is there a way with the api parameters to mitigate this? (count in the other order or something…) Is the webhook a better plan here?

Hi @cadmium,

I hope all is well with you :grinning_face_with_smiling_eyes:

When looking at the Get Recent Deals | Deals API, you’re right to say that if there’s new deals being modified older deals would be push to the back and this may affect the offset paging results.

That said, while I get your point that the last result of the first batch would be the first result of the second batch, I’m not quite sure I’m understanding how this would cause you to miss deals that was modified? Do you mind elaborating a little more here?

Additionally, maybe you can look into increasing the number of deals returned in each calls, so instead of 10/20, you can set the &countparameter to 100? Also, if you have regularly changes on your deals, I’d suggest for you to explore the our Webhook API here: Webhooks API Overview.

Thanks,

A piece I missed sharing :wink: is that I am trying to use this in reverse order to to sync changes into an analytics system.

So I am trying to skip ahead in the offset and then work backwards. In that ordering I think the inserted items cause missed rather than duplicate items.

However, I think your suggestion of just going to the last (oldest) 20 items and then asking for 100 should catch up to 80 inserts. And if that doesn’t work, I will look at the webhook alternative.

Thanks!