# Players statistics

Last but not least, you can retrieve player statistics. The fundamentals and steps are the same as for the team endpoint. First, you can use one of our players' endpoints. For example, the [Player by ID endpoint:](https://docs.sportmonks.com/v3/endpoints-and-entities/endpoints/players/get-player-by-id)

```javascript
https://api.sportmonks.com/v3/football/players/{id}?api_token=YOUR_TOKEN
```

Let's say you want the statistics of James Tavernier (id 758). You can use the statistics include:

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

<details>

<summary>Response</summary>

```javascript
{
  "data": {
    "id": 758,
    "sport_id": 1,
    "country_id": 462,
    "nationality_id": 462,
    "city_id": null,
    "position_id": 25,
    "detailed_position_id": 154,
    "type_id": 25,
    "common_name": "J. Tavernier",
    "firstname": "James",
    "lastname": "Tavernier",
    "name": "James Tavernier",
    "display_name": "James Tavernier",
    "image_path": "https://cdn.sportmonks.com/images/soccer/players/22/758.png",
    "height": 182,
    "weight": 75,
    "date_of_birth": "1991-10-31",
    "gender": "male",
    "statistics": [
      {
        "id": 27324842,
        "player_id": 758,
        "team_id": 62,
        "season_id": 825,
        "position_id": 25,
        "jersey_number": 2
      },
      {
        "id": 216445028,
        "player_id": 758,
        "team_id": 62,
        "season_id": 1929,
        "position_id": null,
        "jersey_number": 2
      },
```

</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/players/758?api_token=YOUR_TOKEN&include=statistics.details.type
```

<details>

<summary>Response</summary>

```javascript
{
  "data": {
    "id": 758,
    "sport_id": 1,
    "country_id": 462,
    "nationality_id": 462,
    "city_id": null,
    "position_id": 25,
    "detailed_position_id": 154,
    "type_id": 25,
    "common_name": "J. Tavernier",
    "firstname": "James",
    "lastname": "Tavernier",
    "name": "James Tavernier",
    "display_name": "James Tavernier",
    "image_path": "https://cdn.sportmonks.com/images/soccer/players/22/758.png",
    "height": 182,
    "weight": 75,
    "date_of_birth": "1991-10-31",
    "gender": "male",
    "statistics": [
      {
        "id": 27324842,
        "player_id": 758,
        "team_id": 62,
        "season_id": 825,
        "position_id": 25,
        "jersey_number": 2,
        "details": [
          {
            "id": 23799175,
            "player_statistic_id": 27324842,
            "type_id": 52,
            "value": {
              "total": 1,
              "goals": 1,
              "penalties": 0
            },
            "type": {
              "id": 52,
              "name": "Goals",
              "code": "goals",
              "developer_name": "GOALS",
              "model_type": "statistic",
              "stat_group": "offensive"
            }
          },
          {
            "id": 2926412,
            "player_statistic_id": 27324842,
            "type_id": 59,
            "value": {
              "in": 1,
              "out": 1
            },
            "type": {
              "id": 59,
              "name": "Substitutions",
              "code": "substitutions",
              "developer_name": "SUBSTITUTIONS",
              "model_type": "statistic",
              "stat_group": "overall"
            }
          },
          //And more
```

</details>

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

The API returns all the available season statistics for the requested player. Only interested in some of the seasons? You can use a filter to only 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: `playerStatistic`
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/players/758?api_token=YOUR_TOKEN&include=statistics.details.type&filters=playerStatisticSeasons:19735
```

<details>

<summary>Response</summary>

```javascript
{
  "data": {
    "id": 758,
    "sport_id": 1,
    "country_id": 462,
    "nationality_id": 462,
    "city_id": null,
    "position_id": 25,
    "detailed_position_id": 154,
    "type_id": 25,
    "common_name": "J. Tavernier",
    "firstname": "James",
    "lastname": "Tavernier",
    "name": "James Tavernier",
    "display_name": "James Tavernier",
    "image_path": "https://cdn.sportmonks.com/images/soccer/players/22/758.png",
    "height": 182,
    "weight": 75,
    "date_of_birth": "1991-10-31",
    "gender": "male",
    "statistics": [
      {
        "id": 520829,
        "player_id": 758,
        "team_id": 62,
        "season_id": 19735,
        "position_id": 25,
        "jersey_number": 2,
        "details": [
          {
            "id": 19937718,
            "player_statistic_id": 520829,
            "type_id": 40,
            "value": {
              "total": 26
            },
            "type": {
              "id": 40,
              "name": "Captain",
              "code": "captain",
              "developer_name": "CAPTAIN",
              "model_type": "statistic",
              "stat_group": "overall"
            }
          },
          {
            "id": 25931945,
            "player_statistic_id": 520829,
            "type_id": 41,
            "value": {
              "total": 2
            },
            "type": {
              "id": 41,
              "name": "Shots Off Target",
              "code": "shots-off-target",
              "developer_name": "SHOTS_OFF_TARGET",
              "model_type": "statistic",
              "stat_group": "offensive"
            }
          },
          //And more
```

</details>

Are you only interested in a specific statistic, like key passes? Add another filter to your request:

1. Add the parameter `&filters=`&#x20;
2. Select the entity you want to filter on: `playerStatisticDetail`
3. Select the field you want to filter on: `Types`
4. Fill in the IDs you're interested in: 117 for key passes (find all player stat types in the [Player Statistics Types Reference](https://docs.sportmonks.com/v3/definitions/types/statistics/player-statistics))

```javascript
https://api.sportmonks.com/v3/football/players/758?api_token=YOUR_TOKEN&include=statistics.details.type&filters=playerStatisticSeasons:19735;playerStatisticDetailTypes:117
```

<details>

<summary>Response</summary>

```javascript
{
  "data": {
    "id": 758,
    "sport_id": 1,
    "country_id": 462,
    "nationality_id": 462,
    "city_id": null,
    "position_id": 25,
    "detailed_position_id": 154,
    "type_id": 25,
    "common_name": "J. Tavernier",
    "firstname": "James",
    "lastname": "Tavernier",
    "name": "James Tavernier",
    "display_name": "James Tavernier",
    "image_path": "https://cdn.sportmonks.com/images/soccer/players/22/758.png",
    "height": 182,
    "weight": 75,
    "date_of_birth": "1991-10-31",
    "gender": "male",
    "statistics": [
      {
        "id": 520829,
        "player_id": 758,
        "team_id": 62,
        "season_id": 19735,
        "position_id": 25,
        "jersey_number": 2,
        "details": [
          {
            "id": 24430323,
            "player_statistic_id": 520829,
            "type_id": 117,
            "value": {
              "total": 72
            },
            "type": {
              "id": 117,
              "name": "Key Passes",
              "code": "key-passes",
              "developer_name": "KEY_PASSES",
              "model_type": "statistic",
              "stat_group": "overall"
            }
          }
        ]
      }
    ]
  },
```

</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: `playerStatisticDetail`

Are you interested in player statistics for a specific fixture? Check our [fixture statistics tutorial.](https://docs.sportmonks.com/v3/tutorials-and-guides/tutorials/statistics/fixture-statistics)

{% hint style="info" %}
Interested in coaches and referees? You can use the same steps as for the player's statistics tutorial. Simply change the entity from players to referees or coaches and use the according endpoints. &#x20;

Coach example:

`https://api.sportmonks.com/v3/football/coaches/{ID}?api_token=YOUR_TOKEN&include=statistics.details.type`<br>

Referee example:&#x20;

`https://api.sportmonks.com/v3/football/referees/{ID}?api_token=YOUR_TOKEN&include=statistics.details.type`
{% endhint %}

### See also

#### Prerequisites

* [Statistics Types](https://docs.sportmonks.com/v3/tutorials-and-guides/tutorials/statistics/statistics-types) - Learn how statistic types work
* [Includes Tutorial](https://docs.sportmonks.com/v3/tutorials-and-guides/tutorials/includes) - Understand nested includes

#### Reference

* [Player Statistics Types](https://docs.sportmonks.com/v3/definitions/types/statistics/player-statistics) - Complete list of player stat types (goals, assists, passes, etc.)
* [Statistics Types Overview](https://docs.sportmonks.com/v3/definitions/types/statistics) - All available statistic types
* [Player Endpoint](https://docs.sportmonks.com/v3/endpoints-and-entities/endpoints/players) - API reference

#### Related Tutorials

* [Fixture Statistics](https://docs.sportmonks.com/v3/tutorials-and-guides/tutorials/statistics/fixture-statistics) - Player stats within specific matches
* [Team Statistics](https://docs.sportmonks.com/v3/tutorials-and-guides/tutorials/statistics/team-statistics) - Team-level performance data
* [Filter and Select Fields](https://docs.sportmonks.com/v3/tutorials-and-guides/tutorials/filter-and-select-fields) - Filter statistics by type
