-
Notifications
You must be signed in to change notification settings - Fork 1
Query parameters
The following query parameters can be used on every GET
request in the application.
This parameter allows you to populate references to other collections in the response.
Key : populate
Value : A comma separated value of the fields you want populated. You can deep populate values by separating fields using a dot (f.e. brewers.beers
). If no value has been defined, the algorithm will populate all references in the root of the results.
Example : ../beers?populate=brewers.beers
This parameter allows you to filter the response data on one or more fields on specific values.
Key : filter[:field]
Value : The value you want the field defined in the key to be filtered on. If the schema type of the field is defined as a string, the filter will check if the given value is a part of the field value (case insensitive). Prepending the value with an !
will only return results where the values do not match.
Example : ../beers?filter[name]=uinnes&filter[percentage]=!5
This parameter allows you to search through all fields of the response using the same value. Results matching the value in at least one of the fields will be shown in the response. You can limit the fields which fields in which the algorithm searches using the search scope parameter.
Key : search
Value : The value you want the field defined in the key to be filtered on. If the schema type of the field is defined as a string, the filter will check if the given value is a part of the field value (case insensitive).
Example : ../beers?search=sour
This parameter allows you to sort the response data on one or more fields in the desired order.
Key : searchScope
Value : A comma separated value of all fields on which the search needs to be executed. If no search scope it set, the search will be conducted on all fields of the model.
Example : ../beers?search=sour&searchScope=name,beerType
This parameter allows you to define which fields you want the results to contain. If one or more fields have been picked for a layer, the remaining layers will be omitted from the response. You can deep pick fields by separating fields using a dot (f.e. brewers.name
).
Key : pick
Value : A comma separated value of all fields which you want returned in the response.
Example : ../beers?pick=name,beerType
This parameter allows you to sort the response data on one or more fields in the desired order.
Key : sort
Value : A comma separated value of all fields on which the response needs to be sorted. A field can be prefixed with a hyphen (-
) in order to by it in descending order.
Example : ../beers?sort=-percentage,name
This parameter allows you to skip the first n number of results.
Key : offset
Value : An integer value which defines how many results you want to skip.
Example : ../beers?offset=10
This parameter allows you to limit the response to only show the next n number of results.
Key : limit
Value : An integer value which defines the maximum number of results you want returned.
Example : ../beers?limit=5
This parameter allows you to find the distinct values for a specified field. The returned models will each contain unique values for that field. When multiple models in the actual response would have the same value, the first encountered model will be chosen based on the sort
attribute.
Key : distinct
Value : The field of which you want the values to be distinct.
Example : ../beers?distinct=percentage
This parameter allows you to randomize the order of the response data. This parameter holds priority over the sort
parameter which means that the sort
will be omitted when random
is defined.
Key : random
Value : Inserting any value but false
will enable the random order. Not defining the parameter of defining false
will disable it.
Example : ../beers?random
Made by Martin Drost - Buy me a ☕