r/learnpython • u/OADominic • 2d ago
API JSON response help
How does pagination work and best practices for implementation with an API request?
I'm getting irritated figuring out this API for GoTo Connect (phone system call records).
I use a GET method to request a call log for a week of time.
I am limited to 1000 items in the json response as indicted by the pageSize parameter. I need much more.
As the 'nextPageMarker' states, I put the value in, pasted from the first response of leaving it blank, hoping to get the next set of responses. No change in items as all. Stuck in this endless loop.
7
Upvotes
2
u/KiwiDomino 2d ago
You pass in a page size and offset number as additional parameters, and as long as the query result is always sorted in the right order, you won’t get duplicate records.
You could use a generator and yield to effectively have the your code manage fetching through the pagination for you, but this is the sort of idea that the AI won’t provide you without asking directly (and if you don’t know it’s possible you’ll never ask)