How pagination works
- Make your initial request with
max_results - Check the response for a
next_tokenin themetaobject - If present, make another request with that token as
pagination_token - Repeat until no
next_tokenis returned
Pagination tokens
Response structure
next_token is omitted:
Pagination parameters
Check each endpoint’s API reference for specific
max_results limits.
Example: Paginating through all results
- Python
- JavaScript
Best practices
Use max results
Request the maximum allowed
max_results to minimize API calls.Handle partial pages
The last page may have fewer results than
max_results.Store tokens
Save
next_token if you need to resume pagination later.Don't poll with pagination
For new data, use
since_id instead of paginating repeatedly.Result ordering
Results are returned in reverse chronological order:- First result on first page = most recent
- Last result on last page = oldest
Notes
- Pagination tokens are opaque strings—don’t parse or modify them
- Tokens may expire after some time
- If you get fewer results than
max_results, more may still exist (continue until nonext_token) - Use SDKs for automatic pagination handling
Next steps
Rate limits
Understand request limits when paginating.
SDKs
Libraries with built-in pagination.