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
  1. Trace two filters
  2. Give omission and repetition a rule
  3. Let the URL represent a reproducible view
  4. Validate both allowed keys and values

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.

References

  1. IETF, RFC 9110: HTTP Semantics ↩
  2. WHATWG, HTML Living Standard: Forms ↩