Keep track of exciting season statistics. We calculate a wide range of stats for you, like the number of matches, matches played, goals scored, clean sheets, yellow cards, average goals per minute, etc. There are multiple ways to retrieve season statistics, but the most commonly used is the GET Season by ID endpoint with the statistics include:
Our API returns many values, but what do they mean exactly? And how can you display the type of statistic? You can use the nested include statistics.type for this:
Now, the season statistics' names and types are also returned. For example, at the time of writing, you can see 198 matches in the season; 159 have already been played, giving a percentage of 80.3%—this is a fantastic way to show the season's progression.
Please check the response carefully to see the correct values for the types.
Including .type is not recommended as an include on any endpoint. Types are used throughout the entire API. We recommend retrieving all types from the types endpoint and storing them in your database or other data structure. Only include the type if no other option is available or when testing the API.
Filtering season statistics
The API returns a lot of season statistics, but we can imagine you're interested in only some of them. Therefore, it might be good to filter only the data you want.
Let's say you're only interested in the number of goals, cards, and clean sheets. In our case, this will result in the following steps:
Add the parameter &filters=
Select the entity you want to filter on: seasonStatistic
Select the field you want to filter on: Types (the statistics types)
Fill in the IDs you're interested in: 191,193,194 (You can retrieve them via the Types endpoint or by looking at the previous request)
It's important to note that you can retrieve statistics from multiple entities. Therefore, you need to specify for which entity you want to filter the statistics. You can do this by prefixing the filter with the entity's name. So in our case: seasonStatistic