Skip to main content

Soccer Odds API in Python: 1X2, Handicaps and Totals

James Whitfield

James Whitfield

•10 min read
Soccer Odds API in Python: 1X2, Handicaps and Totals

A soccer odds API gives you bookmaker prices for football matches as JSON, so your code can read the 1X2, handicap and goal lines without copying them from a website. With Odds-API.io the sport is football. You list fixtures with /v3/events and fetch prices with /v3/odds for one match or /v3/odds/multi for up to 10 matches at a time. Each request takes up to 30 bookmakers, chosen from the 450+ the API covers.

This guide builds a short Python script on those endpoints. It lists the next ten Premier League fixtures. For each one it prints the best 1X2 and over/under 2.5 prices across 14 UK bookmakers, plus the Asian handicap line that most of them quote. A second script uses pandas to compare each bookmaker's margin on one match. Every sample was run against the production API on 27 November 2026, and the output is pasted as it came back. For football coverage, see the football odds API page.

What a soccer odds API returns

The data comes in three layers. Leagues give you the slug for each competition. Events give you the fixtures in a league, with an ID, the two teams, the kick-off time in UTC, the status and the score. Odds give you the prices for one event, grouped by bookmaker and then by market.

Here is a trimmed /v3/odds response for Arsenal v Manchester City, with three of Bet365's 92 markets for that match:

{
  "id": 72221412,
  "home": "Arsenal FC",
  "away": "Manchester City",
  "date": "2026-11-29T16:30:00Z",
  "status": "pending",
  "league": {"name": "England - Premier League", "slug": "england-premier-league"},
  "bookmakers": {
    "Bet365": [
      {"name": "ML", "updatedAt": "2026-11-27T10:31:01.611Z",
       "odds": [{"home": "1.950", "draw": "3.600", "away": "3.800"}]},
      {"name": "Spread", "updatedAt": "2026-11-27T12:18:55.539Z",
       "odds": [{"hdp": -0.75, "home": "2.250", "away": "1.625"},
                {"hdp": -0.5, "home": "1.975", "away": "1.875"},
                {"hdp": -0.25, "home": "1.700", "away": "2.100"}]},
      {"name": "Totals", "updatedAt": "2026-11-27T01:13:45.187Z",
       "odds": [{"hdp": 2.5, "over": "1.725", "under": "2.075"}]}
    ]
  }
}

Prices are decimal odds sent as strings, so convert them with float(). The 1X2 market is called ML, the Asian handicap is Spread and over/under goals is Totals. hdp carries the line: the goal line for totals, and the home team's handicap for the spread.

We also asked for that one match from all 405 bookmakers selected on our test key, 30 names per request. 398 of them returned prices. 394 of them had a 1X2 price, 378 had totals, 311 had both teams to score and 252 had an Asian handicap. Across all of them there were 131 different market names, from double chance and draw no bet to corners, correct score and goalscorer markets. Not every bookmaker offers every market, so always check which ones came back.

Find league slugs and fixtures

Every football competition has a slug. Fetch the list once and keep the ones you need:

curl --compressed "https://api.odds-api.io/v3/leagues?apiKey=$ODDS_API_KEY&sport=football"

The count changes from day to day: 691 football leagues on 27 November, 641 on 30 November. Some example slugs:

LeagueSlug
Premier Leagueengland-premier-league
Championshipengland-championship
LaLigaspain-laliga
Bundesligagermany-bundesliga
Serie Aitaly-serie-a
Ligue 1france-ligue-1
Champions Leagueinternational-clubs-uefa-champions-league
Europa Leagueinternational-clubs-uefa-europa-league

Pass the slug to /v3/events with status=pending to get fixtures that have not kicked off yet. The full parameter list for leagues is in the leagues reference.

Get football odds in Python

You need Python 3.8 or later (we tested on 3.15), requests, and an API key in the ODDS_API_KEY environment variable. Plans and limits are on the pricing page.

pip install requests pandas
export ODDS_API_KEY=your_key

Save this as soccer_odds.py:

import math
import os
import sys
from datetime import datetime

import requests

API = "https://api.odds-api.io/v3"
KEY = os.environ.get("ODDS_API_KEY") or sys.exit("Set ODDS_API_KEY first.")
BOOKMAKERS = [
    "Bet365", "William Hill", "Ladbrokes", "Paddy Power", "Skybet", "Betfair Sportsbook",
    "Unibet UK", "Betway", "BoyleSports", "888Sport", "Virgin Bet", "Coral", "BetVictor", "Parimatch UK",
]


def get(path, **params):
    r = requests.get(f"{API}{path}", params={"apiKey": KEY, **params}, timeout=30)
    if r.status_code != 200:
        sys.exit(f"{path} returned HTTP {r.status_code}: {r.text[:200]}")
    return r.json()


def fixtures(league, count=10):
    events = get("/events", sport="football", league=league, status="pending")
    return sorted(events, key=lambda e: e["date"])[:count]


def odds_for(events):
    if not events:
        return []
    ids = ",".join(str(e["id"]) for e in events[:10])
    found = get("/odds/multi", eventIds=ids, bookmakers=",".join(BOOKMAKERS))
    return sorted(found, key=lambda e: e["date"])


def price(value):
    try:
        value = float(value)
    except (TypeError, ValueError):
        return None
    return value if math.isfinite(value) and value > 1 else None


def lines(event, name):
    """Yield (bookmaker, rows) for one market, in BOOKMAKERS order."""
    for book in BOOKMAKERS:
        for m in event["bookmakers"].get(book, []):
            if m["name"] == name and m.get("odds"):
                yield book, m["odds"]


def best(quotes):
    """Highest price per side. On a tie the bookmaker listed first in BOOKMAKERS is kept."""
    out = {}
    for book, side, value in quotes:
        value = price(value)
        if value and value > out.get(side, (0, ""))[0]:
            out[side] = (value, book)
    return out


def show(top, sides):
    return "  ".join(f"{s} {top[s][0]:.2f} {top[s][1]}" for s in sides if s in top)


def report(event):
    kickoff = datetime.fromisoformat(event["date"].replace("Z", "+00:00"))
    print(f'{kickoff:%a %d %b %H:%M} UTC  {event["home"]} v {event["away"]}  (event {event["id"]})')

    ml = list(lines(event, "ML"))
    top = best((book, s, rows[0].get(s)) for book, rows in ml for s in ("home", "draw", "away"))
    if top:
        print(f"  1X2      {show(top, ('home', 'draw', 'away'))}  ({len(ml)} books)")
    if len(top) == 3:
        print(f"           overround at best prices {sum(1 / p for p, _ in top.values()) - 1:+.1%}")

    totals = best((book, s, row.get(s)) for book, rows in lines(event, "Totals")
                  for row in rows if row.get("hdp") == 2.5 for s in ("over", "under"))
    if totals:
        print(f"  O/U 2.5  {show(totals, ('over', 'under'))}")

    by_line = {}
    for book, rows in lines(event, "Spread"):
        for row in rows:
            if isinstance(row.get("hdp"), (int, float)) and price(row.get("home")) and price(row.get("away")):
                by_line.setdefault(row["hdp"], {})[book] = row
    if by_line:
        hdp = max(by_line, key=lambda h: (len(by_line[h]), -abs(h)))
        books = by_line[hdp]
        ah = best((book, s, row.get(s)) for book, row in books.items() for s in ("home", "away"))
        print(f"  AH {hdp:+g}  {show(ah, ('home', 'away'))}  ({len(books)} books quote this line)")


if __name__ == "__main__":
    league = sys.argv[1] if len(sys.argv) > 1 else "england-premier-league"
    for event in odds_for(fixtures(league)):
        report(event)
        print()

The script makes two requests. fixtures() fetches the pending events for the league and keeps the next ten by kick-off time. odds_for() sends those ten IDs to /v3/odds/multi with the bookmaker list and sorts the result by kick-off. Ten is the most that endpoint accepts in one call. For more fixtures, send them in batches of ten.

lines() walks one event and yields each bookmaker's rows for a market name, in the order of BOOKMAKERS. It only reads the bookmakers you asked for. price() turns the string into a number and drops anything that is not a valid decimal price. best() keeps the highest price per side and the bookmaker that offered it. On a tie, the bookmaker listed first in BOOKMAKERS is kept. get() exits with the HTTP status and the error message from the API, so a wrong league slug prints /events returned HTTP 404: {"error":"League not found"}.

Run it with python soccer_odds.py. This is the output from 27 November, trimmed to five of the ten matches. Kick-off times are UTC, as the API sends them:

Fri 27 Nov 20:00 UTC  Nottingham Forest v Chelsea FC  (event 72221428)
  1X2      home 2.45 Betfair Sportsbook  draw 3.50 Unibet UK  away 3.00 Bet365  (12 books)
           overround at best prices +2.7%
  O/U 2.5  over 1.82 Bet365  under 2.02 Bet365
  AH -0.5  home 2.35 Virgin Bet  away 1.60 Bet365  (4 books quote this line)

Sat 28 Nov 15:00 UTC  Leeds United v Coventry City  (event 72221424)
  1X2      home 1.48 Bet365  draw 4.60 Betfair Sportsbook  away 6.50 Bet365  (14 books)
           overround at best prices +4.7%
  O/U 2.5  over 1.68 Bet365  under 2.20 Paddy Power
  AH -1.5  home 2.30 Bet365  away 1.61 Virgin Bet  (7 books quote this line)

Sat 28 Nov 15:00 UTC  Manchester United v Brentford FC  (event 72221426)
  1X2      home 2.20 Betfair Sportsbook  draw 3.75 Bet365  away 3.25 BoyleSports  (14 books)
           overround at best prices +2.9%
  O/U 2.5  over 1.57 Bet365  under 2.40 Paddy Power
  AH -0.5  home 2.08 Bet365  away 1.74 Virgin Bet  (6 books quote this line)

Sat 28 Nov 17:30 UTC  Ipswich Town v Aston Villa  (event 72221422)
  1X2      home 3.60 Bet365  draw 3.80 William Hill  away 2.00 Ladbrokes  (14 books)
           overround at best prices +4.1%
  O/U 2.5  over 1.57 Bet365  under 2.40 Paddy Power
  AH +0.5  home 1.88 Bet365  away 1.98 Unibet UK  (7 books quote this line)

Sun 29 Nov 12:00 UTC  Everton FC v Liverpool FC  (event 72221418)
  1X2      home 4.60 Betfair Sportsbook  draw 3.90 Bet365  away 1.80 Ladbrokes  (14 books)
           overround at best prices +2.9%
  O/U 2.5  over 1.68 Bet365  under 2.20 Paddy Power
  AH +0.5  home 2.10 Virgin Bet  away 1.75 Ladbrokes  (6 books quote this line)

Pass another slug to run it on a different league, for example python soccer_odds.py spain-laliga.

Reading 1X2, Asian handicap and totals

1X2. The ML market has three prices: home, draw and away. The script prints the best of each across the 14 bookmakers, then the overround at those best prices: the sum of 1 / price for the three outcomes, minus one. For one bookmaker, this overround is what we call its margin in the next section. Taking the best price per outcome from different books lowers the overround. Across the ten fixtures it ranged from +2.7% to +4.7%.

Totals. Each row in Totals is one goal line with an over and an under price. The script filters on hdp == 2.5, a line 11 of the 14 bookmakers quoted for Arsenal v Manchester City. The other three only had a 1X2 price for that match. Change the number to read 1.5 or 3.5 instead.

Asian handicap. Each Spread row is one handicap line. hdp is the home team's handicap, and the away side gets the opposite sign. In the Arsenal v Manchester City response above, -0.5 means Arsenal -0.5 and Manchester City +0.5, so the home price at -0.5 sits close to the plain home win price. Bookmakers also quote quarter lines. A -0.25 handicap splits the stake equally between 0 and -0.5, and -0.75 splits it between -0.5 and -1. Bookmakers do not all quote the same lines, so the script counts how many bookmakers quote each hdp with both prices and prints the line with the most. On a tie it takes the line closest to zero. For settlement examples with quarter lines and pushes, read the Asian handicap API guide.

Compare bookmaker margins with pandas

The best price per outcome is one view. The other is which bookmakers price a match with the lowest margin. This second script reuses the helpers from soccer_odds.py, builds a table of 1X2 prices for one event and works out each bookmaker's margin. Save it as margins.py next to the first file:

import sys

import pandas as pd

from soccer_odds import BOOKMAKERS, get, lines, price

SIDES = ["home", "draw", "away"]

if len(sys.argv) != 2:
    sys.exit("usage: python margins.py <event id>")

event = get("/odds", eventId=sys.argv[1], bookmakers=",".join(BOOKMAKERS))
rows = []
for book, odds in lines(event, "ML"):
    prices = {s: price(odds[0].get(s)) for s in SIDES}
    if all(prices.values()):
        rows.append({"bookmaker": book, **prices})
if not rows:
    sys.exit("No complete 1X2 prices for this event.")

df = pd.DataFrame(rows).set_index("bookmaker")
df["margin"] = (1 / df[SIDES]).sum(axis=1) - 1
fair = df[SIDES].mul(df["margin"] + 1, axis=0)

print(f'{event["home"]} v {event["away"]}')
print(df.sort_values("margin").to_string(float_format="{:.3f}".format))
print("\nmedian fair odds:", fair.median().round(2).to_dict())

Run it with an event ID from the first script's output:

$ python margins.py 72221412
Arsenal FC v Manchester City
                    home  draw  away  margin
bookmaker                                   
BoyleSports        1.952 3.750 3.750   0.046
Betfair Sportsbook 1.950 3.700 3.750   0.050
Coral              2.000 3.750 3.500   0.052
Bet365             1.950 3.600 3.800   0.054
Unibet UK          2.000 3.600 3.600   0.056
Paddy Power        1.950 3.600 3.700   0.061
Skybet             1.950 3.600 3.600   0.068
Ladbrokes          1.950 3.700 3.500   0.069
William Hill       1.950 3.600 3.500   0.076
Betway             1.950 3.600 3.500   0.076
888Sport           1.950 3.600 3.500   0.076
BetVictor          1.950 3.600 3.500   0.076
Parimatch UK       1.950 3.600 3.500   0.076
Virgin Bet         1.860 3.750 3.600   0.082

median fair odds: {'home': 2.09, 'draw': 3.87, 'away': 3.78}

The margin column is the same sum of 1 / price minus one, per bookmaker. On this match it runs from 4.6% to 8.2%. The fair odds remove the margin by scaling the three implied probabilities down by the same factor until they add up to 100%. Scaling every outcome equally is an assumption, and other methods weight the favourite and the outsider differently. The median per outcome across the 14 books gives one reference price for each. Medians are taken per column, so their implied probabilities need not add up to exactly 100%. Here they come to 100.1%. Our backtesting tutorial uses the same proportional approach on closing odds, and comparing odds across bookmakers covers the request side in more depth.

Live soccer odds

The same endpoints serve matches in play. Ask /v3/events for status=live and you get the matches under way, with the current score and the score per half. When we checked on a Friday afternoon, 52 football matches were live. Pass their IDs to /v3/odds/multi in batches of ten, as above.

Polling costs one request per batch of ten matches each time you refresh. The WebSocket feed works the other way: it pushes price changes to you as they arrive. Live Odds API in Node.js builds a WebSocket tracker for one football league, and the live odds API page explains the options.

Historical football odds

Past matches come from the historical endpoints. For a Premier League match on 1 November 2026, /v3/historical/odds returned the final score with each half, and a Bet365 1X2 price last updated about eight seconds before kick-off. The Premier League historical odds page lists what is available for that league, and the Oddsportal alternative tutorial pulls a season of football closing odds into Python.

Limits and errors

These came up while testing the samples:

  • /v3/odds/multi takes up to 10 event IDs. An eleventh returns HTTP 400 with Maximum 10 eventIds allowed.
  • /v3/odds and /v3/odds/multi take up to 30 bookmakers per request. A 31st returns HTTP 400 with Maximum 30 bookmakers allowed. For more, split the list and merge the results.
  • Bookmaker names are case-sensitive. bet365 returns HTTP 400, Bet365 works. Copy names from /v3/bookmakers or the sportsbooks list.
  • Odds responses carry x-ratelimit-limit, x-ratelimit-remaining and x-ratelimit-reset headers. Read them before a batch job.
  • Not every bookmaker prices every market. Check for the market before you read it, as lines() does.

FAQ

Is a soccer odds API the same as a football odds API?

Yes. Both names describe the same data. In Odds-API.io the sport slug is football, and the events, markets and responses are the same whichever word you use.

How many bookmakers price a Premier League match?

It varies by match. For Arsenal v Manchester City on 27 November 2026, we asked for all 405 bookmakers selected on our test key in batches of 30. 398 returned prices and 394 of them had a 1X2 price. We counted only the bookmakers we requested. Each response lists the bookmakers that priced the match among the ones you asked for.

Which soccer markets can I get from the API?

1X2 (ML), over/under goals (Totals), Asian handicap (Spread), both teams to score (yes, no), double chance (1X, 12, X2), draw no bet, European handicap, correct score, corners, bookings and player markets such as anytime goalscorer. The full list of football market names is on the football markets page.

Can I get odds for one bookmaker only?

Yes. Pass a single name in bookmakers, for example bookmakers=Bet365, or use a one-item BOOKMAKERS list in the script. Read only the names you asked for from the response, as lines() does.

Do I need pandas?

No. soccer_odds.py uses only requests. pandas is used in margins.py because a table of prices per bookmaker is easier to sort and summarise as a DataFrame.

Get live and pre-match odds from 500+ bookmakers

OddsNotifier and OddsHub run on the same real-time feed you get with the API.

See what's built with Odds API →