Reading JSON API Pagination Patterns
Offset, cursor, and link-based pagination appear in JSON APIs in predictable shapes. Learn how to spot each pattern and query nested page metadata.
List endpoints rarely return unbounded arrays. Pagination wraps rows in metadata — next, cursor, page, total — and the exact JSON shape varies by API. Recognizing the pattern speeds up debugging and client implementation.
Offset / page pagination
Response often includes:
{
"data": [ ... ],
"page": 2,
"pageSize": 50,
"total": 437
}
Or query-driven: ?offset=100&limit=50.
Pros: jump to page N, simple mental model.
Cons: unstable when rows insert/delete during iteration; large offsets stress databases.
JSONPath examples:
- Items:
$.data[*] - Next page number:
$.page+ 1 if$.data.length == $.pageSize
Cursor pagination
Response includes opaque cursor:
{
"items": [ ... ],
"nextCursor": "eyJpZCI6MTIzfQ==",
"hasMore": true
}
Client sends ?cursor=eyJpZCI6MTIzfQ== on the next request.
Pros: stable for live feeds; efficient for large tables.
Cons: cannot jump to arbitrary page; cursor semantics are API-specific.
jq example: .items[] | .id then pass nextCursor from prior response manually.
Link-based (HATEOAS) pagination
{
"results": [ ... ],
"_links": {
"next": { "href": "/api/items?after=abc" },
"prev": { "href": "/api/items?before=xyz" }
}
}
Follow next.href until absent. Common in HAL-style APIs.
Key names to grep for
next, nextPage, next_cursor, continuationToken, after, links.next, meta.pagination, has_more, total_count.
Debugging pagination bugs
- Fetch page 1 and 2; diff metadata fields only.
- Confirm empty page:
data: []withhasMore: trueis a server bug. - Validate cursor is URL-safe when copy-pasting from logs.
- Use JSONPath to extract
$.items[*].idacross pages for duplicate detection.
Client loop pseudocode
cursor = null
loop:
response = GET /items?cursor=cursor
process response.items
cursor = response.nextCursor
break if !response.hasMore
Schema tip
Document pagination envelope in OpenAPI once; reuse PaginatedResponse<T> in generated types. Validate fixtures per page shape in Schema Validator.
Related: nested JSON querying.
Try this in BracketView
Open the BracketView workspace — core tools run in your browser.
Related BracketView tools
Related articles
- Common JSON Syntax Errors and How to Fix Them
Unexpected token, trailing commas, unescaped strings — learn what causes the most common JSON parse errors and how to fix them with a validator workflow.
- How to Validate JSON Against a JSON Schema
Step-by-step guide to validating JSON documents against JSON Schema — draft versions, common keywords, and worked examples for API payloads.
- Understanding JSON Diff: Structural vs Value-Level Comparisons
JSON diff tools can report added keys, removed branches, and changed values differently. Learn comparison modes and how to interpret diff output for API reviews.