Skip to content

Querying Collections

A collection endpoint like GET /articles can return ten rows or ten million. Returning them all is never the answer. Four query capabilities turn a raw list into something clients can use efficiently.

flowchart LR
  C[GET /articles] --> P[Pagination: how many, which slice]
  C --> F[Filtering: which rows]
  C --> S[Sorting: what order]
  C --> Fl[Field selection: which fields]
All four are expressed with query parameters on the collection

All four live in the query string, because they describe which view of the collection you want — not which resource. Identity stays in the path; the query shapes the result.

  • Pagination — offset vs cursor, and the response envelope.
  • Filtering & sorting — selecting and ordering rows.
  • Field selection — sparse fieldsets and expanding relations.
  • Search & envelopes — full-text search and a consistent wrapper.
Where do pagination, filtering, and sorting parameters belong?
What should an unfiltered GET on a large collection do by default?