# Pagination

Pagination divides a large result set into smaller responses that clients retrieve through successive requests.

Cloud concept. Updated 2026-10-29. Page: https://blowstack.com/tools/cloud-concepts-hub/pagination

> Pagination lets applications consume or expose large collections without transferring every record in a single response. Correct implementations control resource usage while ensuring clients follow continuation information, handle failures, and understand how changing data affects completeness.

Practice exams covering Pagination: [DEA-C01 AWS Certified Data Engineer - Associate](https://blowstack.com/practice-exams/aws-certified-data-engineer-associate), [DVA-C02 AWS Certified Developer - Associate](https://blowstack.com/practice-exams/aws-certified-developer-associate).

## 6 key aspects of Pagination

Reliable pagination combines bounded responses, correct continuation handling, predictable ordering, recoverable processing, and per-request access control.

1. **Explicit continuation contract**: Clients advance using the API's documented token, cursor, offset, or next-page link. Determine completion from that contract rather than assuming that a short response is the last page.
2. **Bounded response size**: Default and maximum page sizes limit resource consumption per request. A requested item limit may be constrained by byte limits or service-specific evaluation rules.
3. **Ordering and consistency**: Stable ordering with a unique tie-breaker makes traversal more predictable. Consistency across pages requires separate consideration because pagination alone does not freeze the underlying data.
4. **Recoverable ingestion**: Save continuation state after successfully processing its associated data, and make repeated processing safe. Confirm token lifetime and scope before relying on a token for restart recovery.
5. **SDK-assisted traversal**: SDK paginators automate supported continuation protocols but still issue multiple API requests. Process their output incrementally and distinguish per-request page size from a total retrieval limit.
6. **Performance and access control**: Balance request overhead against memory, latency, throttling, and retry costs. Enforce authorization for every page and prevent token tampering or reuse outside its intended query context.

## Cloud services for Pagination

API Gateway can expose a data API backed by Lambda, with DynamoDB providing records through paginated queries. The function validates page-size inputs, checks authorization, and translates backend continuation state into the API's documented response contract. For ingestion, code can follow an external API's pages and write results to Amazon S3. SDK paginators simplify supported AWS listing operations, including S3 object discovery, but do not provide durable workflow checkpoints or deduplication. Across these services, engineers must preserve continuation state correctly, respect throttling and execution limits, and distinguish page-by-page retrieval from snapshot consistency or incremental change capture.

- **[Amazon DynamoDB](https://blowstack.com/tools/cloud-services-hub/amazon-dynamodb)**: Query and Scan read up to their applicable limit or 1 MB before applying filter expressions. Supply a returned LastEvaluatedKey as ExclusiveStartKey for the next request; even an empty filtered page can require continuation.
- **[Amazon S3](https://blowstack.com/tools/cloud-services-hub/amazon-s3)**: ListObjectsV2 returns at most 1,000 objects per request and uses IsTruncated and NextContinuationToken to describe continuation. Pass the returned token as ContinuationToken, or use an SDK paginator to traverse the listing.
- **[Amazon API Gateway](https://blowstack.com/tools/cloud-services-hub/amazon-api-gateway)**: API Gateway exposes custom data APIs whose request and response contracts can include page sizes and continuation tokens. The backend or integration must implement pagination; the gateway does not automatically divide arbitrary backend results into pages.
- **[AWS Lambda](https://blowstack.com/tools/cloud-services-hub/aws-lambda)**: Lambda functions can implement paginated API backends or consume paginated APIs through SDK calls. Long traversals must account for invocation time limits by persisting progress and continuing work across invocations when necessary.

## Pagination exam questions

Real practice exam questions on Pagination, with the correct answer and its explanation.

### Question 1 (DEA-C01)

**Question:**

A data engineer maintains a Python automation job that submits processing tasks for every partition in an AWS Glue Data Catalog table. The table contains 24,000 partitions and does not change during the run. The job uses Boto3 as follows:

paginator = glue.get_paginator('get_partitions')
for page in paginator.paginate(
    DatabaseName='analytics',
    TableName='daily_events',
    PaginationConfig={'PageSize': 1000, 'MaxItems': 1000}
):
    submit_tasks(page['Partitions'])

The job finishes without errors but submits tasks for only 1,000 partitions. The engineer must process all partitions while continuing to handle results in bounded-size pages. Which change meets these requirements?

**Correct answer:** Remove MaxItems, retain PageSize at 1,000, and continue processing each page yielded by the paginator.

**Explanation:** MaxItems limits the total number of items yielded by the paginator. Removing that limit allows the paginator to follow continuation tokens until all partitions have been retrieved. Retaining PageSize keeps individual responses bounded, and processing each yielded page avoids accumulating the entire collection.

### Question 2 (DVA-C02)

**Question:**

A developer is implementing an export of all failed delivery events for one customer from an Amazon DynamoDB table. The application uses Query with a KeyConditionExpression for the customer's partition key and a FilterExpression for deliveryStatus = 'FAILED'. The customer's events occupy approximately 8 MB, and failed events occur throughout that data. No events change during the export. With Limit set to 100, one response contains an empty Items array and a nonempty LastEvaluatedKey, even though failed events remain unread. Which implementation will retrieve all failed events?

**Correct answer:** Repeat the Query with the same conditions, passing each response's LastEvaluatedKey as the next request's ExclusiveStartKey. Continue until LastEvaluatedKey is absent or empty.

**Explanation:** Query applies its filter after evaluating a page of items. A page can therefore contain no matching items while still providing a LastEvaluatedKey. Passing that key as ExclusiveStartKey continues from the evaluated position without skipping later matches.

## Practice Pagination in a full exam

Questions on Pagination in each practice exam, with every answer option and an explanation for each:

- [DEA-C01](https://blowstack.com/practice-exams/aws-certified-data-engineer-associate): 7 questions
- [DVA-C02](https://blowstack.com/practice-exams/aws-certified-developer-associate): 3 questions

## What is Pagination

Pagination is a request-and-response pattern for retrieving a collection in manageable portions called pages. A request specifies a desired page size and, after the first request, a position from which to continue. The response contains records and information indicating how to request another page. Cloud APIs use pagination to bound response sizes, memory consumption, processing time, and network transfer per request.

Common approaches include page numbers, offsets, and continuation tokens or cursors. An offset-based API might accept limit=100 and offset=200 to request records after the first 200 results. A cursor-based API instead returns a position associated with the previous page. Offset pagination supports convenient navigation but can become expensive for deep database queries. Cursor-based pagination often scales better for sequential traversal, although arbitrary jumps to a particular page may not be supported.

When ingesting data from an API, request the first page, process its records, and follow the documented continuation mechanism until the API indicates completion. Do not assume that a short or empty page means the collection is exhausted. Some APIs apply filters after reading a bounded amount of data, so they can return no matching records while still providing continuation information. Keep filters, sorting, and other parameters consistent across requests as required by the API, and treat continuation tokens as opaque values rather than decoding or modifying them.

For example, an ingestion job can retrieve pages from a supplier API and write each page to object storage before requesting the next one. Persist progress only after the corresponding records are durably processed. A failure between writing records and saving progress can cause the same page to be processed again, so use idempotent writes or deduplication keys. Check whether tokens expire or are valid only within a particular session; a saved token is not necessarily a durable incremental-ingestion checkpoint.

When creating a data API, define a default page size, enforce a maximum, and document the continuation contract. Use deterministic ordering with a unique tie-breaker, such as an event timestamp followed by a record identifier. Validate tokens and bind them to relevant query parameters or authorization context where appropriate. A token must never replace authorization checks on each request. API gateways can expose and validate pagination parameters, but they do not automatically paginate arbitrary backend results.

Pagination does not guarantee a consistent snapshot. Concurrent inserts, updates, and deletes can cause records to move between pages, particularly with offsets. Keyset cursors reduce positional shifts but do not automatically provide snapshot isolation. Exports requiring a fixed view may need database snapshot support, versioned data, or an API-defined snapshot token. Pagination also differs from incremental ingestion: dividing results into pages does not determine which records changed since a previous run.

When calling AWS APIs from code, consult the operation's pagination contract or use an SDK paginator when available. For example, Boto3 provides client.get\_paginator('list\_objects\_v2') for Amazon S3 object listings. A single low-level SDK call generally returns only one service response, whereas a paginator iterates through multiple responses. SDK page-size controls and total-item limits have different purposes, and support varies by operation. Larger pages reduce request overhead but increase per-response memory and retry work; smaller pages increase request count and possible throttling. Apply bounded retries with backoff, process pages incrementally, and monitor request counts, errors, and completed records.

## Learn Pagination in lessons

2 short lessons on Pagination in 1 certification course.

- DEA-C01: Pagination: consuming API pages (Premium), https://app.blowstack.com/lessons/pagination-consuming-api-pages-dea-c01
- DEA-C01: Pagination: designing continuation contracts (Premium), https://app.blowstack.com/lessons/pagination-designing-continuation-contracts-dea-c01
