Testing pagination against a real API

Pagination looks trivial until a page boundary lands in the middle of a record set that is still being written to. The APIs below implement both common styles — page numbers with a total, and opaque cursors — so you can write a client against each and find out which assumptions your code is making.

Pagination testing — request and response sequence Sequence diagram for Pagination testing: GET /friends/v1/characters answers 200 OK. GET /friends/v1/episodes answers 400 Bad Request. GET /friends/v2/characters answers 404 Not Found. Your client Fun API Playground GET /friends/v1/characters 200 OK Paginated character list, with Deprecation/Sunset/Link he… GET /friends/v1/episodes 400 Bad Request Non-integer season GET /friends/v2/characters 404 Not Found Page out of range
Real endpoints from the catalog — every request above is served, and every status code shown is one that endpoint actually returns.

How to practise it

  1. Walk every page of a collection and assert that the number of records you collected equals the total the API reported.
  2. Request a page past the end of the collection. Some APIs answer with an empty list and a 200; the Friends API answers 404. Both are defensible, and your client has to handle whichever it meets.
  3. Check the last page: it is almost always partially full, and off-by-one errors hide there.
  4. Walk the Bank API by cursor and confirm no record is skipped or repeated — the failure mode cursors are supposed to prevent.
  5. Combine pagination with a filter and verify the counts still agree.

APIs to try it on

Status codes involved

Other techniques

Getting started guide · All 39 mock REST APIs

Last updated