REST API Pagination, Filtering, Sorting, and Search

Common collection query patterns including offset pagination, cursor pagination, filtering, sorting, and search.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all

Pagination patterns

Use stable collection pagination contracts.

Offset pagination

Simple page and limit contract.

httpANYrestpaginationoffset
http
GET /users?page=2&limit=25

Offset pagination is easy to understand, but performance can degrade on large datasets and results may shift during concurrent writes.

Cursor pagination

Use opaque cursors for large or changing datasets.

httpANYrestpaginationcursor
http
GET /events?limit=100&cursor=eyJpZCI6IjEwMDAifQ==

Cursor pagination is often more stable and efficient than offset pagination for append-heavy lists.

Return next-page metadata

Expose pagination state in the response body.

jsonANYrestresponsemetadata
json
{
  "data": [/* ... */],
  "page": 2,
  "limit": 25,
  "total": 140,
  "next_cursor": null
}

Pagination metadata helps clients build pagers and infinite-scroll experiences without guessing.

Use a stable sort key with cursors

Paginate in a deterministic order.

httpANYrestcursorsorting
http
GET /events?sort=created_at:desc&cursor=...

Cursor pagination works best when the ordering is explicit and stable.

Recommended next

No recommendations yet.