# Teams

> **Included in all plans**
>
> Team data is included in all base plans (Starter, Growth, Pro, Enterprise) at no additional cost.
>
> Plans differ only in:
>
> * Number of leagues (5 leagues → all leagues)
> * API call limits (2,000 → 5,000+ calls/hour)
>
> [Compare plans →](https://www.sportmonks.com/football-api/plans-pricing)

Every country, league, and season has multiple teams included. The team endpoints are important to show the teams, team stats, and other team data.

This section will briefly discuss all the options available to request teams.

An overview of all the options available:

* **GET All Teams:** returns all the teams that are accessible within your subscription.
* **GET Team by ID:** returns the single team you’ve requested by id.
* **GET Team by Country ID:** returns all the teams from your requested country id.
* **GET Team by Season ID:** returns all the teams from your requested season id.
* **GET Team Search by Name:** returns all the teams that match your search query.
* **GET Team Current Leagues by ID:** returns all the current leagues from your requested team id.
* **GET Team All Leagues by ID:** returns all the current and historical leagues from your requested team id.

The base URL is the same for all team endpoints:&#x20;

```http
https://api.sportmonks.com/v3/football/teams
```

Per endpoint, the rest of the URL requires additional information. We will explain this per endpoint.

## Requesting Teams&#x20;

### GET All Teams&#x20;

To get your database filled with all teams in your subscription, you can gather all teams via the [GET All Teams endpoint.](https://docs.sportmonks.com/v3/endpoints-and-entities/endpoints/teams/get-all-teams) The URL to get all your teams is the same as the base URL for teams. All you have to do is authorize the request with your API token. Check our [authentication section](https://docs.sportmonks.com/v3/welcome/authentication) for more info.

{% code overflow="wrap" %}

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

{% endcode %}

<details>

<summary>Response</summary>

```javascript
{
  "data": [
    {
      "id": 53,
      "sport_id": 1,
      "country_id": 1161,
      "venue_id": 8909,
      "gender": "male",
      "name": "Celtic",
      "short_code": "CEL",
      "image_path": "https://cdn.sportmonks.com/images/soccer/teams/21/53.png",
      "founded": 1888,
      "type": "domestic",
      "placeholder": false,
      "last_played_at": "2023-02-26 15:00:00"
    },
    {
      "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"
    },
    //and more
```

</details>

Let’s take a look together at what the API returns. As you can see, the API returns all the teams available in the free plan.

You can see the team id, country id, venue id, gender, name, shortcode and image. You can see details about when the club was founded and played its last match.&#x20;

Now that you've requested all the teams, you also know their unique team id. You can use this id in the second option: [GET Team by ID.](https://docs.sportmonks.com/v3/endpoints-and-entities/endpoints/teams/get-team-by-id)

### GET Teams by ID&#x20;

This endpoint is useful if you only want information about one particular team. You need to add the `team_id` to your request:

`https://api.sportmonks.com/v3/football/teams`**`/{team_id}`**

For example, if you’re interested in information about Celtic (team id: 53).

{% code overflow="wrap" %}

```javascript
https://api.sportmonks.com/v3/football/teams/53?api_token=YOUR_TOKEN
```

{% endcode %}

<details>

<summary>Response</summary>

```javascript
{
  "data": {
    "id": 53,
    "sport_id": 1,
    "country_id": 1161,
    "venue_id": 8909,
    "gender": "male",
    "name": "Celtic",
    "short_code": "CEL",
    "image_path": "https://cdn.sportmonks.com/images/soccer/teams/21/53.png",
    "founded": 1888,
    "type": "domestic",
    "placeholder": false,
    "last_played_at": "2023-02-26 15:00:00"
  },
```

</details>

Easy isn’t it? You can now request information per team. Now let’s imagine you want an overview of all the teams in a specific country. The [GET Teams by Country ID](https://docs.sportmonks.com/v3/endpoints-and-entities/endpoints/teams/get-teams-by-country-id) option could be just the endpoint you’re looking for.

### GET Teams by Country ID&#x20;

This endpoint is useful if you only want information about teams from a specific country. You need to add the `country_id` to your request:

`https://api.sportmonks.com/v3/football/teams`**`/countries/{country_id}`**

For example, if you’re interested in all available Scottish teams in your subscription. (team id: 1161).

{% code overflow="wrap" %}

```javascript
https://api.sportmonks.com/v3/football/teams/countries/1161?api_token=YOUR_TOKEN
```

{% endcode %}

<details>

<summary>Response</summary>

```javascript
{
  "data": [
    {
      "id": 53,
      "sport_id": 1,
      "country_id": 1161,
      "venue_id": 8909,
      "gender": "male",
      "name": "Celtic",
      "short_code": "CEL",
      "image_path": "https://cdn.sportmonks.com/images/soccer/teams/21/53.png",
      "founded": 1888,
      "type": "domestic",
      "placeholder": false,
      "last_played_at": "2023-02-26 15:00:00"
    },
    {
      "id": 734,
      "sport_id": 1,
      "country_id": 1161,
      "venue_id": 219,
      "gender": "male",
      "name": "St. Johnstone",
      "short_code": "STJ",
      "image_path": "https://cdn.sportmonks.com/images/soccer/teams/30/734.png",
      "founded": 1885,
      "type": "domestic",
      "placeholder": false,
      "last_played_at": "2023-02-25 15:00:00"
    },
```

</details>

### GET Teams by Season ID&#x20;

The fourth option is to retrieve all teams from a specific season. This endpoint is useful if you want team information about current or historical seasons. You need to add the `season_id` to your request:

`https://api.sportmonks.com/v3/football/teams`**`/seasons/{season_id}`**

For example, if you’re interested in all the teams participating in the 2022/2023 Scottish Premiership. (season id: 19735).

{% code overflow="wrap" %}

```javascript
https://api.sportmonks.com/v3/football/teams/seasons/19735?api_token=YOUR_TOKEN
```

{% endcode %}

<details>

<summary>Response</summary>

```javascript
{
  "data": [
    {
      "id": 309,
      "sport_id": 1,
      "country_id": 1161,
      "venue_id": 8922,
      "gender": "male",
      "name": "Motherwell",
      "short_code": "MOT",
      "image_path": "https://cdn.sportmonks.com/images/soccer/teams/21/309.png",
      "founded": 1886,
      "type": "domestic",
      "placeholder": false,
      "last_played_at": "2023-02-25 15:00:00"
    },
    {
      "id": 180,
      "sport_id": 1,
      "country_id": 1161,
      "venue_id": 8906,
      "gender": "male",
      "name": "Kilmarnock",
      "short_code": "KIL",
      "image_path": "https://cdn.sportmonks.com/images/soccer/teams/20/180.png",
      "founded": 1869,
      "type": "domestic",
      "placeholder": false,
      "last_played_at": "2023-02-25 15:00:00"
    },
    
  //And more
```

</details>

### GET Teams Search by Name&#x20;

[This endpoint ](#get-teams-by-season-id-1)returns all the teams based on your search query. This might come in handy if you cannot find a team. To search on a team name, you’ll need to add `/search/{search_query}` to the teams base URL:

`https://api.sportmonks.com/v3/football/teams`**`/search/{search_query}`**

For example, if you could not find Celtic:

{% code overflow="wrap" %}

```javascript
https://api.sportmonks.com/v3/football/teams/search/Celtic?api_token=YOUR_TOKEN
```

{% endcode %}

<details>

<summary>Response</summary>

```javascript
{
  "data": [
    {
      "id": 53,
      "sport_id": 1,
      "country_id": 1161,
      "venue_id": 8909,
      "gender": "male",
      "name": "Celtic",
      "short_code": "CEL",
      "image_path": "https://cdn.sportmonks.com/images/soccer/teams/21/53.png",
      "founded": 1888,
      "type": "domestic",
      "placeholder": false,
      "last_played_at": "2023-02-26 15:00:00"
    }
  ],
```

</details>

{% hint style="info" %}
The more complete your search query is, the more relevant response you’ll get.
{% endhint %}

## Adding useful information

As you’ve learnt in the [includes tutorial](https://docs.sportmonks.com/v3/tutorials-and-guides/tutorials/includes), you can enrich your request with includes. This section will discuss some of the most common requests on the teams’ endpoints.

First of all, you can find a list of all available includes on the [endpoint pages](https://docs.sportmonks.com/v3/endpoints-and-entities/endpoints/teams). For teams the most common includes are: `players`, `seasons,` `statistics` and `sidelined`.

For example, if you’re interested in all the statistics of Celtic (team id: 53)

{% code overflow="wrap" %}

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

{% endcode %}

<details>

<summary>Response</summary>

```javascript
{
  "data": {
    "id": 53,
    "sport_id": 1,
    "country_id": 1161,
    "venue_id": 8909,
    "gender": "male",
    "name": "Celtic",
    "short_code": "CEL",
    "image_path": "https://cdn.sportmonks.com/images/soccer/teams/21/53.png",
    "founded": 1888,
    "type": "domestic",
    "placeholder": false,
    "last_played_at": "2023-02-26 15:00:00",
    "statistics": [
      {
        "id": 38080,
        "team_id": 53,
        "season_id": 718,
        "has_values": true,
        "details": [
          {
            "id": 345190,
            "team_statistic_id": 38080,
            "type_id": 194,
            "value": {
              "all": {
                "count": 1,
                "percentage": 8.33
              },
              "home": {
                "count": 1,
                "percentage": 100
              },
              "away": {
                "count": 0,
                "percentage": 0
              }
            },
            "type": {
              "id": 194,
              "name": "Cleansheets",
              "code": "cleansheets",
              "developer_name": "CLEANSHEET",
              "model_type": "statistic",
              "stat_group": null
            }
          },
```

</details>

{% 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 %}

## Selecting and filtering&#x20;

In our [filtering tutorial](https://docs.sportmonks.com/v3/tutorials-and-guides/tutorials/filter-and-select-fields/filtering), you’ve learnt how to select specific fields or filter only on the data you’re interested in. Our API returns a set of data related to the team by default. We imagine you’re not interested in all the team data the API returns. Let’s say you’re only interested in the team name and logo of Celtic.

You can add the `&select=` parameter followed by the fields you want. In our case: `&select=name,image_path`. This results in the below request and response:

{% code overflow="wrap" %}

```javascript
https://api.sportmonks.com/v3/football/teams/53?api_token=YOUR_TOKEN&select=name,image_path
```

{% endcode %}

<details>

<summary>Response</summary>

```javascript
{
  "data": {
    "name": "Celtic",
    "image_path": "https://cdn.sportmonks.com/images/soccer/teams/21/53.png",
    "id": 53,
    "sport_id": 1,
    "country_id": 1161,
    "venue_id": 8909
  },
```

</details>

{% hint style="info" %}
Check our [filtering tutorial](https://docs.sportmonks.com/v3/tutorials-and-guides/tutorials/filter-and-select-fields/filtering) for more information and tips.
{% endhint %}
