Team statistics

Next to the fixture and season fixtures, you can request team statistics. You can use the Team by ID endpoint with the statistics include. For example, for Rangers (id: 62)

https://api.sportmonks.com/v3/football/teams/62?api_token=YOUR_TOKEN&include=statistics
Response
{
  "data": {
    "id": 62,
    "sport_id": 1,
    "country_id": 1161,
    "venue_id": 8914,
    "gender": "male",
    "name": "Rangers",
    "short_code": "RAN",
    "image_path": "https://cdn.sportmonks.com/images/soccer/teams/30/62.png",
    "founded": 1873,
    "type": "domestic",
    "placeholder": false,
    "last_played_at": "2023-02-26 15:00:00",
    "statistics": [
      {
        "id": 42108,
        "team_id": 62,
        "season_id": 821,
        "has_values": true
      },
      {
        "id": 42277,
        "team_id": 62,
        "season_id": 825,
        "has_values": true
      },
      {
        "id": 42288,
        "team_id": 62,
        "season_id": 827,
        "has_values": true
      },

Now, just like in the previous section, you need to add details to retrieve the statistics values and type to retrieve the name of the statistics:

https://api.sportmonks.com/v3/football/teams/62?api_token=YOUR_TOKEN&include=statistics.details.type
Response
{
  "data": {
    "id": 62,
    "sport_id": 1,
    "country_id": 1161,
    "venue_id": 8914,
    "gender": "male",
    "name": "Rangers",
    "short_code": "RAN",
    "image_path": "https://cdn.sportmonks.com/images/soccer/teams/30/62.png",
    "founded": 1873,
    "type": "domestic",
    "placeholder": false,
    "last_played_at": "2023-02-26 15:00:00",
    "statistics": [
      {
        "id": 42108,
        "team_id": 62,
        "season_id": 821,
        "has_values": true,
        "details": [
          {
            "id": 371396,
            "team_statistic_id": 42108,
            "type_id": 88,
            "value": {
              "all": {
                "count": 4,
                "average": 1,
                "first": null
              },
              "home": {
                "count": 2,
                "percentage": 50,
                "average": 0.67,
                "first": null
              },
              "away": {
                "count": 2,
                "percentage": 50,
                "average": 2,
                "first": null
              }
            },
            "type": {
              "id": 88,
              "name": "Goals Conceded",
              "code": "goals-condeded",
              "developer_name": "GOALS_CONCEDED",
              "model_type": "statistic",
              "stat_group": "defensive"
            }
          },

Please check the response carefully to see the correct values with 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 team statistics

The API returns all the available season statistics for the requested team. Only interested in some of the seasons? You can use a filter only to retrieve stats for a specific season.

  1. Add the parameter &filters=

  2. Select the entity you want to filter on

  3. Select the field you want to filter on

  4. Fill in the IDs you're interested in

Let's say you're only interested in the statistics of the 2022/2023 season (id: 19735) this will result in the following steps:

  1. Add the parameter &filters=

  2. Select the entity you want to filter on: teamStatistic

  3. Select the field you want to filter on: Seasons

  4. Fill in the IDs you're interested in: 19735

https://api.sportmonks.com/v3/football/teams/62?api_token=YOUR_TOKEN&include=statistics.details.type&filters=teamStatisticSeasons:19735
Response
{
  "data": {
    "id": 62,
    "sport_id": 1,
    "country_id": 1161,
    "venue_id": 8914,
    "gender": "male",
    "name": "Rangers",
    "short_code": "RAN",
    "image_path": "https://cdn.sportmonks.com/images/soccer/teams/30/62.png",
    "founded": 1873,
    "type": "domestic",
    "placeholder": false,
    "last_played_at": "2023-02-26 15:00:00",
    "statistics": [
      {
        "id": 257394,
        "team_id": 62,
        "season_id": 19735,
        "has_values": true,
        "details": [
          {
            "id": 1932212,
            "team_statistic_id": 257394,
            "type_id": 84,
            "value": {
              "count": 51,
              "average": 1.96,
              "player_id": 92276,
              "player_name": "Alfredo Morelos"
            },
            "type": {
              "id": 84,
              "name": "Yellowcards",
              "code": "yellowcards",
              "developer_name": "YELLOWCARDS",
              "model_type": "statistic",
              "stat_group": "overall"
            }
          },
          {
            "id": 1931679,
            "team_statistic_id": 257394,
            "type_id": 44,
            "value": {
              "count": 1589,
              "average": 61.12
            },
            "type": {
              "id": 44,
              "name": "Dangerous Attacks",
              "code": "dangerous-attacks",
              "developer_name": "DANGEROUS_ATTACKS",
              "model_type": "statistic",
              "stat_group": "offensive"
            }
          },

Are you only interested in a specific statistic, like total team wins? Add another filter to your request:

  1. Add the parameter &filters=

  2. Select the entity you want to filter on

  3. Select the field you want to filter on

  4. Fill in the IDs you're interested in

Let's say you're only interested in the statistics number of wins. The this will result in the following steps:

  1. Add the parameter &filters=

  2. Select the entity you want to filter on: teamStatisticDetail

  3. Select the field you want to filter on: Types

  4. Fill in the IDs you're interested in: 214 (You can retrieve them via the Types endpoint or by looking at the previous request)

https://api.sportmonks.com/v3/football/teams/62?api_token=YOUR_TOKEN&include=statistics.details.type&filters=teamStatisticSeasons:19735;teamStatisticDetailTypes:214
Response
{
  "data": {
    "id": 62,
    "sport_id": 1,
    "country_id": 1161,
    "venue_id": 8914,
    "gender": "male",
    "name": "Rangers",
    "short_code": "RAN",
    "image_path": "https://cdn.sportmonks.com/images/soccer/teams/30/62.png",
    "founded": 1873,
    "type": "domestic",
    "placeholder": false,
    "last_played_at": "2023-02-26 15:00:00",
    "statistics": [
      {
        "id": 257394,
        "team_id": 62,
        "season_id": 19735,
        "has_values": true,
        "details": [
          {
            "id": 1932172,
            "team_statistic_id": 257394,
            "type_id": 214,
            "value": {
              "all": {
                "count": 20,
                "percentage": 76.92
              },
              "home": {
                "count": 11,
                "percentage": 55
              },
              "away": {
                "count": 9,
                "percentage": 45
              }
            },
            "type": {
              "id": 214,
              "name": "Team Wins",
              "code": "team-wins",
              "developer_name": "WIN",
              "model_type": "statistic",
              "stat_group": null
            }
          }
        ]
      }
    ]
  },

It's important to note that you can retrieve statistics from multiple entities. Therefore, you also 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: teamStatisticDetail

Are you interested in team statistics for a specific fixture? Check our fixture statistics tutorial.

Last updated