How pagination works
The API has list and search endpoints that can return multiple objects, such as listing campaigns or searching for results. To mitigate negative impacts to performance, these endpoints don’t return all results at once. Instead, the API returns one page of results per API call, with each page containing up to 10 results by default. Use thelimit parameter to change the number of results per page.
For example, this is an API request to list campaigns results that uses role based evaluations, with a limit of 3:
- Objects are inside the
dataproperty. - Objects are sorted by
created_atin descending order (newest first) by default. - The
has_moreproperty indicates if there are additional objects that weren’t returned in this request.
Follow these steps to paginate results
- Make an API call to list the objects that you want to find.
- In the response, check the value of
has_more:- If the value is
false, you’ve retrieved all the objects. - If the value is
true, get the ID fromlast_record_id, and make a new API call with thestarting_afterparameter set to that ID.
- If the value is
Parameters
A limit on the number of objects to be returned. Limit can range between 1 and
100, and the default is 10.
A cursor for use in pagination.
starting_after is an object ID that defines
your place in the list. For instance, if you make a list request and receive
10 objects, ending with ID 105, your subsequent call can include
starting_after=105 in order to fetch the next page of the list.Response format
All paginated endpoints return responses in the following format:Array of objects for the current page
Whether there are more objects available after this page
ID of the last record in the current page. Use this as the
starting_after
parameter for the next page. null if there are no more pages.
