Filtering API content
Filtering API content allows the API consumer to retrieve a subset of data rather than retrieving an entire dataset. Filtering only works with the endpoints that retrieve the entire data for a specific content-type; to be more specific, it will only work with the find
endpoint.
To filter the API data, we can use the filters
API parameter. Strapi uses LHS bracket syntax for query parameters, which means the query parameters are encoded in the URL using square brackets ([]
). The filters
API parameter is in the ?filters[FILED_NAME][OPERATOR]=VALUE
format, where FILED_NAME
is the name of the field we want to filter on and OPERATOR
is the operator we want to use to filter the data. The following table shows all the possible operators we can use:
To better illustrate the filters
parameter, let's consider the following requirement:
As an API user I want to be...