Make your first request

Now that all prerequisites have been fulfilled, we’re ready to send our first request to the API!

Before being able to make a request, you need to create your account in MySportmonks. Here you can create your personal API token, which you need to authenticate your requests. You can use the free plan or choose one of the various plans and data features of Sportmonks.

Build the request

The request consists of the following components:

  • The base URL

  • A path parameter, in this example, we use fixtures

  • Optional: Query string parameters, to filter on enrich your requests.

  • And finally, your API token

The base URL

In this example we're using the fixtures endpoint. The base URL of the fixtures endpoint is:

https://api.sportmonks.com/v3/football

Your API token

We offer two different options for passing your API token. You are free to choose between the authentication methods. You can also use both of them at the same time. Please note that both methods count towards the same rate-limiting.

Authenticate using a query parameter: You can pass your API token by passing 'api_token' in your request parameters, like so: https://api.sportmonks.com/v3/football?api_token=YOUR_TOKEN

Authenticate using a request header: You can also pass your token via an 'Authorization' header, like so:

HeaderValue

Authorization

YOUR_TOKEN

For example, this can results in the below request and response:

https://api.sportmonks.com/v3/football/fixtures?api_token=YOUR_TOKEN
Basic response
{
  "data": {
    "id": 18535517,
    "sport_id": 1,
    "league_id": 501,
    "season_id": 19735,
    "stage_id": 77457866,
    "group_id": null,
    "aggregate_id": null,
    "round_id": 274719,
    "state_id": 5,
    "venue_id": 8909,
    "name": "Celtic vs Rangers",
    "starting_at": "2022-09-03 11:30:00",
    "result_info": "Celtic won after full-time.",
    "leg": "1/1",
    "details": null,
    "length": 90,
    "placeholder": false,
    "last_processed_at": "2023-02-17 10:19:55",
    "has_odds": true,
    "starting_at_timestamp": 1662204600
  },
    // and more

The example above was the most basic request you can create, while our highly flexible football API 3.0 can handle way more advanced requests. Our API's data will enable you to create excellent and specialized applications.

Let’s make another request, and add an include to get more information. The includes can be found on the specific endpoint page. In our case, fixtures.

https://api.sportmonks.com/v3/football/fixtures?api_token=YOUR_TOKEN&include=statistics

You are getting the hang of it now. Let’s make one more request with multiple includes.

https://api.sportmonks.com/v3/football/fixtures?apitoken=YOUR_TOKEN&include=statistics;events;scores

Are you interested in seeing the difference in response when you use includes vs when you don't? Check the below response examples.

Resonse without includes
{
  "data": {
    "id": 18535517,
    "sport_id": 1,
    "league_id": 501,
    "season_id": 19735,
    "stage_id": 77457866,
    "group_id": null,
    "aggregate_id": null,
    "round_id": 274719,
    "state_id": 5,
    "venue_id": 8909,
    "name": "Celtic vs Rangers",
    "starting_at": "2022-09-03 11:30:00",
    "result_info": "Celtic won after full-time.",
    "leg": "1/1",
    "details": null,
    "length": 90,
    "placeholder": false,
    "last_processed_at": "2023-02-17 10:19:55",
    "has_odds": true,
    "starting_at_timestamp": 1662204600
  },
    // and more
Resonse with includes
{
  "data": {
    "id": 18535517,
    "sport_id": 1,
    "league_id": 501,
    "season_id": 19735,
    "stage_id": 77457866,
    "group_id": null,
    "aggregate_id": null,
    "round_id": 274719,
    "state_id": 5,
    "venue_id": 8909,
    "name": "Celtic vs Rangers",
    "starting_at": "2022-09-03 11:30:00",
    "result_info": "Celtic won after full-time.",
    "leg": "1/1",
    "details": null,
    "length": 90,
    "placeholder": false,
    "last_processed_at": "2023-02-17 10:19:55",
    "has_odds": true,
    "starting_at_timestamp": 1662204600,
    "scores": [
      {
        "id": 11316768,
        "fixture_id": 18535517,
        "type_id": 1,
        "participant_id": 53,
        "score": {
          "goals": 3,
          "participant": "home"
        },
        "description": "1ST_HALF"
      },
      {
        "id": 11316769,
        "fixture_id": 18535517,
        "type_id": 1,
        "participant_id": 62,
        "score": {
          "goals": 0,
          "participant": "away"
        },
        "description": "1ST_HALF"
      },
      {
        "id": 11316770,
        "fixture_id": 18535517,
        "type_id": 2,
        "participant_id": 53,
        "score": {
          "goals": 4,
          "participant": "home"
        },
        "description": "2ND_HALF"
      },
      {
        "id": 11316771,
        "fixture_id": 18535517,
        "type_id": 2,
        "participant_id": 62,
        "score": {
          "goals": 0,
          "participant": "away"
        },
        "description": "2ND_HALF"
      },
      {
        "id": 11316772,
        "fixture_id": 18535517,
        "type_id": 1525,
        "participant_id": 53,
        "score": {
          "goals": 4,
          "participant": "home"
        },
        "description": "CURRENT"
      },
      {
        "id": 11316773,
        "fixture_id": 18535517,
        "type_id": 1525,
        "participant_id": 62,
        "score": {
          "goals": 0,
          "participant": "away"
        },
        "description": "CURRENT"
      }
    ]
  },
// and more!        

API Syntax

Great, now you have used the first part of API 3.0’s syntax. A quick overview of the new syntax:

SyntaxUsageExample

&select=

Select specific fields on the base entity

&select=name

&include=

Include relations

&include=lineups

&filters=

Filter your request

&filters=eventTypes:15

;

Mark end of (nested) relation. You can start including other relations from here

&include=lineups;events;participants

:

Mark field selection

&include=lineups:player_name;events:player_name,related_player_name,minute

,

Used as separation to select or filter on more ids

&include=events:player_name,related_player_name,minute&filters=eventTypes:15

Request: use multiple include

For example, you want the scores, teams and events of a certain fixture. In this case, you would use scores;participants;events

https://api.sportmonks.com/v3/football/fixtures?api_token=YOUR_TOKEN&include=scores;participants;events
Response
{
  "data": {
    "id": 18535517,
    "sport_id": 1,
    "league_id": 501,
    "season_id": 19735,
    "stage_id": 77457866,
    "group_id": null,
    "aggregate_id": null,
    "round_id": 274719,
    "state_id": 5,
    "venue_id": 8909,
    "name": "Celtic vs Rangers",
    "starting_at": "2022-09-03 11:30:00",
    "result_info": "Celtic won after full-time.",
    "leg": "1/1",
    "details": null,
    "length": 90,
    "placeholder": false,
    "last_processed_at": "2023-02-17 10:19:55",
    "has_odds": true,
    "starting_at_timestamp": 1662204600,
    "scores": [
      {
        "id": 11316768,
        "fixture_id": 18535517,
        "type_id": 1,
        "participant_id": 53,
        "score": {
          "goals": 3,
          "participant": "home"
        },
        "description": "1ST_HALF"
      },
      {
        "id": 11316769,
        "fixture_id": 18535517,
        "type_id": 1,
        "participant_id": 62,
        "score": {
          "goals": 0,
          "participant": "away"
        },
        "description": "1ST_HALF"
      },
      {
        "id": 11316770,
        "fixture_id": 18535517,
        "type_id": 2,
        "participant_id": 53,
        "score": {
          "goals": 4,
          "participant": "home"
        },
        "description": "2ND_HALF"
      },
      {
        "id": 11316771,
        "fixture_id": 18535517,
        "type_id": 2,
        "participant_id": 62,
        "score": {
          "goals": 0,
          "participant": "away"
        },
        "description": "2ND_HALF"
      },
      {
        "id": 11316772,
        "fixture_id": 18535517,
        "type_id": 1525,
        "participant_id": 53,
        "score": {
          "goals": 4,
          "participant": "home"
        },
        "description": "CURRENT"
      },
      {
        "id": 11316773,
        "fixture_id": 18535517,
        "type_id": 1525,
        "participant_id": 62,
        "score": {
          "goals": 0,
          "participant": "away"
        },
        "description": "CURRENT"
      }
    ],
    "participants": [
      {
        "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",
        "meta": {
          "location": "home",
          "winner": true,
          "position": 1
        }
      },
      {
        "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",
        "meta": {
          "location": "away",
          "winner": false,
          "position": 2
        }
      }
    ],
    "events": [
      {
        "id": 42683644,
        "fixture_id": 18535517,
        "period_id": 4296154,
        "participant_id": 53,
        "type_id": 18,
        "section": "event",
        "player_id": 3298,
        "related_player_id": 10966261,
        "player_name": "Aaron Mooy",
        "related_player_name": "R. Hatate",
        "result": null,
        "info": null,
        "addition": null,
        "minute": 73,
        "extra_minute": null,
        "injured": false,
        "on_bench": false,
        "coach_id": null,
        "sub_type_id": null
      },
  //and more!      

Request: only select a specific field

One of our new additions to API 3.0 is a name field on the fixtures. The name field contains a textual representation of the participants playing the fixture. Without selecting a specific field, the API request and response would look like this:

https://api.sportmonks.com/v3/football/fixtures/18535517?api_token=YOUR_TOKEN
Response

  "data": {
    "id": 18535517,
    "sport_id": 1,
    "league_id": 501,
    "season_id": 19735,
    "stage_id": 77457866,
    "group_id": null,
    "aggregate_id": null,
    "round_id": 274719,
    "state_id": 5,
    "venue_id": 8909,
    "name": "Celtic vs Rangers",
    "starting_at": "2022-09-03 11:30:00",
    "result_info": "Celtic won after full-time.",
    "leg": "1/1",
    "details": null,
    "length": 90,
    "placeholder": false,
    "last_processed_at": "2023-02-17 10:19:55",
    "has_odds": true,
    "starting_at_timestamp": 1662204600
  },

As you can see, the API response is rather large if you're only interested in the fixture's name. Let's select that API field to reduce the response length and size.

We're using the fixtures endpoint. This means we can select on all the fields of the fixtures entity. You can do this by adding &select={specific fields on the base entity}.

In our example, this would result in the below API request and response:

https://api.sportmonks.com/v3/football/fixtures/18535517?api_token=YOUR_TOKEN&select=name
Response
{
  "data": {
    "name": "Celtic vs Rangers",
    "id": 18535517,
    "sport_id": 1,
    "round_id": 274719,
    "stage_id": 77457866,
    "group_id": null,
    "aggregate_id": null,
    "league_id": 501,
    "season_id": 19735,
    "venue_id": 8909,
    "state_id": 5,
    "starting_at_timestamp": null
  },

As you can see in the example response above, the 'name' field is only returned for the fixture.

Please note that the fields that have relations are also automatically included for technical reasons.

Request: filter your request

Next to selecting specific fields on the base entity or includes, it’s possible to filter your request.

Let’s say you want to request all the events of a specific fixture, like Celtic vs Rangers. Your request would look like this:

https://api.sportmonks.com/v3/football/fixtures/18535517?api_token=YOUR_TOKEN&include=events
Response
{
  "data": {
    "id": 18535517,
    "sport_id": 1,
    "league_id": 501,
    "season_id": 19735,
    "stage_id": 77457866,
    "group_id": null,
    "aggregate_id": null,
    "round_id": 274719,
    "state_id": 5,
    "venue_id": 8909,
    "name": "Celtic vs Rangers",
    "starting_at": "2022-09-03 11:30:00",
    "result_info": "Celtic won after full-time.",
    "leg": "1/1",
    "details": null,
    "length": 90,
    "placeholder": false,
    "last_processed_at": "2023-02-17 10:19:55",
    "has_odds": true,
    "starting_at_timestamp": 1662204600,
    "events": [
      {
        "id": 42683644,
        "fixture_id": 18535517,
        "period_id": 4296154,
        "participant_id": 53,
        "type_id": 18,
        "section": "event",
        "player_id": 3298,
        "related_player_id": 10966261,
        "player_name": "Aaron Mooy",
        "related_player_name": "R. Hatate",
        "result": null,
        "info": null,
        "addition": null,
        "minute": 73,
        "extra_minute": null,
        "injured": false,
        "on_bench": false,
        "coach_id": null,
        "sub_type_id": null
      },
      {
        "id": 42683195,
        "fixture_id": 18535517,
        "period_id": 4296154,
        "participant_id": 53,
        "type_id": 18,
        "section": "event",
        "player_id": 319282,
        "related_player_id": 9939171,
        "player_name": "Daizen Maeda",
        "related_player_name": "L. Abada",
        "result": null,
        "info": null,
        "addition": null,
        "minute": 73,
        "extra_minute": null,
        "injured": false,
        "on_bench": false,
        "coach_id": null,
        "sub_type_id": null
      },
 //and more     

As you can see in the response, you will receive all match events. But what if you’re only interested in a specific event like goals, cards or substitutions? You can filter on the specific data you're interested in:

https://api.sportmonks.com/v3/football/fixtures/18535517?api_token=YOUR_TOKEN&include=events&filters=eventTypes:18
Response
{
  "data": {
    "id": 18535517,
    "sport_id": 1,
    "league_id": 501,
    "season_id": 19735,
    "stage_id": 77457866,
    "group_id": null,
    "aggregate_id": null,
    "round_id": 274719,
    "state_id": 5,
    "venue_id": 8909,
    "name": "Celtic vs Rangers",
    "starting_at": "2022-09-03 11:30:00",
    "result_info": "Celtic won after full-time.",
    "leg": "1/1",
    "details": null,
    "length": 90,
    "placeholder": false,
    "last_processed_at": "2023-02-17 10:19:55",
    "has_odds": true,
    "starting_at_timestamp": 1662204600,
    "events": [
      {
        "id": 42683644,
        "fixture_id": 18535517,
        "period_id": 4296154,
        "participant_id": 53,
        "type_id": 18,
        "section": "event",
        "player_id": 3298,
        "related_player_id": 10966261,
        "player_name": "Aaron Mooy",
        "related_player_name": "R. Hatate",
        "result": null,
        "info": null,
        "addition": null,
        "minute": 73,
        "extra_minute": null,
        "injured": false,
        "on_bench": false,
        "coach_id": null,
        "sub_type_id": null
      },
      {
        "id": 42683195,
        "fixture_id": 18535517,
        "period_id": 4296154,
        "participant_id": 53,
        "type_id": 18,
        "section": "event",
        "player_id": 319282,
        "related_player_id": 9939171,
        "player_name": "Daizen Maeda",
        "related_player_name": "L. Abada",
        "result": null,
        "info": null,
        "addition": null,
        "minute": 73,
        "extra_minute": null,
        "injured": false,
        "on_bench": false,
        "coach_id": null,
        "sub_type_id": null
      },

There are a lot more variations available. More information about your options to enrich your request can be found in our request options section.

Alright, we have now discussed a lot of important information about the API and how to make requests to the ‘All fixtures’ endpoint. Let's continue with how to set your timezone.

Last updated