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.