📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials API Design Pagination

Pagination

5 min read Quiz at the end
Offset, cursor, and keyset pagination — cursor is most reliable for large frequently-changing datasets.

Pagination Patterns

# Offset pagination (simplest)
GET /posts?page=3&limit=20
{"data":[...],"pagination":{"total":500,"page":3,"pages":25}}

# Cursor pagination (recommended for large data)
GET /posts?limit=20
{"data":[...],"next_cursor":"eyJpZCI6MjB9","has_more":true}
GET /posts?limit=20&cursor=eyJpZCI6MjB9

# Keyset pagination (fastest)
GET /posts?limit=20&after_id=20
# WHERE id > 20 LIMIT 20  (uses index)

# Link headers (RFC 5988)
Link: ; rel="next"
Topic Quiz · 1 questions

Test your understanding before moving on

1. Why is cursor-based pagination better than offset-based for large datasets?
💡 Cursor pagination uses a pointer to the last item — new inserts/deletes do not shift subsequent pages.