Includes are the cornerstone of our API and allow you to enrich and customize your requests. This flexibility is what distinguishes Sportmonks from all competitors. This manner of flexibility lets you receive the specific data that interests you. Each endpoint comes with a list of includes. For more information, please refer to our API reference guide.
You can see includes as something like an add-on to an endpoint. In this tutorial, we will show and explain what includes are and how you can make use of them. Don’t worry, though; using includes is relatively straightforward!
In this tutorial, our goal is to analyze a match played on the 2nd of August 2020. We want to know who the teams are and what events (goals, cards, substitutions) happened during the match. Our starting endpoint will be fixture get by date:
The date is in YYYY-MM-DD format:
This request will give you all the fixtures of a specific date. In our case, the 2nd of August 2020, which is what we want.
Note that you only have access to the leagues that are available in your plan.
All of our endpoints will give you a ‘basic’ response by default. As you can see, we will receive information mostly containing unique ids.
You can see the fixture id, the local and visitor teams’ id, and the full-time score. However, what if we want to know more about the participating teams, their team names, or what their logos look like?
This is where includes come into play. By merely adding&include=localTeam,visitorTeam
to the request, we have successfully used includes. This request will show you the extra data about the home and visitor teams because we've ‘included’ information about the local and visitor teams.
As you can see, there is an extra part included in comparison to the basic response:
The API will give you all the information about the local and visitor teams. You can see the team names, the logos when the team was founded, the venue id, and the id of the current season they’re participating in.
Like shooting fish in a barrel, right?
But we’re not done yet! We still want to know about the events (goals, cards, and substitutions) that happened during the match.
Our API has close to no limit on the number of includes per endpoint. This allows you to request all the extra data you want in the same request. So, we can simply add the include events
to our request:
And we'll get all the events per fixture. You can view a snippet of the response below.
Now we have extra information about the participating teams and all the events of a fixture! Just like that, we have achieved our goal. Includes are basically add-ons that you can use with your request for additional information. The endpoint provides basic data, while the include gives you extra information.
Not all includes work with every endpoint. So please make sure that you check which includes are available per endpoint in our API reference guide.
There are also more advanced, includes called nested includes. These are relationships of relationships. You can already check out our nested includes tutorial for more information.
Not seeing all the data you expected to see? Check out our tutorial about pagination.
We ended the previous chapter with a small teaser about nested includes. Now in this part, we finally present to you the nested include. This tutorial will teach you what it is, where it is used and how you can apply them yourself.
Life is all about relationships. You are, for example, your parents’ child, your sister’s sibling, etc. Nested includes are no different from this because they too share a relationship with includes. The nested include allows you to further enrich your data, by requesting more information from a standard include. Might sound difficult, but we assure you, it’s anything but hard. This is how we use Nested includes.
For example, in our includes tutorial you’ve enriched your fixture by date request with the team and events includes:
The include event shows you the data about players who received a card, scored a goal, or were substituted. A snippet of the response:
But, what if we want to know more about these players, who scored a goal, like their country of origin, height, weight, age, image, etc. This is where the nested include comes into play!
Because the include event is related to a player. You can add .player
to the include, which will result in the nested include: events.player
The nested includes are represented in the form of dots (.), which are then linked to a standard include. This shows their relationship.
Now you've learnt how to enrich your response. In the next chapter you will learn how you can filter, sort and limit the response.
In this chapter, you will learn how to enrich your API request by using includes. Includes are the cornerstone of our API and allow you to enrich and customize your requests. This flexibility is what distinguishes Sportmonks from all competitors.
Already know what includes are? No worries, we've got some extra information for you in this chapter: nested includes.
You can also skip this chapter and dive straight into filtering, sorting and limiting right away.
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 visitor team
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
localTeam
Opens an array with information about the local team
id
The unique id of the local team
legacy_id
This was for our API version 1.0. It's only of use for old users of our API
name
The name of the local team
short_code
The shortcode of the local team
twitter
The official Twitter page of the local team
country_id
The unique country id the local team belongs to
national_team
Indicates if the local team is a national team
founded
The year when the local team was founded
logo_path
The logo URL path of the local team logo
venue_id
The official venue of the local team
current_season_id
The unique id of the domestic season the local team is active in
visitorTeam
Opens an array with information about the visitor team
id
The unique id of the visitor team
legacy_id
This was for our API version 1.0. It's only of use for old users of our API
name
The name of the visitor team
short_code
The shortcode of the visitor team
twitter
The official Twitter page of the visitor team
country_id
The unique country id the visitor team belongs to
national_team
Indicates if the visitor team is a national team
founded
The year when the visitor team was founded
logo_path
The logo URL path of the visitor team logo
venue_id
The official venue of the visitor team
current_season_id
The unique id of the domestic season the visitor team is active in
Field
Description
id
The unique id of an event
team_id
The id of team the event belongs to
type
The event type. Possible values can be found in our statuses and definitions
var_result
The outcome of the Video Assistant Referee intervention. Possible values can be found in our statuses and definitions
fixture_id
The unique id of the fixture
player_id
The unique id of the main player involved in the event
player_name
The name of the main player involved in the event
related_player_id
The unique id of the second player involved in the event (if applicable)
related_player_name
The name of the second player involved in the event (if applicable)
minute
The minute of the fixture the event happened in
extra_minute
The extra minute of the fixture the event happened in (if applicable)
reason
The reason for the event. Mostly available when the event is a card. (if applicable)
injuried
Indicates if the event resulted in an injured player
results
The result of the event. Mostly available when the event is a goal. (if applicable)
Field
Description
id
The unique id of an event
team_id
The id of team the event belongs to
type
The event type. Possible values can be found in our statuses and definitions
var_result
The outcome of the Video Assistant Referee intervention. Possible values can be found in our statuses and definitions
fixture_id
The unique id of the fixture
player_id
The unique id of the main player involved in the event
player_name
The name of the main player involved in the event
related_player_id
The unique id of the second player involved in the event (if applicable)
related_player_name
The name of the second player involved in the event (if applicable)
minute
The minute of the fixture the event happened in
extra_minute
The extra minute of the fixture the event happened in (if applicable)
reason
The reason of the event. Mostly available when the event is a card. (if applicable)
injuried
Indicates if the event resulted in an injured player
results
The result of the event. Mostly available when the event is a goal. (if applicable)
Field
Description
player_id
The unique id of the main player involved in the event
team_id
The unique id of the team the event belongs to
country_id
The unique id of the country the team plays in
position_id
The unique id of the position the player plays in
common_name
The common name the player is known for
display_name
The display name of the player. Often used to show in the lineup formation
fullname
The full name of the player
firstname
The first name of the player
lastname
The last name of the player
nationality
The nationality of the player
birthdate
The date of birth of the player
birthcountry
The country the player was born in
birthplace
The place the player was born in
height
The height of the player
weight
The weight of the player
image_path
The URL of the player image