Filtering & Sorting
Filtering narrows a collection to the rows a client cares about; sorting decides their order. Both are query parameters on the collection, and a little convention keeps them readable.
Filtering
Section titled “Filtering”The simplest, most discoverable form is one query parameter per field:
GET /articles?status=published&author=42For ranges and operators, a common convention is a bracketed or suffixed operator:
GET /articles?createdAt[gte]=2026-01-01&views[gt]=1000Keep the operator vocabulary small and documented (gte, lte, gt, lt, ne, in). Whatever you pick, apply it the same way on every collection.
Sorting
Section titled “Sorting”Accept a sort parameter listing fields, with a leading - for descending:
GET /articles?sort=-createdAt,titleThat reads as “newest first, then by title ascending”. Define which fields are sortable (sorting on an unindexed column can be expensive) and reject the rest with 400.