In plain words
Pagination splits a long list into pages, either by offset (skip 40, take 20) or by cursor (take 20 after this row), so responses stay small and fast however many rows exist.
Where you see it
A Harbor customer has 30,000 invoices. GET /v1/invoices returns 50 at a time with a next_cursor value, and the client sends it back as ?cursor= for the next 50 until has_more is false. Stripe's API pages the same way, with starting_after and has_more.
What goes wrong
- Offsets on a big, busy table
offset 100000 still makes the database walk past 100,000 rows, and when rows are added while someone pages, items shift and get skipped or repeated. Use a cursor for long or changing lists.
- Sorting by a column that isn't unique
Ordering only by created_at lets rows with the same timestamp swap places between requests. Add the id as a final tiebreaker.
- No upper limit on page size
?limit=1000000 turns a paginated endpoint back into a dump of the whole table. Set a default page size and a maximum, and cap anything larger.
What to tell your agent
Quick check
Sign in to earn +10 XP for itA Harbor customer exports invoices page by page using offsets while new invoices keep arriving. Some invoices appear twice in the export. Why?