THE GITHTML FIELD GUIDE

An API pagination documentation template that defines when to stop

Document pagination by explaining how to request the first page, obtain the next page, and recognize completion. Include ordering, page-size limits, consistency assumptions, and empty-page behavior. Use the API's actual continuation contract rather than guessing page numbers or stopping whenever a response contains fewer records than requested.

Identify the pagination model and its stability limits

Determine whether the API uses page numbers, offsets, cursors, or response links. Name the authoritative continuation signal and explain whether clients should treat a cursor as opaque. Record the ordering contract and what can happen when data changes during traversal. A sequence of pages is not automatically a consistent snapshot. If the service offers snapshot behavior, document the relevant conditions; otherwise explain the limitation without inventing guarantees about duplicates or omissions. Keep the reference scoped to one endpoint family when different endpoints paginate differently. A generic SDK helper does not replace the server's documented contract.

Write an example that includes the end condition

Use a tiny synthetic dataset and show the first response, the continuation value, and the final response. The template below asks explicitly when the client stops. Include allowed page-size bounds and the behavior when a requested size is unsupported. Explain whether an empty page can still include a continuation signal. If the API supplies a next link, show how that link is obtained instead of reconstructing it from assumptions. GitHub's REST documentation provides a concrete example of link-based pagination, but do not transfer its exact parameters to another service. Mark all illustrative endpoints and values so readers do not mistake them for a live API.

text
Endpoint family:
Pagination model:
First request:
Continuation field or header:
Page-size bounds:
Ordering and consistency:
Empty-page behavior:
Completion condition:
Expired continuation behavior:
Safe traversal example:

Review traversal and error recovery separately

Test the documented sequence against a safe fixture containing zero, one, and several pages. Include a case where data changes if the API's behavior matters to the user's task. Document how errors or expired cursors affect continuation and whether restarting can duplicate processing. Keep rate-limit and authentication failures separate from the normal termination condition. A client should not interpret an error as the end of a dataset. Review the page when response envelopes or ordering rules change. The reference should help implementers build a bounded, correct traversal rather than a loop that happens to work on the first small sample. Record whether filters and sort options must remain unchanged across requests. A continuation token may be meaningful only within the original query, and the reference should not encourage mixing unrelated traversals.

  1. Identify the actual continuation signal and the supported ordering contract.
  2. Show first, intermediate, and final responses with a clear stop condition.
  3. Test zero-result and multi-page cases using safe sample data.
  4. Distinguish completion from errors, expired cursors, and rate-limit responses.

Sources and further reading

AI-assisted writing with source-linked guidance and illustrative examples. Read our editorial approach or report a correction.

All documentation templates guides →

Read as MarkdownAll guides

An API pagination documentation template that defines when to stop · gitHtml