How-to build a match page with odds

Welcome to the how-to guide about building a match page with odds. For example, what are the odds that Real Madrid will win against Bayern Munich in the Champions League? If Real Madrid has a numerical value of 2.5, while Bayern has 2, and a draw would be 1.5, then the match’s most probable outcome would be a draw. This is due to the draw being the lowest numerical odds value. In this how-to guide, we’ll walk you through the steps of creating a match page that displays pre-match and live odds. There is also a continuation guide called how-to build a betting odds portal. There we will compare different bookmakers with each other.

Step 1: Gather the tools

You will once again be needing:

  • SportMonks API token

  • A Code editor (Visual studio used in examples)

  • Postman (optional)

You can find a link to another article where we discuss the tools in-depth here.

Step 2: Decide which market and bookmaker you want to use

There are thousands of different markets, such as 3-way results, home/away, first card received, and Asian handicap.

Besides choosing an appropriate market, you also have to choose between various bookmakers, such as 10bet, bet365, 188bet, and many more.

For a full overview of all the markets and bookmakers we offer, use these two endpoints:

Request markets
Request bookmakers
Request markets
https://soccer.sportmonks.com/api/v2.0/markets?api_token={API_TOKEN}
Request bookmakers
https://soccer.sportmonks.com/api/v2.0/bookmakers?api_token={API_TOKEN}

The most used market is 3-way results. The 3-way result means that there are three possible outcomes: Home team wins (label 1), draw (label X), and visitor team wins (label 2).

Step 3: Choose the correct endpoint

SportMonks provides four different odds endpoints:

However, many users prefer to request pre-match odds with the fixture by id endpoint and then include flatOdds. This request allows the user to filter on the parameters 'bookmakers' and 'markets' at the same time, rather than only being able to choose either bookmaker or market.

For live odds, we only offer all the markets from bet365. Therefore, the bookmaker and market have already been pre-defined with bookmaker id = 2. For live odds, you can use our inplay odds by fixture id endpoint, or use the inplayOdds include our livescore/now endpoint. So the example URLs will be:

Request pre-match odds
Request Live odds
Request pre-match odds
https://soccer.sportmonks.com/api/v2.0/fixtures/{ID}?api_token={API_TOKEN}&include=flatOdds&markets=1&bookmakers=2
Request Live odds
https://soccer.sportmonks.com/api/v2.0/odds/inplay/fixture/{ID}/?api_token={API_TOKEN}

Note that we use flatOddshere for pre-match odds, but we also have a different include calledoddsandoddComparisonthat is used for the betting odds portal. For more information regarding odds, see our odds tutorial.

Step 4: Make your request

For this guide, we’ll be requesting the 3-way result market (market id: 1) and bet365 as our bookmaker (bookmaker id: 2).

Let's analyze a Champions League match between Dynamo Kiev vs Barcelona. At the time of writing this match has yet to be played so it's perfect for an example. Its fixture id is 17361241. We’ll show you both live and pre-match odds:

Request pre-match odds
Request live odds
Request pre-match odds
https://soccer.sportmonks.com/api/v2.0/fixtures/17361241?api_token={API_TOKEN}&include=flatOdds,localTeam,visitorTeam&markets=1&bookmakers=2
Request live odds
https://soccer.sportmonks.com/api/v2.0/odds/inplay/fixture/1736124?api_token={API_TOKEN}&include=localTeam,visitorTeam

These requests will return the live or pre-match odds, as well as the local and visitor teams. We added the includes localTeam,visitorTeam, because we want to have more information about the teams.

Step 5: The API Response

"localTeam": {
"data": {
"id": 556,
"legacy_id": 172,
"name": "Dynamo Kyiv",
"short_code": null,
"twitter": null,
"country_id": 86,
"national_team": false,
"founded": 1927,
"logo_path": "https://cdn.sportmonks.com/images//soccer/teams/12/556.png",
"venue_id": 104,
"current_season_id": 17381
}
},
"visitorTeam": {
"data": {
"id": 83,
"legacy_id": 130,
"name": "Barcelona",
"short_code": "FCB",
"twitter": "@FCBarcelona",
"country_id": 32,
"national_team": false,
"founded": 1899,
"logo_path": "https://cdn.sportmonks.com/images//soccer/teams/19/83.png",
"venue_id": 9236,
"current_season_id": 17480
}
},
"flatOdds": {
"data": [
{
"bookmaker_id": 2,
"bookmaker_event_id": 95198504,
"market_id": 1,
"suspended": false,
"odds": [
{
"label": "1",
"value": "8.00",
"extra": null,
"probability": "12.5%",
"dp3": "8.0000",
"american": 700,
"factional": null,
"handicap": null,
"total": null,
"winning": null,
"stop": false,
"last_update": {
"date": "2020-11-18 16:24:12.069667",
"timezone_type": 3,
"timezone": "UTC"
}
},
{
"label": "X",
"value": "5.00",
"extra": null,
"probability": "20%",
"dp3": "5.0000",
"american": 400,
"factional": null,
"handicap": null,
"total": null,
"winning": null,
"stop": false,
"last_update": {
"date": "2020-11-18 16:24:12.069680",
"timezone_type": 3,
"timezone": "UTC"
}
},
{
"label": "2",
"value": "1.36",
"extra": null,
"probability": "73.37%",
"dp3": "1.3630",
"american": -276,
"factional": null,
"handicap": null,
"total": null,
"winning": null,
"stop": false,
"last_update": {
"date": "2020-11-18 16:24:12.069699",
"timezone_type": 3,
"timezone": "UTC"
}
}

You can see the betting values per possible outcome. As you know, market has three possible outcomes: Home team wins (label 1), draw (label X), and visitor team wins (label 2). The value represents the odds at the time of requesting.

Also, our predictions are included In this match. Barcelona has the highest probability of winning with 73.37%, followed by a draw (20%) and Dynamo Kiev winning (12.5%). More information is available in our predictions tutorial and how-to use the predictions API guide.

inplayOdds will show you the same output format asflatOddsbut will be changed actively throughout the match.

Step 6: Example match pages with odds

Congratulations! You now have all the tools ready to create your own odds page. Have a look at this fantastic website for some inspiration!

In the next how-to guide, we'll be discussing how you can build an odds portal.