A team asks an API for its customer records. The first response contains 100 rows, so the script asks for the next 100. During that pause, a new record arrives at the top of the list. The script finishes without an error, reports 200 rows, and quietly repeats one record while missing another. The API did what it was asked to do. The question is whether the request described the same list each time.
Offset pagination asks for a position in an ordered result; cursor pagination asks to continue from a supplied marker. Both split a large result into manageable responses. Neither automatically guarantees a consistent snapshot if the underlying collection changes. The endpoint’s documented ordering, cursor behavior and snapshot guarantees determine what a client can safely conclude.
The distinction matters whenever pages feed a reconciliation, report, migration or backup. A pleasant-looking count is not proof that every distinct record was collected. The objective is a complete, understandable result, not merely reaching the end of a loop.
What an offset counts
Imagine a list sorted from newest to oldest. A fictional endpoint accepts a limit and an offset. A request with a limit of three and an offset of zero returns records A, B and C. A second request with the same limit and an offset of three asks the server to skip the first three positions and return the following three.
If the list stays A, B, C, D, E, F, the next response is D, E and F. Now suppose a new record X arrives before the second request. The list becomes X, A, B, C, D, E, F. Skipping three positions now returns C, D and E. C is duplicated; F has moved beyond this page. If the client stops because it expected six rows, it has missed F despite receiving six responses in total.
Deletion can cause a different problem. If A disappears after the first page, the list becomes B, C, D, E, F. Skipping three now starts at E, so D is omitted. The examples assume each request sees the latest list. A service may instead offer a snapshot or other protection; check that feature rather than assuming all offset endpoints behave identically.
Offset can be convenient when users jump to a numbered page or when the data is stable. Its simplicity does not make it wrong. It does mean that a position is a property of a particular ordering at a particular moment. When the ordering or collection changes, the meaning of “skip three” can change too.
What a cursor means
A cursor is a continuation marker supplied by an API or constructed according to its contract. One endpoint may return an opaque token for the next page. Another may accept the last object’s ID. The client should not invent a token’s format or assume it can substitute a timestamp unless the documentation says so.
Stripe’s pagination documentation, for example, describes list endpoints that use object IDs with starting_after or ending_before. Those parameters have specific directional meanings for that API. Other providers use different ordering, tokens, expiration rules or page metadata. Follow the exact endpoint rather than copying the names into every integration.
In a simple conceptual list A through F, a cursor saying “continue after C” can return D, E and F even if X is inserted before A. That avoids the particular position shift in the first example. But it does not establish that every changing record is captured. A record can be deleted, move across the ordering boundary after an update, become newly visible because permissions changed, or arrive with a timestamp that sorts behind the cursor. The actual behavior depends on the service.
Some APIs bind a cursor to the original filters or a temporary snapshot; others may not. Tokens can expire. A client that saves a cursor for tomorrow needs to know whether the provider supports resuming it tomorrow and what to do when the token is no longer valid. “Cursor” is a category of interface, not a universal consistency guarantee.
Stable order needs a tie-breaker
Suppose several records share the same creation timestamp. If an endpoint sorts only by that timestamp and does not specify how ties are ordered, two pages can rearrange equal-time records between requests. Even a well-intentioned client can duplicate or miss an item when it tries to continue from the last timestamp alone.
Where the service allows it, a stable unique tie-breaker can clarify ordering: for example, creation time followed by a unique ID. That is a design pattern, not a claim that every provider offers that sort. If the API supplies an opaque next-page token, use it as instructed and do not replace it with a guessed pair of fields.
Also distinguish the time an event happened, the time it was created in a system and the time it was last updated. A report filtered by creation time may miss an older record that was corrected today. A sync filtered by update time needs to understand whether every relevant change advances that field and whether timestamps have sufficient precision.
Timezone offsets are another source of accidental ordering errors. Compare actual instants according to the service’s format, not strings that merely look similar. Our guide to timestamp offsets illustrates why the displayed local time and the moment represented are different questions.
Filters and permissions are part of the page
Record the endpoint, account, filters, sort order, page limit and time window used for a collection. If the filter changes halfway through, the later page is not a continuation of the same request, even if the cursor appears accepted. If an account’s permissions or visibility change, the accessible set can change without a record being created or deleted.
For a fictional orders report, “all orders created in a month” is different from “orders currently open that were created in a month.” An order closing during collection can vanish from the latter filter. A terminal next-page response proves only that the server reported no further page under that request; it does not prove the report includes every state the business intended to include.
Do not assume a default view is comprehensive. An endpoint may omit archived objects, cap its accessible history or require a separate endpoint for another state. Those are coverage questions to resolve in the provider’s documentation and available account context before calling a list complete.
Retries need a checkpoint
A network interruption can occur after the server sent a page but before the client stored it. The client must decide whether to request the same page again. A robust workflow saves the records and its continuation checkpoint in a way that can be reconciled after interruption. If the page is requested again, stable record identifiers allow duplicates to be recognized.
That is different from blindly discarding every record with a previously seen ID. A record can have a newer version or a changed status. The correct treatment depends on whether the task is building a historical event log, a current-state table or a snapshot for a particular cutoff. Preserve the information needed to decide which representation belongs in the result.
Retries of a read and retries of an operation that creates or changes data are also different. An endpoint’s idempotency mechanism can matter for the latter; it does not make a multi-page read into a consistent snapshot. The guide to idempotency keys explains that separate problem.
How to check a completed collection
For a bounded read, keep the time the run started and ended, the query parameters, the page count, the terminal indicator and the number of unique IDs. If the service supplies a trustworthy total for the same filters and snapshot, compare it with the unique count. Do not compare a current total from one moment with an independently changing list and call a mismatch impossible.
A practical check may repeat the first page and compare the complete anchor, not just its first item. If it changed, investigate whether the service’s snapshot semantics still establish coverage. An unchanged first page is useful evidence, not proof that no record changed deeper in the list. For important reconciliations, a documented overlap window, later refresh or provider-supported export can help detect changes that crossed a boundary.
Keep raw identifiers and private records in the appropriate protected system. A shareable report can describe counts, coverage and limitations without exposing customer data or continuation tokens. If one page fails, report the missing range or unknown coverage rather than filling the gap with the last known count.
Before trusting a paginated result, ask three questions: what was ordered, what did the marker mean, and what could change while the collection ran? The answers reveal whether you have a list of responses or a defensible record of the collection you intended to retrieve.
Explore Infinite Upside
For Vijay Sheth’s personal accounts, read Infinite Upside: Building Wealth With Room to Live, published by Sheth Capital, Inc.
Explore a related guide
How do idempotency keys make API retries safer?