Follow continuation information, not page length
How to traverse API results reliably using continuation information or SDK paginators, including safe recovery and the limits of completeness when data changes. · associate
Pagination divides a result collection into pages. A single API request usually returns one page, not the whole collection. To traverse the results, request the first page, process its records, and use the response's documented continuation information to request the next page.
The continuation contract belongs to the operation. It may use a token, a key, a next-page link, or a completion flag. Treat opaque tokens as values to pass back unchanged, not values to decode or increment. Keep filters, ordering, and other request settings consistent as the operation requires.
Page length is not a completion signal. An API can return a short or empty page and still have more work to scan. For example, a DynamoDB Query can return no matching items after filtering while still returning LastEvaluatedKey; pass that value as ExclusiveStartKey to continue. Stop according to the operation's documented end condition, not because the records array is empty.