Filter the unneeded data for more efficient responses!
In this chapter, we’ll teach you how to filter out data from our API, which is useful when you want to request specific data and can omit the rest for faster response time. You can filter out data for various parameters per endpoint. See our API reference guide for more detailed information. For this tutorial, we’ll use the get fixtures by date endpoint.
This endpoint has the following parameters:
Leagues: filter on league IDs
Bookmakers*: filter on bookmaker IDs
Markets:* filter on market IDs
Status: filter on status
You can only filter on the bookmakers & markets parameters when you've enriched your response with the odds include.
In this tutorial, we’ll show you step by step how filtering works, but most importantly, why you would want to use it.
First, we’ll show you why exactly filtering is useful. For example, we want to have all the fixtures on a specific date of the Italian Serie A (league id: 384).
As mentioned above, we’re going to use the same endpoint as in our includes tutorial. Requesting all the fixtures played on the 2nd of August 2020:
The request works, but it is far from efficient. While you do receive the data you requested, it is incredibly hard to find the data for only the Italian Serie A (league id: 384) because you’ve just requested every single fixture on that date. For this example, we made the request with an Enterprise Plan subscribed API token, which means that the API would return all fixtures of 1200+ leagues.
Note, that there is only one league id in the previous response snippet. And it's not a fixture from the Italian Serie A (league id: 384).
You can find a short overview of the response at the bottom of the request. This is called the meta description:
As you can see, the API returns a total of 570 results with 100 results per page. Obviously, this is way too much if you only want to request fixtures for a specific league. Therefore, this request is inefficient and needs some slight adjustments.
Please check our pagination tutorial for more information about pages.
This is where filtering comes into play. Because we only want the fixtures of the Italian Serie A (league id: 384) in our response. We can easily exclude the rest of the data that we won’t be needing. Simply add the leagues
parameter to your request:
Now, you can simply add the league id of the Italian Serie A to your request: &leagues=384
The result? Only five fixtures instead of 570! Again, you can see this in the meta description of the response.
Did you get a blank response?
Note that there may be no fixtures on the date you’ve requested in the leagues you’ve access to.
Since we’re on a roll, we might as well filter on more than just one league. Simply add more league ids! You can separate them with a comma:
In the previous chapter, you’ve learned about includes. Thanks to our API’s flexibility, you can filter and use includes in the same request! Let’s mix up the previous request with some includes:
Just like that, you have built an efficient request and experienced the flexibility of our API. By filtering the request on the data you need, you can save yourself from a lot of irrelevant data. Moreover, you can combine filtering with includes as well. The possibilities are near limitless! Next, we'll be covering limiting API responses.
Field
Description
data
Opens an array of data you've requested
id
A unique fixture id
league_id
The unique id of the league the fixture belongs to
season_id
The unique id of the season the fixture belongs to
stage_id
The unique id of the stage the fixture belongs to
round_id
The unique id of the round the fixture belongs to
group_id
The unique id of the group the fixture belongs to
aggregate_id
Indicates if the fixture has an aggregated score
venue_id
The unique id of the venue the fixture is played at
referee_id
The unique id of the referee that is in charge of the fixture
localteam_id
The unique id of the local team
visitorteam_id
The unique id of the visitor team
winnerteam_id
Contains the id of the team that won the fixture
weather_report
Opens an array of weather details. Possible values of the data in this array can be found in our statuses and definitions
commentaries
Indicates if this fixture has commentaries available
attendance
Give information about the visitor attendance of the fixture
pitch
Gives information about the pitch. Possible values can be found in our statuses and definitions
details
Optional additional information.
neutral_venue
Indicates if the fixture was played at a neutral fixture. This often happens in cup finals
formations
Opens an array containing the lineup formations of the teams. Possible values can be found in our statuses and definitions
scores
Opens an array containing the scores of the fixture
localteam_score
The number of goals the local team has scored in this fixture
visitorteam_score
The number of goals the visitor team has scored in this fixture
localteam_pen_score
The number of penalty goals the local team has scored in this fixture (only available when the fixture goes into penalty shootout)
visitorteam_pen_score
The number of penalty goals the visitor team has scored in this fixture (only available when the fixture goes into penalty shootout)
ht_score
The score at halftime
ft_score
The score at full time (90 minutes)
et_score
The score in extra time (only available when the fixture goes into extra time)
ps_score
The score of the penalty shootout (only available when the fixture goes into penalty shootout)
time
Opens an array containing the time details of the fixture
status
Indicates in which phase the fixture is in. Possible values can be found in our statuses and definitions
starting_at
Opens an array containing the time details of the fixture
date_time
Gives the date and time the fixture starts
date
Gives the date on which the fixture is played
time
Gives the starting time of the fixture
timestamp
The timestamp notation of the match
timezone
Indicates in which timezone you've requested the data
minute
Indicates in which minute the fixture is in
second
Indicates in which second the fixture is in
added_time
Indicates how much added time is added
extra_minute
Extra minute is when a fixture goes to extra time. Extra_minute will count from 0 to 15 and from 15 to 30.
injury_time
In case of added time it will end up in injury_minute
coaches
Opens an array containing the unique id's of the coaches
localteam_coach_id
The unique id of the coach from the local team
visitorteam_coach_id
The unique id of the coach from the visitor team
standings
Opens an array containing the standings of the local- and visitorteam
localteam_position
Indicates in which positions the local team is before the fixture
visitorteam_position
Indicates in which positions the visitor team is before the fixture
assistants
Opens an array containing the unique id's of the assistant referees
first_assistant_id
The unique id of the first assistant
second_assistant_id
The unique id of the second assistant
fourth_official_id
The unique id of the fourth official
leg
Indicates in how many legs this fixture is played
colors
Opens an array containing information about the team colors
localteam
Opens an array containing information about the local team colors
color
The main color code of the local team
kit_colors
The kit color codes of the local team
visitorteam
Opens an array containing information about the visitor team colors
color
The main color code of the visitor team
kit_colors
The kit color codes of the local team
deleted
Indicates if the team was deleted. More information: Keep in Sync
is_placeholder
This property indicates if the resource is used to display dummy data. The false of this property will always be a boolean
value.
Field
Description
pagination
Opens an array of information about the pages in the API response
total
The total amount of results the API returns
count
The amount of results on the current page
per_page
The amount of results per page
current_page
The number of page currently browsed
total_pages
The total number of pages
links
The link if you want to go to the next API page
In the previous chapter, we have discussed how you can enrich your API request by using includes. In this chapter, you will find out how you can filter, sort and limit your API request. Already familiar with this? Simply skip this chapter and dive right into the details of our livescores & fixtures tutorial.
Want a small recap? No worries just go back to the previous chapter.
Sometimes you just want to limit your response a little bit!
In the previous tutorial, we have explained the fundamentals of filtering API responses, which allows you to request the exact data you need. However, sometimes the response can be rather large. In such cases, you can use our limiting feature. In this part of our tutorial, you will be able to limit your API responses.
Limiting, as its name suggests, will limit the response you get from our API to a specific amount. Limiting your API responses can come in handy when you want to avoid big API responses. In this tutorial, we'll show you how limiting is used and why it may be handy for you. Let's go!
In this tutorial, we will request all the fixtures from the 20/21 season from the Scottish Premiership (season id: 17141). As for the endpoint, we’ll go with season by id.
Furthermore, as discussed in our includes tutorial, we’ll enrich the response with an include. In this case, we’ll use the include called fixtures
The below request will give you all the fixtures of the 20/21 season of the Scottish Premiership (season id: 17141).
The response is enormous. Therefore, we've copied a small snippet instead of the full response.
Season Field Description
Fixtures Field Description
Your first thought is probably: ‘Wow that’s an enormous response’. This is because football seasons tend to have a large number of matches. In order, to make the response more legible we can introduce a limit.
By limiting the response, we mean that you can limit the number of results per page. Let’s say we want to limit the response to only five results per page. You still need to use the fixtures
include, but now you can add :limit(X|X)
.
The first attribute (X) is the number of records per page, while the second (X) is the page currently browsed.
For example, if you want 5 fixtures per page and you want to browse the first page: &include=fixtures:limit(5|1)
Now there are only five results per page! Moreover, you can simply replace the ‘1’ in (5|1) for a ‘2’, if you want to go to the second page. And just like that, you have successfully limited an API response!
Note that paginating through includes count towards your request limit
You’ve learnt how to filter and limit your response. Next up you will learn how to sort the API response.
After filtering and limiting, comes sorting! In this tutorial, we’ll teach you how to sort the API response and why this might come in handy for you. In other words, you will learn how to order the API response on a specific field.
Sorting as its name implies, is the act of having the API sort data in an ascending or descending logical order. So, we have the following numbers: 8, 3, 7, 5, 1 If we sort this in ascending form: 1, 3, 5, 7, 8 Descending form: 8, 7, 5, 3, 1
Now, let's apply this logic to our API. Every fixture is assigned a unique id at the announcement of a new season. Our API logically orders these ids. The first fixture’s id ends with one, the second fixture’s id with two, etc. However, during the season, games get rescheduled all the time. This will most of the time result in updated games, but since the game ids haven't changed, it might result in weird responses.
Let’s say fixture #5 is scheduled to be played in round one but gets rescheduled and will now be played in the last round of the season. The API still lists the fixture as the fifth match, but the start date is now much later in the season. Therefore, the response is not in order of the original starting date.
To avoid this, we want the API to sort the response with all the fixtures in the correctly scheduled order. We can do this by using the attribute called starting_at
.
Note that you can only sort on included data. When you’ve included the fixtures, you can sort on all the fields in the fixture data.
First, the standard request without the sorting:
Season Field Description
Fixtures Field Description
This URL requests all the fixtures of the 20/21 season of the Scottish Premiership (season id: 17141).
Second, we add in the :order(starting_at | asc)
to sort the request in the ascending order:
The above request will give you all the matches sorted by the starting_at
attribute in ascending (asc) order, but you can also request it in the descending (desc) order.
This sorting option will get you all the fixtures in the preferred scheduled order. See how the order changes based on the starting_at
attribute?
And that’s all there is to sorting API requests!
With that, we have reached the end of our Sorting tutorial. In the next chapter, we’ll discuss one of the most important endpoints, namely season schedule, fixtures and livescores.
We recommend you submit your requests with Postman since we have already prepared the request for you there! Hit the button below to import our Football API collection.
Field
Description
data
Opens an array of data you've requested
id
The unique season id
name
The name of the season
league_id
The unique league id the season belongs to
is_current_season
Indicates if the season is the current one. Possible values are "true" or "false"
current_round_id
The unique id of the current round
current_stage_id
The unique id of the current stage
Field
Description
data
Opens an array of data you've requested
id
A unique fixture id
league_id
The unique id of the league the fixture belongs to
season_id
The unique id of the season the fixture belongs to
stage_id
The unique id of the stage the fixture belongs to
round_id
The unique id of the round the fixture belongs to
group_id
The unique id of the group the fixture belongs to
aggregate_id
Indicates if the fixture has an aggregated score
venue_id
The unique id of the venue the fixture is played at
referee_id
The unique id of the referee that is in charge of the fixture
localteam_id
The unique id of the local team
visitorteam_id
The unique id of the visitor team
winnerteam_id
Contains the id of the team that won the fixture
weather_report
Opens an array of weather details. Possible values of the data in this array can be found in our statuses and definitions
commentaries
Indicates if this fixture has commentaries available
attendance
Give information about the visitor attendance of the fixture
pitch
Gives information about the pitch. Possible values can be found in our statuses and definitions
details
Optional additional information.
neutral_venue
Indicates if the fixture was played at a neutral fixture. This often happens in cup finals
formations
Opens an array containing the lineup formations of the teams. Possible values can be found in our statuses and definitions
scores
Opens an array containing the scores of the fixture
localteam_score
The amount of goals the local team has scored in this fixture
visitorteam_score
The amount of goals the visitor team has scored in this fixture
localteam_pen_score
The amount of penalty goals the local team has scored in this fixture (only available when the fixture goes into penalty shootout)
visitorteam_pen_score
The amount of penalty goals the visitor team has scored in this fixture (only available when the fixture goes into penalty shootout)
ht_score
The score at half time
ft_score
The score at full time (90 minutes)
et_score
The score in extra time (only available when the fixture goes into extra time)
ps_score
The score of the penalty shootout (only available when the fixture goes into penalty shootout)
time
Opens an array containing the time details of the fixture
status
Indicates in which phase the fixture is in. Possible values can be found in our statuses and definitions
starting_at
Opens an array containing the time details of the fixture
date_time
Gives the date and time the fixture starts
date
Gives the date on which the fixture is played
time
Gives the starting time of the fixture
timestamp
The timestamp notation of the match
timezone
Indicates in which timezone you've requested the data
minute
Indicates in which minute the fixture is in
second
Indicates in which second the fixture is in
added_time
Indicates how many added time is added
extra_minute
Extra minute is when a fixture goes to extra time. Extra_minute will count from 0 to 15 and from 15 to 30.
injury_time
In case of added time it will end up in injury_minute
coaches
Opens an array containing the unique id's of the coaches
localteam_coach_id
The unique id of the coach from the local team
visitorteam_coach_id
The unique id of the coach from the visitor team
standings
Opens an array containing the standings of the local- and visitorteam
localteam_position
Indicates in which positions the local team is before the fixture
visitorteam_position
Indicates in which positions the visitor team is before the fixture
assistants
Opens an array containing the unique id's of the assistant referees
first_assistant_id
The unique id of the first assistant
second_assistant_id
The unique id of the second assistant
fourth_official_id
The unique id of the fourth official
leg
Indicates in how many legs this fixture is played
colors
Opens an array containing information about the team colors
localteam
Opens an array containing information about the local team colors
color
The main color code of the local team
kit_colors
The kit color codes of the local team
visitorteam
Opens an array containing information about the visitor team colors
color
The main color code of the visitor team
kit_colors
The kit color codes of the local team
deleted
Indicates if the team was deleted. More information: Keep in Sync
is_placeholder
This property indicates if the resource is used to display dummy data. The false of this property will always be a boolean
value.
Field
Description
data
Opens an array of data you've requested
id
The unique season id
name
The name of the season
league_id
The unique league id the season belongs to
is_current_season
Indicates if the season is the current one. Possible values are "true" or "false"
current_round_id
The unique id of the current round
current_stage_id
The unique id of the current stage
Field
Description
data
Opens an array of data you've requested
id
A unique fixture id
league_id
The unique id of the league the fixture belongs to
season_id
The unique id of the season the fixture belongs to
stage_id
The unique id of the stage the fixture belongs to
round_id
The unique id of the round the fixture belongs to
group_id
The unique id of the group the fixture belongs to
aggregate_id
Indicates if the fixture has an aggregated score
venue_id
The unique id of the venue the fixture is played at
referee_id
The unique id of the referee that is in charge of the fixture
localteam_id
The unique id of the local team
visitorteam_id
The unique id of the visitor team
winnerteam_id
Contains the id of the team that won the fixture
weather_report
Opens an array of weather details. Possible values of the data in this array can be found in our statuses and definitions
commentaries
Indicates if this fixture has commentaries available
attendance
Give information about the visitor attendance of the fixture
pitch
Gives information about the pitch. Possible values can be found in our statuses and definitions
details
Optional additional information.
neutral_venue
Indicates if the fixture was played at a neutral fixture. This often happens in cup finals
formations
Opens an array containing the lineup formations of the teams. Possible values can be found in our statuses and definitions
scores
Opens an array containing the scores of the fixture
localteam_score
The amount of goals the local team has scored in this fixture
visitorteam_score
The amount of goals the visitor team has scored in this fixture
localteam_pen_score
The amount of penalty goals the local team has scored in this fixture (only available when the fixture goes into penalty shootout)
visitorteam_pen_score
The amount of penalty goals the visitor team has scored in this fixture (only available when the fixture goes into penalty shootout)
ht_score
The score at half time
ft_score
The score at full time (90 minutes)
et_score
The score in extra time (only available when the fixture goes into extra time)
ps_score
The score of the penalty shootout (only available when the fixture goes into penalty shootout)
time
Opens an array containing the time details of the fixture
status
Indicates in which phase the fixture is in. Possible values can be found in our statuses and definitions
starting_at
Opens an array containing the time details of the fixture
date_time
Gives the date and time the fixture starts
date
Gives the date on which the fixture is played
time
Gives the starting time of the fixture
timestamp
The timestamp notation of the match
timezone
Indicates in which timezone you've requested the data
minute
Indicates in which minute the fixture is in
second
Indicates in which second the fixture is in
added_time
Indicates how many added time is added
extra_minute
Extra minute is when a fixture goes to extra time. Extra_minute will count from 0 to 15 and from 15 to 30.
injury_time
In case of added time it will end up in injury_minute
coaches
Opens an array containing the unique id's of the coaches
localteam_coach_id
The unique id of the coach from the local team
visitorteam_coach_id
The unique id of the coach from the visitor team
standings
Opens an array containing the standings of the local- and visitorteam
localteam_position
Indicates in which positions the local team is before the fixture
visitorteam_position
Indicates in which positions the visitor team is before the fixture
assistants
Opens an array containing the unique id's of the assistant referees
first_assistant_id
The unique id of the first assistant
second_assistant_id
The unique id of the second assistant
fourth_official_id
The unique id of the fourth official
leg
Indicates in how many legs this fixture is played
colors
Opens an array containing information about the team colors
localteam
Opens an array containing information about the local team colors
color
The main color code of the local team
kit_colors
The kit color codes of the local team
visitorteam
Opens an array containing information about the visitor team colors
color
The main color code of the visitor team
kit_colors
The kit color codes of the local team
deleted
Indicates if the team was deleted. More information: Keep in Sync
is_placeholder
This property indicates if the resource is used to display dummy data. The false of this property will always be a boolean
value.