How-to use the predictions API

We have discussed how our prediction API works in-depth in our tutorial. In this how-to guide, we’ll show you how to implement the predictions of the Champions League group stage. Our prediction API is based on the latest machine learning techniques, which will give you the best predictions possible.

We’ll only be discussing probabilities per match. For the value bet and player contribution models, you can refer to our prediction tutorial.

Step 1: Make our request

First some general information about the Champions League:

  • League id: 2

  • Current season id: 17299

  • Current stage (Group stage) id: 77448760

  • Current round id: 211704

At the time of writing, the Champions League is in its third round of the group stages. The dates are from 2020-11-03 to 2020-11-04

We use the following URL:

Request
Response
Request
https://soccer.sportmonks.com/api/v2.0/fixtures/between/2020-11-03/2020-11-04?api_token={API_TOKEN}&include=localTeam,visitorTeam&leagues=2
Response
"data": [
{
"id": 17361016,
"league_id": 2,
"season_id": 17299,
"stage_id": 77448760,
"round_id": 211704,
"group_id": 244365,
"aggregate_id": null,
"venue_id": 177923,
"referee_id": 16994,
"localteam_id": 490,
"visitorteam_id": 7980,
"winner_team_id": null,
"weather_report": {
"code": "clouds",
"type": "overcast clouds",
"icon": "https://cdn.sportmonks.com/images/weather/04n.png",
"temperature": {
"temp": 45.77,
"unit": "fahrenheit"
},
"temperature_celcius": {
"temp": 7.7,
"unit": "celcius"
},
"clouds": "90%",
"humidity": "100%",
"pressure": 1026,
"wind": {
"speed": "8.95 m/s",
"degree": 170
},
"coordinates": {
"lat": 55.75,
"lon": 37.62
},
"updated_at": "2020-11-03T19:45:07.664160Z"
},
"commentaries": true,
"attendance": 8147,
"pitch": null,
"details": null,
"neutral_venue": false,
"winning_odds_calculated": true,
"formations": {
"localteam_formation": "4-4-2",
"visitorteam_formation": "4-3-2-1"
},
"scores": {
"localteam_score": 1,
"visitorteam_score": 1,
"localteam_pen_score": null,
"visitorteam_pen_score": null,
"ht_score": "1-1",
"ft_score": "1-1",
"et_score": null,
"ps_score": null
},
"time": {
"status": "FT",
"starting_at": {
"date_time": "2020-11-03 17:55:00",
"date": "2020-11-03",
"time": "17:55:00",
"timestamp": 1604426100,
"timezone": "UTC"
},
"minute": 94,
"second": null,
"added_time": null,
"extra_minute": null,
"injury_time": null
},
"coaches": {
"localteam_coach_id": 1068613,
"visitorteam_coach_id": 452946
},
"standings": {
"localteam_position": 4,
"visitorteam_position": 2
},
"assistants": {
"first_assistant_id": 12172,
"second_assistant_id": 12128,
"fourth_official_id": 15839
},
"leg": "1/1",
"colors": {
"localteam": {
"color": "#F0F0F0",
"kit_colors": "#F0F0F0,#F0F0F0,#F0F0F0,#F0F0F0,#C40010,#0046A8,#F0F0F0"
},
"visitorteam": {
"color": "#002B87",
"kit_colors": "#002B87,#002B87,#002B87,#002B87,#C40010,#0046A8,#002B87"
}
},
"deleted": false,
"localTeam": {
"data": {
"id": 490,
"legacy_id": 501,
"name": "Lokomotiv Moskva",
"short_code": null,
"twitter": null,
"country_id": 227,
"national_team": false,
"founded": 1923,
"logo_path": "https://cdn.sportmonks.com/images//soccer/teams/10/490.png",
"venue_id": 177923,
"current_season_id": 17288
}
},
"visitorTeam": {
"data": {
"id": 7980,
"legacy_id": 113,
"name": "Atlético Madrid",
"short_code": "ATM",
"twitter": "@Atleti",
"country_id": 32,
"national_team": false,
"founded": 1903,
"logo_path": "https://cdn.sportmonks.com/images//soccer/teams/12/7980.png",
"venue_id": 140808,
"current_season_id": 17480
}
}
},
{
"id": 17361028,
"league_id": 2,
"season_id": 17299,
"stage_id": 77448760,
"round_id": 211704,
"group_id": 244366,
"aggregate_id": null,
"venue_id": 8829,
"referee_id": 17308,
"localteam_id": 621,
"visitorteam_id": 683,
"winner_team_id": 683,
"weather_report": {
"code": "clouds",
"type": "overcast clouds",
"icon": "https://cdn.sportmonks.com/images/weather/04n.png",
"temperature": {
"temp": 48.11,
"unit": "fahrenheit"
},
"temperature_celcius": {
"temp": 9,
"unit": "celcius"
},
"clouds": "90%",
"humidity": "87%",
"pressure": 1025,
"wind": {
"speed": "6.71 m/s",
"degree": 80
},
"coordinates": {
"lat": 50,
"lon": 36.25
},
"updated_at": "2020-11-03T19:30:32.966719Z"
},
"commentaries": true,
"attendance": null,
"pitch": null,
"details": null,
"neutral_venue": false,
"winning_odds_calculated": true,
"formations": {
"localteam_formation": "4-1-4-1",
"visitorteam_formation": "4-2-3-1"
},
"scores": {
"localteam_score": 0,
"visitorteam_score": 6,
"localteam_pen_score": null,
"visitorteam_pen_score": null,
"ht_score": "0-4",
"ft_score": "0-6",
"et_score": null,
"ps_score": null
},
"time": {
"status": "FT",
"starting_at": {
"date_time": "2020-11-03 17:55:00",
"date": "2020-11-03",
"time": "17:55:00",
"timestamp": 1604426100,
"timezone": "UTC"
},
"minute": 93,
"second": null,
"added_time": null,
"extra_minute": null,
"injury_time": null
},
"coaches": {
"localteam_coach_id": 464141,
"visitorteam_coach_id": 29710
},
"standings": {
"localteam_position": 1,
"visitorteam_position": 2
},
"assistants": {
"first_assistant_id": 11658,
"second_assistant_id": 12150,
"fourth_official_id": 15834
},
"leg": "1/1",
"colors": {
"localteam": {
"color": "#FC7E00",
"kit_colors": "#D94B14,#FC7E00,#D94B14,#D94B14,#C40010,#0046A8,#0A0A0A"
},
"visitorteam": {
"color": "#F0F0F0",
"kit_colors": "#F0F0F0,#F0F0F0,#F0F0F0,#F0F0F0,#0A0A0A,#FFDF1B,#F0F0F0"
}
},
"deleted": false,
"localTeam": {
"data": {
"id": 621,
"legacy_id": 137,
"name": "Shakhtar Donetsk",
"short_code": "SHK",
"twitter": null,
"country_id": 86,
"national_team": false,
"founded": 1936,
"logo_path": "https://cdn.sportmonks.com/images//soccer/teams/13/621.png",
"venue_id": 8829,
"current_season_id": 17381
}
},
"visitorTeam": {
"data": {
"id": 683,
"legacy_id": 41,
"name": "Borussia M'gladbach",
"short_code": "BMG",
"twitter": "@borussia",
"country_id": 11,
"national_team": false,
"founded": 1900,
"logo_path": "https://cdn.sportmonks.com/images//soccer/teams/11/683.png",
"venue_id": 180,
"current_season_id": 17361

This URL requests all the Champion League matches of the third round of the group stages. Now that you have an overview of all the Champion League fixture ids, we can start implementing our Prediction API.

Remember the two endpoints?

See our tutorial again for a refresher, in case you forgot. You have multiple options. Including the options to either use the probabilities by fixture id endpoint or to use the fixtures between dates endpoint with probability as include. We’ll analyze the following match between Real Madrid and Inter with fixture id #17361029.

Request 1
Request 2
Request 1
https://soccer.sportmonks.com/api/v2.0/predictions/probabilities/fixture/17361029/?api_token={API_TOKEN}
Request 2
https://soccer.sportmonks.com/api/v2.0/fixtures/between/2020-11-03/2020-11-04?api_token={API_TOKEN}&include=localTeam,visitorTeam,probability&leagues=2

Step 2: The API response

"fixture_id": 17361029,
"predictions": {
"btts": 63.087,
"over_2_5": 61.667,
"under_2_5": 38.33,
"over_3_5": 39.384,
"under_3_5": 60.614,
"HT_over_0_5": 82.125,
"HT_under_0_5": 17.872,
"HT_over_1_5": 51.346,
"HT_under_1_5": 48.651,
"AT_over_0_5": 76.818,
"AT_under_0_5": 23.18,
"AT_over_1_5": 42.932,
"AT_under_1_5": 57.066,
"home": 43.903,
"away": 32.803,
"draw": 23.29,
"correct_score": {
"0-0": 4.143,
"0-1": 6.057,
"0-2": 4.427,
"0-3": 2.157,
"0-4": 0.788,
"0-5": 0.231,
"0-6": 0.056,
"0-7": 0.012,
"0-8": 0.002,
"1-0": 7.134,
"1-1": 10.42,
"1-2": 7.623,
"1-3": 3.715,
"1-4": 1.358,
"1-5": 0.397,
"1-6": 0.097,
"1-7": 0.02,
"1-8": 0.004,
"1-9": 0.001,
"2-0": 6.141,
"2-1": 8.978,
"2-2": 6.563,
"2-3": 3.198,
"2-4": 1.169,
"2-5": 0.342,
"2-6": 0.083,
"2-7": 0.017,
"2-8": 0.003,
"2-9": 0.001,
"3-0": 3.525,
"3-1": 5.153,
"3-2": 3.767,
"3-3": 1.836,
"3-4": 0.671,
"3-5": 0.196,
"3-6": 0.048,
"3-7": 0.01,
"3-8": 0.002,
"4-0": 1.517,
"4-1": 2.218,
"4-2": 1.621,
"4-3": 0.79,
"4-4": 0.289,
"4-5": 0.084,
"4-6": 0.021,
"4-7": 0.004,
"4-8": 0.001,
"5-0": 0.523,
"5-1": 0.764,
"5-2": 0.558,
"5-3": 0.272,
"5-4": 0.099,
"5-5": 0.029,
"5-6": 0.007,
"5-7": 0.001,
"6-0": 0.15,
"6-1": 0.219,
"6-2": 0.16,
"6-3": 0.078,
"6-4": 0.029,
"6-5": 0.008,
"6-6": 0.002,
"7-0": 0.037,
"7-1": 0.054,
"7-2": 0.039,
"7-3": 0.019,
"7-4": 0.007,
"7-5": 0.002,
"7-6": 0.001,
"8-0": 0.008,
"8-1": 0.012,
"8-2": 0.008,
"8-3": 0.004,
"8-4": 0.002,
"9-0": 0.002,
"9-1": 0.002,
"9-2": 0.002,
"9-3": 0.001
}
}

Summary of the data:

BTTS (Both teams to score) = 63.01% Over 2,5 goals scored = 61.67% Under 3,5 goals scored = 60.14% Home team (Real Madrid) over 0,5 goals scored = 82,13% Away team (Inter) over 0,5 goals scored = 76.82% Real Madrid win probability = 43.90% Inter win probability = 32.80% Draw probability = 23.29% A final score of 1-1 has the highest probability = 10.42% If you used the probabilities by fixture id endpoint you will have to repeat this step for all the other Champion League matches.

But, if you used the probability include on one of our fixtures or livescores endpoints, you won’t have to.

Predictions are updated multiple times a day. Take this into account when you start implementing.

Step 3: Example Page

Need some inspiration? The website below shows how you can display the various market predictions for one specific match.

Conclusion

Our prediction API uses cutting edge technology and has been developed by SportMonks’ very own data scientists and development team. If you’re interested in the technology behind our predictions you can have a look at our prediction API blog.