Overview
The KDP API uses cursor-based pagination for endpoints that return large collections of data. This approach provides consistent results even when data is being added or removed.How It Works
Paginated endpoints accept the following query parameters:limit- Number of items to return (default: 20, max: 100)starting_after- Cursor for forward paginationending_before- Cursor for backward pagination
You cannot use both
starting_after and ending_before in the same request.Response Format
Paginated responses include ametadata object:
hasMore- Indicates if there are more results availablecount- Number of items in the current page
Examples
First Page
Next Page
Use the last item’s ID from the previous response asstarting_after:
Previous Page
Use the first item’s ID from the current page asending_before:
Implementation Example
TypeScript
Python
Best Practices
- Use consistent limits: Keep the same limit value when paginating through results
- Handle empty results: Check if the data array is empty before accessing items
- Store cursors: Save pagination state to resume later if needed
- Respect rate limits: Add delays between requests for large datasets
- Use appropriate page sizes: Balance between number of requests and response size