meta object with result_count, previous_token, and next_token. The XDK takes care of making multiple API calls using the next_token so developers can just specify how much data they are looking for without having to make multiple calls.
The SDK simplifies this with:
- Built-in Iterators: Use generator functions for seamless multi-page fetching.
- Explicit Token Handling: For flexible manual control when needed by passing
pagination_tokenwhen needed. - Max Results Enforcement: Respect
max_resultsper call (up to API limits, e.g., 100 for search).
Automatic Pagination (Recommended)
Use theiterate() method on paginated responses to fetch all results lazily.
Example: Paginated Search
- The iterator handles
next_tokenautomatically. - Stops when no
next_tokenis present. - Supports rate limit backoff to avoid 429 errors.
Manual Pagination
If you require control over the results for some custom logic (e.g. processing page-by-page), you can still use thenext_token and do the pagination manually as shown below:
- Always specify
max_resultsto optimize (default varies by endpoint). - Monitor
meta.result_countfor debugging. - For very large queries, consider async iteration to avoid blocking.