> For the complete documentation index, see [llms.txt](https://docs.sportmonks.com/v3/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sportmonks.com/v3/tutorials-and-guides/tutorials/statistics/team-statistics.md).

# Team statistics

Next to the fixture and season fixtures, you can request team statistics. You can use the [Team by ID endpoint ](/v3/endpoints-and-entities/endpoints/teams/get-team-by-id.md)with the `statistics` include. For example, for Rangers (id: 62)

```javascript
https://api.sportmonks.com/v3/football/teams/62?api_token=YOUR_TOKEN&include=statistics
```

<details>

<summary>Response</summary>

```javascript
{
  "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
      },
```

</details>

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:&#x20;

```javascript
https://api.sportmonks.com/v3/football/teams/62?api_token=YOUR_TOKEN&include=statistics.details.type
```

<details>

<summary>Response</summary>

```javascript
{
  "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"
            }
          },
```

</details>

Please check the response carefully to see the correct values with the types.&#x20;

{% hint style="danger" %}
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.
{% endhint %}

### 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=`&#x20;
2. Select the entity you want to filter on&#x20;
3. Select the field you want to filter on&#x20;
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=`&#x20;
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`

```javascript
https://api.sportmonks.com/v3/football/teams/62?api_token=YOUR_TOKEN&include=statistics.details.type&filters=teamStatisticSeasons:19735
```

<details>

<summary>Response</summary>

```javascript
{
  "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"
            }
          },
```

</details>

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

1. Add the parameter `&filters=`&#x20;
2. Select the entity you want to filter on&#x20;
3. Select the field you want to filter on&#x20;
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=`&#x20;
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 for wins (you can find all type IDs in the[ Statistics Types Reference](https://docs.sportmonks.com/v3/tutorials-and-guides/tutorials/statistics/statistics-types))

```javascript
https://api.sportmonks.com/v3/football/teams/62?api_token=YOUR_TOKEN&include=statistics.details.type&filters=teamStatisticSeasons:19735;teamStatisticDetailTypes:214
```

<details>

<summary>Response</summary>

```javascript
{
  "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
            }
          }
        ]
      }
    ]
  },
```

</details>

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`

### See also

#### Prerequisites

* [Statistics Types](https://docs.sportmonks.com/v3/tutorials-and-guides/tutorials/statistics/statistics-types) - Understand statistic type IDs and categories
* [Includes Tutorial](https://docs.sportmonks.com/v3/tutorials-and-guides/tutorials/includes) - Master the includes parameter

#### Reference

* [Statistics Types List](https://docs.sportmonks.com/v3/definitions/types/statistics) - Full reference of team statistic types (wins, goals, cards, etc.)
* [Team Statistics Endpoint](https://docs.sportmonks.com/v3/endpoints-and-entities/endpoints/teams) - API endpoint documentation

#### Related Tutorials

* [Fixture Statistics](https://docs.sportmonks.com/v3/tutorials-and-guides/tutorials/statistics/fixture-statistics) - Team stats for specific matches
* [Season Statistics](https://docs.sportmonks.com/v3/tutorials-and-guides/tutorials/statistics/season-statistics) - League performance data
* [Filter and Select Fields](/v3/tutorials-and-guides/tutorials.md) - Filter by type ID


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.sportmonks.com/v3/tutorials-and-guides/tutorials/statistics/team-statistics.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
