I needed to filter data when accessing an API following the JSON:API specifications. For those not familiar with JSON:API, it provides a set of conventions on how to structure JSON responses. It also provides some guidance on how to request data. Similar to semantic versioning, the set of conventions cuts down on the debate on how to structure APIs.
Filtering by Passing Query Parameters
JSON:API describes how to filter parameters, through the use of a filter parameter.
Example (fetching all posts made by author Joe):
http://example.com/api/posts?filter=[author][joe]
What I don’t see in the examples is how to pass in a list of values. For example, filtering by multiple authors. For now, I’ll assume that it is acceptable to pass in a list of values:
http://example.com/api/posts?filter=[author][jack,jill]
See also