Syntax and filters

Syntax

The syntax for filtering and including works differently from API V2. The syntax is used across all endpoints: the documentation for each endpoint describes the exceptions regarding exclusions of some fields/relations. Find out everything about the new syntax.

Filters

The filter system changed compared to the previous version. You can now select specific fields on the base entity or includes and it’s possible to filter your request. Below is a fixture shown with events.

Example Fixture with Events
// URL
https://api.sportmonks.com/v3/football/fixtures/18535517?api_token=YOUR_TOKEN&include=events
{
  "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-03-02 17:47:38",
    "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
      },
      {
        "id": 42703418,
        "fixture_id": 18535517,
        "period_id": 4296154,
        "participant_id": 62,
        "type_id": 19,
        "section": "event",
        "player_id": 2927,
        "related_player_id": null,
        "player_name": "Connor Goldson",
        "related_player_name": null,
        "result": null,
        "info": "Foul",
        "addition": "6th Yellow Card",
        "minute": 90,
        "extra_minute": null,
        "injured": null,
        "on_bench": false,
        "coach_id": null,
        "sub_type_id": null
      },
      {
        "id": 42688034,
        "fixture_id": 18535517,
        "period_id": 4296154,
        "participant_id": 62,
        "type_id": 18,
        "section": "event",
        "player_id": 1452870,
        "related_player_id": 3387,
        "player_name": "F. Sakala",
        "related_player_name": "Ryan Kent",
        "result": null,
        "info": null,
        "addition": null,
        "minute": 78,
        "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. The URL now includes a &filters query parameter that shows the entity you want to filter on and the ID's you want to see in your results.

Example Fixture with Filtered Goal Events
// URL
https://api.sportmonks.com/v3/football/fixtures/18535517?api_token=YOUR_TOKEN&include=events&filters=eventTypes:14
{
  "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-03-02 17:47:38",
    "has_odds": true,
    "starting_at_timestamp": 1662204600,
    "events": [
      {
        "id": 42688040,
        "fixture_id": 18535517,
        "period_id": 4296154,
        "participant_id": 53,
        "type_id": 14,
        "section": "event",
        "player_id": 173160,
        "related_player_id": null,
        "player_name": "David Turnbull",
        "related_player_name": null,
        "result": "4-0",
        "info": "Shot",
        "addition": "4th Goal",
        "minute": 78,
        "extra_minute": null,
        "injured": null,
        "on_bench": false,
        "coach_id": null,
        "sub_type_id": null
      },
      {
        "id": 42646477,
        "fixture_id": 18535517,
        "period_id": 4295921,
        "participant_id": 53,
        "type_id": 14,
        "section": "event",
        "player_id": 9939171,
        "related_player_id": null,
        "player_name": "L. Abada",
        "related_player_name": null,
        "result": "1-0",
        "info": "Shot",
        "addition": "1st Goal",
        "minute": 8,
        "extra_minute": null,
        "injured": null,
        "on_bench": false,
        "coach_id": null,
        "sub_type_id": null
      },
      //And more

More information and a more detailed explanation is covered on our request options page.

Select the fields you need

You can request only the fields you need by using the new syntax. Filters can filter the data based on the fields you would like to display in your application.

: can be used for filtering the fields you want to see in the response. For example, you only want the name of a certain team. In this case you need to use participants:name.

A more detailed explanation is covered on our request options page

Last updated