Most pagination bugs I've seen weren't in the happy path. Page 1 works, page 2 works, and then someone asks for page 0, or the last page has exactly limit items, or a cursor gets cut off in a URL, and the client either loops forever or quietly drops data.
I build testingapis.com , a free fake API for testing clients, and while adding pagination endpoints to it I wrote down every edge case I could think of. Here's the list. The requests point at my API so you can see a real response, but the point is to run the same cases against your own API.
The five styles
Before the test cases, a quick reminder that "pagination" means five different things:
Style Request Client stops when
Offset ?offset=20&limit=10 hasMore is false or offset >= total
Page number ?page=2&size=10 last is true
Cursor ?cursor=eyJsYXN0SWQiOjJ9 next_cursor is null
Keyset ?after_id=20&limit=10 next_after_id is null
Link header Link: <...page=3>; rel="next" No rel="next"
A cursor response looks like this:
curl…