Includes

What are 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. 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!

Creating the request

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:
1
https://soccer.sportmonks.com/api/v2.0/fixtures/date/2020-08-02?api_token={API_TOKEN}
Copied!
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.

Evaluating the response

All of our endpoints will give you a ‘basic’ response by default. As you can see, we will receive information mostly containing unique ids.
Response
Field description
1
{
2
"data": [
3
{
4
"id": 16475287,
5
"league_id": 501,
6
"season_id": 17141,
7
"stage_id": 77447501,
8
"round_id": 194968,
9
"group_id": null,
10
"aggregate_id": null,
11
"venue_id": 8909,
12
"referee_id": 14859,
13
"localteam_id": 53,
14
"visitorteam_id": 338,
15
"winner_team_id": 53,
16
"weather_report": {
17
"code": "clouds",
18
"type": "few clouds",
19
"icon": "https://cdn.sportmonks.com/images/weather/02d.png",
20
"temperature": {
21
"temp": 59.94,
22
"unit": "fahrenheit"
23
},
24
"temperature_celcius": {
25
"temp": 15.5,
26
"unit": "celcius"
27
},
28
"clouds": "20%",
29
"humidity": "67%",
30
"pressure": 1014,
31
"wind": {
32
"speed": "10.29 m/s",
33
"degree": 300
34
},
35
"coordinates": {
36
"lat": 55.87,
37
"lon": -4.26
38
},
39
"updated_at": "2020-08-02T17:15:04.814798Z"
40
},
41
"commentaries": false,
42
"attendance": null,
43
"pitch": null,
44
"details": null,
45
"neutral_venue": false,
46
"winning_odds_calculated": true,
47
"formations": {
48
"localteam_formation": "4-2-3-1",
49
"visitorteam_formation": "4-4-2"
50
},
51
"scores": {
52
"localteam_score": 5,
53
"visitorteam_score": 1,
54
"localteam_pen_score": null,
55
"visitorteam_pen_score": null,
56
"ht_score": "2-1",
57
"ft_score": "5-1",
58
"et_score": null,
59
"ps_score": null
60
},
61
"time": {
62
"status": "FT",
63
"starting_at": {
64
"date_time": "2020-08-02 15:30:00",
65
"date": "2020-08-02",
66
"time": "15:30:00",
67
"timestamp": 1596382200,
68
"timezone": "UTC"
69
},
70
"minute": 90,
71
"second": null,
72
"added_time": null,
73
"extra_minute": null,
74
"injury_time": null
75
},
76
"coaches": {
77
"localteam_coach_id": 1467946,
78
"visitorteam_coach_id": 30082158
79
},
80
"standings": {
81
"localteam_position": 1,
82
"visitorteam_position": 12
83
},
84
"assistants": {
85
"first_assistant_id": 12118,
86
"second_assistant_id": 17249,
87
"fourth_official_id": 15815
88
},
89
"leg": "1/1",
90
"colors": {
91
"localteam": {
92
"color": "#007848",
93
"kit_colors": "#F0F0F0,#139343,#5B0623,#0A0A0A,#5C8FAE,#FFDF1B,#F0F0F0"
94
},
95
"visitorteam": {
96
"color": "#0046A8",
97
"kit_colors": "#0046A8,#0046A8,#0046A8,#0046A8,#C40010,#0046A8,#0046A8"
98
}
99
},
100
"deleted": false,
101
"is_placeholder": false,
102
}
103
],
104
Copied!
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
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?

Enrich your response with includes!

This is where includes come into play. By merely adding&include=localTeam,visitorTeamto 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.
1
https://soccer.sportmonks.com/api/v2.0/fixtures/date/2020-08-02?api_token={API_TOKEN}&include=localTeam,visitorTeam
Copied!
As you can see, there is an extra part included in comparison to the basic response:
Response
Field Description
1
"localTeam": {
2
"data": {
3
"id": 53,
4
"legacy_id": 152,
5
"name": "Celtic",
6
"short_code": "CEL",
7
"twitter": null,
8
"country_id": 1161,
9
"national_team": false,
10
"founded": 1888,
11
"logo_path": "https://cdn.sportmonks.com/images//soccer/teams/21/53.png",
12
"venue_id": 8909,
13
"current_season_id": 17141
14
}
15
},
16
"visitorTeam": {
17
"data": {
18
"id": 338,
19
"legacy_id": 693,
20
"name": "Hamilton Academical",
21
"short_code": "HMA",
22
"twitter": null,
23
"country_id": 1161,
24
"national_team": false,
25
"founded": 1874,
26
"logo_path": "https://cdn.sportmonks.com/images//soccer/teams/18/338.png",
27
"venue_id": 288196,
28
"current_season_id": 17141
29
}
30
}
31
32
}
Copied!
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
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:
1
https://soccer.sportmonks.com/api/v2.0/fixtures/date/2020-08-02?api_token={API_TOKEN}&include=localTeam,visitorTeam,events
Copied!
And we'll get all the events per fixture. You can view a snippet of the response below.
Response
Field Description
1
"events": {
2
"data": [
3
{
4
"id": 16475287001,
5
"team_id": "338",
6
"type": "yellowcard",
7
"var_result": null,
8
"fixture_id": 16475287,
9
"player_id": 174161,
10
"player_name": "S. Martin",
11
"related_player_id": null,
12
"related_player_name": null,
13
"minute": 17,
14
"extra_minute": null,
15
"reason": null,
16
"injuried": null,
17
"result": null
18
},
19
{
20
"id": 16475287002,
21
"team_id": "53",
22
"type": "goal",
23
"var_result": null,
24
"fixture_id": 16475287,
25
"player_id": 96792,
26
"player_name": "O. Édouard",
27
"related_player_id": 173080,
28
"related_player_name": "G. Taylor",
29
"minute": 20,
30
"extra_minute": null,
31
"reason": null,
32
"injuried": null,
33
"result": "1-0"
34
},
35
{
36
"id": 16475287003,
37
"team_id": "53",
38
"type": "goal",
39
"var_result": null,
40
"fixture_id": 16475287,
41
"player_id": 8403182,
42
"player_name": "J. Frimpong",
43
"related_player_id": 173080,
44
"related_player_name": "G. Taylor",
45
"minute": 31,
46
"extra_minute": null,
47
"reason": null,
48
"injuried": null,
49
"result": "2-0"
50
},
51
{
52
"id": 16475287004,
53
"team_id": "338",
54
"type": "own-goal",
55
"var_result": null,
56
"fixture_id": 16475287,
57
"player_id": 32761,
58
"player_name": "C. Jullien",
59
"related_player_id": null,
60
"related_player_name": null,
61
"minute": 34,
62
"extra_minute": null,
63
"reason": null,
64
"injuried": null,
65
"result": "2-1"
66
},
67
{
68
"id": 16475287005,
69
"team_id": "338",
70
"type": "yellowcard",
71
"var_result": null,
72
"fixture_id": 16475287,
73
"player_id": 173774,
74
"player_name": "R. Callachan",
75
"related_player_id": null,
76
"related_player_name": null,
77
"minute": 36,
78
"extra_minute": null,
79
"reason": null,
80
"injuried": null,
81
"result": null
82
},
83
],
84
}
Copied!
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)
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.

Conclusion

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.