Selecting and filtering

Thanks to the API flexibility, you can select specific fields and filter simultaneously!

Letโ€™s continue with our events example from the last section: we want all the goal and substitution events:

https://api.sportmonks.com/v3/football/fixtures/18535517?api_token=YOUR_TOKEN&include=events.type&filters=eventTypes:18,14

This time weโ€™ve used the include events.type to have the name of the event type included in the response. More information about this can be found in our nested include tutorial.

Now, the events include contains a lot of information weโ€™re not interested in. Frankly, weโ€™re only interested in the name of the players related to the event and the minute the event occurred. As youโ€™ve learnt, we can select all the fields on the base entity.

In our example, the events entity. We need the โ€œplayer_nameโ€, โ€œrelated_player_nameโ€ and โ€œminuteโ€ field. This results in the following steps:

  1. Add the include: &include=events

  2. Determine the fields youโ€™re interested in: โ€œplayer_nameโ€, โ€œrelated_player_nameโ€ and โ€œminuteโ€ field.

  3. Select the fields: &include=events:player_name,related_player_name,minute

The above steps result in the following request:

https://api.sportmonks.com/v3/football/fixtures/18535517?api_token=YOUR_TOKEN&include=events:player_name,related_player_name,minute

Now, add the filter from the previous filter request: &filters=eventTypes:18,14

https://api.sportmonks.com/v3/football/fixtures/18535517?api_token=YOUR_TOKEN&include=events:player_name,related_player_name,minute&filters=eventTypes:18,14
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,
        "type_id": 18,
        "sub_type_id": null,
        "fixture_id": 18535517,
        "player_id": 3298,
        "related_player_id": 10966261,
        "period_id": 4296154,
        "participant_id": 53,
        "player_name": "Aaron Mooy",
        "related_player_name": "R. Hatate",
        "minute": 73
      },
      {
        "id": 42683195,
        "type_id": 18,
        "sub_type_id": null,
        "fixture_id": 18535517,
        "player_id": 319282,
        "related_player_id": 9939171,
        "period_id": 4296154,
        "participant_id": 53,
        "player_name": "Daizen Maeda",
        "related_player_name": "L. Abada",
        "minute": 73
      },
 //And more 

Please note that if you also want the name of the event type you need to add the events.type include as well.

https://api.sportmonks.com/v3/football/fixtures/18535517?api_token=YOUR_TOKEN&include=events:player_name,related_player_name,minute;event.type&filters=eventTypes:18,14

Last updated