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
| Token | Description |
|---|---|
next_token | In response meta. Use to get the next page. |
previous_token | In response meta. Use to go back a page. |
pagination_token | Request parameter. Set to next_token or previous_token value. |
Response structure
next_token is omitted:
Pagination parameters
| Parameter | Description | Default |
|---|---|---|
max_results | Results per page | Endpoint-specific |
pagination_token | Token from previous response | None |
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