API pagination is a technique for splitting large datasets into smaller, sequential chunks so clients can retrieve them incrementally rather than fetching everything at once. Without pagination, a single API request on a large dataset can time out, exhaust memory, or return millions of records the client does not need. For example, Amazon Web Services documents that the default integration timeout quota for API Gateway APIs is 29 seconds. Pagination lets the client request exactly the range of data it needs, so response times stay fast and server load stays manageable.
The most common types of pagination are offset, cursor-based, page-based, time-based, and keyset. The right choice depends on database size and real-time syncing needs.
The sequence diagram above illustrates a client requesting a paginated API resource and the server returning the first chunk of data alongside a next-page cursor token. Selecting the right design prevents bottlenecks as application data grows.
1. Offset and Limit Pagination
Offset pagination uses two parameters: an ‘offset’ to determine the starting point and a ‘limit’ to specify the maximum number of records per page. Convoy notes that offset fetches data from a database based on these two parameters.
For example, an API request could include parameters like offset=0 and limit=10 to retrieve the first 10 records.
GET /api/posts?offset=0&limit=10
It is simple to implement but degrades in performance on large datasets because the database must scan and discard all preceding rows (full table scans). If records are inserted or deleted between page requests, offset pagination skips or duplicates records.
2. Cursor-Based Pagination
Cursor-based pagination uses a unique identifier or opaque token to mark the specific position in the dataset. The API consumer includes the cursor value in subsequent requests to fetch the next page of data. A cursor bookmarks your location in a result set and must be a unique, sequential column, such as an ID or a timestamp. Because the cursor is opaque, it reduces coupling between the client and the server.
This approach stays stable if records are inserted or deleted between page requests, because page boundaries remain consistent. It is fast on large tables because it uses indexed lookups instead of scanning rows. The cursor can be built from a timestamp, a primary key, or an encoded representation of the record. The main tradeoff is that it does not easily support random page access or calculating total record counts.
GET /api/posts?cursor=eyJpZCI6MX0
In the above API request, the cursor value eyJpZCI6MX0 represents the identifier of the last fetched record. This request retrieves the next page of posts after that specific cursor. You can review implementation differences in our comparison on API Pagination Best Practices: Cursor & Keyset.
3. Page-Based Pagination
Page-based pagination uses a ‘page’ parameter alongside a ‘limit’ or ‘per_page’ parameter to request a specific page number. Convoy clarifies that instead of specifying the position of the next item in the database, it simply sets a page number. The API consumer requests a specific page of data, and the API responds with the corresponding page, typically along with metadata such as the total number of pages or total record count.
It is easier to use but has the same performance limitations as offset pagination on large datasets. Developers must tune the bounds carefully, applying guidelines on How to Determine API Pagination Page Size based on payload constraints.
GET /api/posts?page=2&limit=20
In this API request, the client requests the second page, where each page contains 20 posts.
4. Time-Based Pagination
When data is ordered by time, time-based pagination retrieves it by date range. This method uses time-related parameters, such as ‘start_time’ and ‘end_time’, to specify a time range.
It is ideal for incremental data sync use cases where you only want to fetch records created or updated after a specific timestamp. It can fetch data in chronological or reverse-chronological order, which works for both recent and historical data. However, it can miss records if clock skew or delayed writes cause data to land outside the requested time window.
GET /api/events?start_time=2023-01-01T00:00:00Z&end_time=2023-01-31T23:59:59Z
Here, this request fetches events that occurred between January 1, 2023, and January 31, 2023, based on their timestamp.
5. Keyset Pagination
Keyset pagination relies on filtering by the value of a sortable, indexed column to determine the starting point for the next page. Infinum’s .NET handbook explains that the idea behind keyset pagination is to have a pointer to a specific item in the data set which determines where the pagination continues. The handbook also notes that items in the set must have a unique value for ordering and pointing, using the pointer as an instruction for filtering.
It combines the stability of cursor-based pagination with direct SQL query efficiency. The API consumer includes the last seen timestamp or identifier as a parameter to fetch the next set of records. This technique retrieves subsequent pages without duplication or missing records. Developers must manage edge cases carefully, using techniques covered in API Pagination Stability: Avoiding Duplicates & Gaps.
GET /api/products?last_key=XYZ123
Here, XYZ123 represents the last seen key or identifier. The request retrieves the next set of products after the one with the key XYZ123.
How API Pagination Affects Integration Performance
Pagination style affects integration performance, especially under concurrent writes when syncing frequently updated data. Developers must build custom retry logic and adapt to different pagination styles when integrating with third-party APIs. Fetching data across different endpoints means handling complex token structures and strict limits. You can apply API Rate Limiting Best Practices for Developers to handle backoff properly. Learning What is API Integration? The 2026 Complete Guide provides further context on connecting software systems to share data automatically. Troubleshooting the integration process helps you solve Common API Pagination Errors and How to Fix Them (2026).
With Knit: Knit’s documentation describes Knit as a translation layer that standardizes API authentication, data models, pagination, and errors across all integrated accounting platforms. According to the Knit FAQ, it eliminates the hassle of maintaining individual integrations, their API rate limits, pagination issues and retries. Knit’s documentation also points out that Salesforce allows up to 2,000 records per query while HubSpot caps at 100; Knit abstracts that difference away.
Frequently Asked Questions
What is API pagination?
API pagination is a technique for splitting large datasets into smaller, sequential chunks (pages) so clients can retrieve them incrementally rather than fetching everything at once.
What are pagination techniques?
The main API pagination techniques are offset and limit, page-based, cursor-based, time-based, and keyset pagination. Each suits different use cases. Cursor-based is best for real-time feeds and large datasets, offset works for simple sorted results, and time-based is ideal for incremental data sync.
What are the different types of pagination?
The different types of pagination are offset, page-based, cursor-based, time-based, and keyset. Offset pagination uses offset and limit parameters; it is simple to implement but slows down on large datasets because of full table scans. Page-based pagination uses page and per_page parameters. Cursor-based pagination uses an opaque cursor token pointing to the last record, performing well on large or frequently-updated datasets. Time-based pagination fetches records within a time window using start and end parameters. Keyset pagination filters by the value of an indexed column.
How to do pagination on API?
To implement pagination on an API, choose a pagination style like offset, cursor, or keyset depending on your dataset size and update frequency. Add the relevant query parameters to your GET endpoint, such as ?limit=100&offset=0 or ?after=cursor_token. Return pagination metadata in the response, such as total count, next cursor or next page URL. Handle the last page by returning an empty next cursor or a has_more: false flag. On the client side, follow the next link or cursor in each response until no further pages return.
What are the advantages of cursor-based pagination over offset pagination?
Cursor-based pagination has three advantages over offset pagination. First, it is stable: if records are inserted or deleted between page requests, offset pagination skips or duplicates records, whereas cursors point to a specific position so page boundaries remain consistent. Second, cursor-based queries use indexed lookups, avoiding the need for the database to scan and discard all preceding rows. Third, cursor pagination works reliably on datasets with millions of records where offset becomes too slow. The tradeoff is that cursor pagination does not support random page access or total record counts as easily.
What are API pagination best practices?
Key best practices include using cursor-based or keyset pagination for large or frequently-updated datasets rather than offset. Always return a next cursor or link in the response so clients do not need to calculate the next page themselves. Set a sensible default and maximum page size to prevent unbounded requests. Include a has_more boolean or empty next link to signal the final page clearly. Use consistent parameter names so clients do not need to re-learn the interface per endpoint. Document the pagination model explicitly.
When should I use time-based pagination?
Time-based pagination suits incremental data sync best. It allows you to fetch only records created or updated after a specific timestamp, rather than fetching all records from scratch on each run. Developers commonly use it in webhook alternative patterns, audit log retrieval, and integration sync loops. The main limitation is that it assumes records have reliable, indexed timestamp columns. It can miss records if clock skew or delayed writes cause them to land before the boundary.
How does API pagination affect integration performance?
Pagination style affects integration performance. Offset pagination becomes slow on large tables and can produce inconsistent results under concurrent writes. This creates a common problem when syncing employee data from HRIS platforms that update frequently. Cursor-based pagination is more reliable for integration sync loops because it handles insertions and deletions between pages gracefully. When building integrations against third-party APIs, always check which pagination style they use and implement retry logic with backoff for rate-limited page requests.
What are common pagination approaches?
The common approaches are simple offset skips, cursor tokens, and indexed keysets. To choose one, weigh database size and read/write frequency; those two factors decide which approach stays stable under high-volume requests.
Which pagination strategies should I use?
Use cursor-based or keyset strategies for massive datasets and real-time feeds to ensure stability and fast indexed lookups. Use time-based strategies for incremental data syncing to only fetch new or updated records. Reserve offset and page-based strategies for small, static lists where performance degradation is not a concern.