3 ms·
Querystrings for resources are technically okay in REST: > The query component contains non-hierarchical data that, along with data in the path component (Sect
by hartror 11y ago
Querystrings for resources are technically okay in REST:
> The query component contains non-hierarchical data that, along with data in the path component (Section 3.3), serves to identify a resource . . .
source: https://tools.ietf.org/html/rfc3986#section-3.4 https://tools.ietf.org/html/rfc3986#section-3.4
With a caveat, you will note the "non-hierarchical data" bit.
It means that this:
GET /user/1/groups
is valid and this:
GET /user?id=1&groups
is an anti-pattern.
Why? The spec doesn't say of course but at a guess I'd say because there is already a hierarchical data format in URLs, the path. This assumption is build into every web framework & language I've ever used, with query strings being passed as unordered dictionaries.
As you suggest the convention is to only use query strings as search parameters and the like. Personally I think conventions are useful to follow, especially when they don't cost you anything like the one we're talking about.