Syntax and relations
How to know what syntax to use? And how can you add additional information about participants (players, coaches, teams etc.)? Itโs essential to check the API response to see which model is returned.
Two of the most overlooked nested includes are:
players.player
โ Can be used to include player details on various endpoints.
teams.team
โ Can be used to include team details on various endpoints.
Check the exact relation of the requested entities to determine the syntax.
Player transfers
Letโs say youโre interested in the players from a specific team with all the historical transfers of the player. You can use the Team by ID endpoint with the players
include:
https://api.sportmonks.com/v3/football/teams/{ID}?api_token=YOUR_TOKEN&include=players
This request returns a list of player IDs with start and end dates but not the player record. Therefore if you use the players.transfer
include, you will only receive the transfer that led the player to the requested team.
If youโre interested in all transfers, you must include the player model first. You can do this by adding the nested include .player
:
https://api.sportmonks.com/v3/football/teams/{ID}?api_token=YOUR_TOKEN&include=players.player
Now you can add the transfers include for all the playerโs historical transfers.
https://api.sportmonks.com/v3/football/teams/{ID}?api_token=YOUR_TOKEN&include=players.player.transfers
Last updated