Filtering and sorting
Learn how to use URL parameters to filter and sort results from the PandaScore REST API.
PandaScore allows you to filter and sort request results by adding query parameters to the request URL.
Filter
The filter
query parameter is used to check for strict equality. Using the filter[field]=value
syntax, you can filter out results where field
is not strictly equal to value
.
To get only LoL champions whose name is Brand
, use the following URL:
/lol/champions?filter[name]=Brand
The filter
parameter also accepts a list of comma-separated values. To get only LoL champions whose name is either Brand
or Twitch
, use the following URL:
/lol/champions?filter[name]=Brand,Twitch
Dates format
When using
filter
with dates, dates should be given in UTC time.
Warning
The
filter
parameter only allows to filter dates on their date (day, month, year). The time (hours, minutes, seconds) is ignored.
Search
The search
query parameter is used to check for string values that contain a given sub-string. Using the search[field]=value
, you can filter out results where field
does not contain value
.
To get only LoL champions whose name contains "twi", use the following URL:
/lol/champions?search[name]=twi
Notice
The
search
query parameter only works with string values.
Range
The range
query parameter is used to check for numeric values that are between a given interval. Using the range[field]=0,100
, you can filter out results where field
is not between 0
and 100
.
To get only LoL champions whose HP are between 500 and 1000, use the following URL:
/lol/champions?range[hp]=500,1000
Notice
The
range
query parameter only works with numeric values.
Sort
The sort
query parameter is used to sort results based on field values. Using the sort=field
syntax, you can sort results by field
.
The sorting is always done in ascending order unless the field name is prefixed with a minus, in which case the order is descending.
It is possible to sort by multiple fields by providing a comma-separated list of values. In that case, the sorting is done by the first field, then the second, and so on.
The following URL allows you to:
- get all LoL champions
- sort champions by attack damage
- sort champions with the same attack damage by their name (descending alphabetical order).
/lol/champions?sort=attackdamage,-name
Null values
When sorting in ascending order,
null
values appear first. In descending order,null
values come last.
Updated over 2 years ago