AlgoViz

API pagination

easy 24 min

Pagination sends a long list in small pages.

Where it shows up

The same pattern appears across everyday software.

  • Stripe

    List calls take starting_after or ending_before with an object id and a limit from 1 to 100, and answer with has_more.

  • Slack

    A 2017 engineering article explains the move to cursors. The docs warn that a page may hold fewer items than the limit, so only an empty cursor means the end.

  • GitHub

    Responses carry a Link header with the next and other pages, so a client follows links instead of building URLs.

  • DynamoDB

    A Query returns at most 1 MB and a LastEvaluatedKey. The next call sends it back as ExclusiveStartKey.

  • Elasticsearch

    from and size stop at 10,000 hits by default. Deeper reading uses search_after with the last hit's sort values and a tiebreaker.

  • Admin panels

    Small tables with page numbers stay on offsets. The person wants page 4, and the table has a few thousand rows.