Automatic Pagination
Theauto_paging_each method automatically fetches successive pages as you iterate:
The
auto_paging_each method handles all pagination logic internally, fetching new pages as needed until all results have been processed.Accessing Single Page Data
You can access items from a single page without triggering automatic pagination:Manual Pagination
For more granular control, usenext_page? and next_page methods:
Check for Next Page
Iterate Through Pages Manually
Comparison: Automatic vs Manual
- Automatic Pagination
- Manual Pagination
- You need to process all items
- You want simple, readable code
- You don’t need page-level metadata
Controlling Page Size
Set thelimit parameter to control how many items are returned per page:
The API may have maximum limit values. Check the specific endpoint documentation for limits.
Paginated Resources
Pagination is available on various list endpoints:Best Practices
Use auto_paging_each by default
For most use cases,
auto_paging_each provides the simplest and most readable approach to handling paginated data.Set appropriate page limits
Balance between API call overhead and memory usage by choosing an appropriate
limit value for your use case.Handle rate limits gracefully
When processing large paginated datasets, be mindful of rate limits. The SDK automatically retries on rate limit errors.