Representing Page Filters in Query Parameters
A query can describe a view of a collection, such as its search text, sort order, or selected subset.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace two filters
A books path can list all books. A query requesting author Ada and year 2024 narrows the visible list according to defined semantics. URL components identify where these filter values occur.
Give omission and repetition a rule
An absent sort field may default to newest. Multiple values could be a supported list or an invalid input depending on the parameter. See optional fields for making the distinction explicit.[1][2]
Let the URL represent a reproducible view
A reader selects region west and order newest. Encoding both in a collection URL lets another reader open that view, subject to public data and access. An omitted parameter can choose a default, while an explicit empty value needs a documented meaning. See shareable search URLs.
/reports?region=west&sort=new → filtered view
/reports → default view
/reports?region= → define explicit empty behavior
Validate both allowed keys and values
Repeated names can mean several selected regions or invalid input. Treat sorting as a restricted set of operations predicted by the interface. Test omitted, repeated and invalid values through the actual route.