API Pagination 00:00:01 Count past the first page A shopper reaches page two. In the meantime three new products arrive at the head of the catalogue. The page number is unchanged, but has the starting item stayed in the same place? The client asks for the first three products. The database limits the result to three rows and skips none. OFFSET 3: three rows are read and thrown away. OFFSET 6. OFFSET 9: nine rows for nothing. It is the last page, so there is no next. Offset pagination is simple to explain and can jump to a page number. Deep offsets may still oblige the database to visit and discard many earlier rows. 00:00:43 Continue after a known item Each answer carries a token. The client sends it back without looking inside. The first request asks for three products and carries no continuation token. For illustration, the token encodes last seen identifier three. The next query continues after that identifier. Real clients should treat the token as opaque. After 6. Four rows were asked for and three came, so there is no more. A cursor represents a continuation point under a named sort and filter. Treat it as opaque at the client and validate its context so it cannot be reused with a different query silently. 00:01:22 Seek on an indexed ordering WHERE id > last, through the index. Nothing is counted. The first keyset request asks for the three lowest identifiers in the specified order. The index goes straight to 4. The same work as before. Still the same work, and has_more is false. Include a unique tie-breaker when many products share a timestamp or price. Without it, two pages can disagree on which equally ranked item follows the last one. 00:01:52 Measure a deep traversal Rows the database reads for one page of 20. No difference. Offset 1,980 plus 20. Offset 100,000 plus 20. Offset 1,000,000 plus 20. Use the actual query plan and data distribution. A keyset predicate can avoid scanning every prior row when an index supports the same ordering, but cannot make an unsupported sort free. 00:02:18 A moving feed has a different promise Three newest posts and a cursor after 7. The list moved, the place did not. After 7: 6, 5 and 4. Nothing is repeated. A second question, newer than 9, finds post 10 for the top. Inserts behind or ahead of a cursor have different effects. Document how new, edited and deleted items behave across requests instead of promising that an ordinary browsing session is a snapshot. 00:02:47 Export the entire list The first pages fly, the last ones read a million rows each. Every page costs the same. For a full export, a background job writes a file and the client downloads it once. A long export may need a consistent snapshot, a cutoff or a background file. Name what time the extracted catalogue represents before assuming a sequence of live pages is complete. Choose whether the customer is browsing a changing collection or exporting a fixed one. A continuation token, stable order and reproducible snapshot solve different parts of that decision.