Syntax and filters
Syntax
The syntax for filtering and including works differently from API V2. The syntax is used across all endpoints: the documentation for each endpoint describes the exceptions regarding exclusions of some fields/relations. Find out everything about the new syntax.
Filters
The filter system changed compared to the previous version. You can now select specific fields on the base entity or includes, and it’s possible to filter your request. Below is a fixture shown with events.
As you can see in the response, you will receive all match events. But what if you’re only interested in a specific event like goals, cards or substitutions? You can filter on the specific data you're interested in. The URL now includes a &filters
query parameter that shows the entity you want to filter on and the IDs you want to see in your results.
So, we already explained how to use filters and how to filter on one particular ID. But what if you're interested in filtering on multiple IDs? That is also possible! You can use filters on multiple IDs.
More information and a more detailed explanation are covered on our request options page.
Select the fields you need
You can request only the fields you need by using the new syntax. Filters can filter the data based on the fields you would like to display in your application.
:
can be used for filtering the fields you want to see in the response. For example, you only want the name of a certain team. In this case you need to use participants:name
.
Custom Sorting
You can use custom sorts on endpoints; this enables the sorting of base entities returned in the endpoint responses. This feature is designed to enhance flexibility and customisation for users interacting with the API.
Usage
This provides users with the ability to customise sorting of returned data through the use of the sortBy
and order
parameters. This functionality is particularly useful when retrieving lists of fixtures in football, as it allows users to organise the data based on specific criteria.
Sorting Fixtures
When querying fixtures, users can specify the field to sort by and the desired order using the following parameters:
sortBy: Specifies the field by which the data will be sorted. Currently supported fields include
starting_at
andname
.order: Determines the order in which the data will be sorted. Users can choose between ascending (
asc
) and descending (desc
) orders.
Examples
Sort by starting_at
: This option sorts the fixtures based on their starting date and time.
This URL sorts the fixtures in descending order of their starting date and time.
Sort by name
: This option sorts the fixtures alphabetically based on their names.
This URL sorts the fixtures alphabetically by their names in ascending order.
Sorting on the name
field currently works for all entities with a "name"
field. For Fixtures, sorting also works on the starting_at
field.
If an unsupported field is passed to sort on, an error is thrown, and the request returns a 400 Bad Request HTTP code.
A more detailed explanation is covered on our request options page
Last updated