oddsrelay
The OddsRelay Python client. One method for each data, lookup and historical route of the OddsRelay API, which serves bookmaker odds for the UK & Ireland and 20 more regions as JSON: raw prices in every region, and UK and Irish bookmakers matched to exchange lay prices. Standard library only, Python 3.9 and up.
Install
pip install oddsrelay
Get a key
Sign up at app.oddsrelay.io/signup and copy your key from the dashboard. Free gives you 50,000 tokens for 14 days from sign-up, with no card, then no tokens until you choose a plan, on the same key. Plans and token prices. Paid plans are for personal use. Any business, even one using the data only in-house, and any product that serves other people runs on Enterprise; a business can try the data on Free first.
First call
Put your key in your environment, never in your code:
export ODDSRELAY_KEY="your key"
from oddsrelay import OddsRelay
client = OddsRelay() # reads ODDSRELAY_KEY
result = client.odds("standard", region="uk", sports="soccer", markets="h2h") # soccer is the API's key for football
for event in result.data["data"]:
teams = f"{event['home_team']} v {event['away_team']}" if event.get("home_team") else event.get("event_name")
print(event["commence_time"], teams)
print(result.tokens) # what the call cost and what is left
No key yet? These routes answer without one:
client = OddsRelay()
print(client.status().data)
print(client.coverage(region="uk").data["products"].keys())
Regions
Raw prices, in-play prices, event states and historical odds come from every region regions() lists. raw() takes
one code, or several international codes in one call (uk is always asked alone). Every other method takes one code.
page = client.raw(region="us", sports="basketball")
both = client.raw(region="us,global", sports="basketball") # one board, priced as the two together
live = client.raw(region="us", sports="basketball", in_play="only") # prices on events in play
- The matched boards and the exchanges are served for
ukonly: elsewhereodds()raisesPermissionDeniedErrorwith codeproduct_not_in_region. - A call with no
regionreadsukwhen that is your account's home region. With another home region it raisesBadRequestErrorwith coderegion_required: passregion=.
Methods
| Method | Route | What it returns |
|---|---|---|
odds(type, **filters) |
GET /v2/odds/{type} |
Matched odds for one board type: standard, 2up, dutching, each-way, extra-place or bog |
raw(**filters) |
GET /v2/odds/raw |
Bookmaker and exchange prices by event, unpaired, a page at a time |
event(id, **filters) |
GET /v2/odds/event/{id} |
One event's raw prices |
sports(**filters) |
GET /v2/sports |
Sport and competition keys |
events(sport, **filters) |
GET /v2/events |
Upcoming events for one sport key |
events_state(**filters) |
GET /v2/events/state |
Each event's state in one region: scheduled, started, gone or merged (no tokens) |
events_changes(since, **filters) |
GET /v2/events/changes |
The state changes after since, in order (no tokens) |
bookmakers(**filters) |
GET /v2/bookmakers |
The venues you can filter on, with their keys |
regions() |
GET /v2/regions |
The region codes open to your key |
coverage(**filters) |
GET /v2/coverage |
Which venues and sports each product carries (keyless; more detail with a key) |
status(**filters) |
GET /v2/status |
Whether each product is serving (keyless) |
health() |
GET /v2/health |
When each board was last processed, and whether any is behind |
usage() |
GET /v2/usage |
Tokens used and left, and what your key may read |
pricing() |
GET /v2/pricing |
The token rate card |
openapi() |
GET /v2/openapi.json |
The API description (keyless) |
healthz() |
GET /healthz |
A plain-text liveness check (keyless) |
history_raw(date, sports, **filters) |
GET /v2/historical/odds/raw |
The raw board as it stood at one moment |
history_event(id, from_, **filters) |
GET /v2/historical/events/{id}/odds |
One event's price changes over a window of up to 24 hours |
closing(date, sports, **filters) |
GET /v2/historical/closing |
Opening and closing prices of the events that started on one UTC day |
history_files(**filters) |
GET /v2/historical/files |
The bulk day files, with each one's size and cost |
download_file(tier, sport, file, **filters) |
GET /v2/historical/files/{tier}/{sport}/{file} |
One bulk file, as bytes |
Each method returns a Result. result.data is the decoded body, with every field kept, including fields the API
adds after this release.
Filters
Every query parameter in the API reference is a keyword argument. Python's
snake_case and the API's camelCase both work, so odds_format="decimal" and oddsFormat="decimal" send the same
thing. Lists become comma-separated values, True and False become true and false, a datetime becomes a UTC
timestamp, and None is left out:
from datetime import datetime, timedelta, timezone
now = datetime.now(timezone.utc)
result = client.odds(
"each-way",
region="uk",
sports=["horse_racing"],
commence_time_from=now,
commence_time_to=now + timedelta(hours=6),
)
The API checks every filter itself: an unknown name or value raises BadRequestError, and where the API lists the
accepted values, error.get("valid") holds them.
Historical odds
board = client.history_raw("2026-11-17T18:00:00Z", "basketball", region="us", max_tokens=cap)
moves = client.history_event(event_id, "2026-11-17T12:00:00Z", region="us") # 24 hours from there, or pass to=
lines = client.closing("2026-11-17", "basketball", region="us")
for item in client.history_files(region="uk").data["data"]:
print(item["name"], item["size"], item["cost"])
packed = client.download_file("closing", "soccer", "2026-11-17.csv.gz", max_tokens=cap)
with open("2026-11-17.csv.gz", "wb") as out:
out.write(packed.data) # a gzip CSV, saved as sent
Each region has its own archive with its own first day. A date before it raises BadRequestError with code
date_out_of_range, and exc.error["earliest"] and exc.error["latest"] give the range that region holds. Outside
uk the archive holds bookmakers only. A file is charged in full when its download starts; quote=True or
max_tokens prices it first.
Event states
events_state() is a snapshot of every event's state in one region, and events_changes() follows it. Neither
spends tokens.
snapshot = client.events_state(region="us", sports="basketball")
since = snapshot.data["meta"]["since"] # from the first page
while True:
log = client.events_changes(since, region="us", sports="basketball") # the same filters as the snapshot
for change in log.data["data"]:
rows[change["event"]["id"]] = change["event"]
since = log.data["meta"]["next_since"]
if not log.data["meta"]["more"]:
time.sleep(poll_seconds)
If since is too old the API answers 410 with code since_expired (an APIError): take a new snapshot.
Price a call before you make it
quote=True asks what a call would cost instead of making it. A quote spends no tokens:
quote = client.odds("standard", region="uk", quote=True)
print(quote.data["cost"], quote.data["remaining"])
Or let the client do it. With max_tokens, odds(), raw(), event() and the priced history methods quote first and raise QuoteTooHigh,
without making the call, when the cost is above your cap:
from oddsrelay import QuoteTooHigh
try:
result = client.raw(region="uk", sports="tennis", max_tokens=cap) # cap: the most you will spend on this call
except QuoteTooHigh as exc:
print(f"this call costs {exc.cost} tokens: add filters to narrow it")
Polling: spend tokens only on changes
The client keeps the ETag of each URL it has fetched and sends it back as If-None-Match. When nothing has changed
the API answers 304, which spends no tokens, and you get a NotModified result whose data is the body you already
have:
import time
while True:
result = client.odds("standard", region="uk", sports="soccer")
if not result.not_modified:
update_my_screen(result.data)
time.sleep(poll_seconds)
NotModified is a subclass of Result, so code that reads result.data works either way.
Paging
raw(), sports(), events(), events_state() and the history methods return a page at a time. Pass the next page's cursor back as cursor:
cursor = None
while True:
page = client.raw(region="uk", sports="tennis", cursor=cursor)
handle(page.data["data"])
cursor = page.data["meta"].get("next_cursor")
if not cursor:
break
Errors
A reply the API refuses raises an APIError subclass with status, code, message, request_id and error (the
whole error object). APIError and QuoteTooHigh are both OddsRelayErrors. Network failures are not wrapped: a
refused connection or a timeout raises the standard library's OSError (such as urllib.error.URLError), so a
long-running loop catches (OddsRelayError, OSError).
| Status | Exception |
|---|---|
| 400 | BadRequestError |
| 401 | AuthenticationError |
| 402 | InsufficientTokensError, with cost, remaining and resets_at |
| 403 | PermissionDeniedError |
| 410 | APIError, code since_expired |
| 404 | NotFoundError |
| 429 | RateLimitError, with retry_after, once the client's own retries are used up |
| 5xx | ServerError |
Branch on exc.code, never on the message, which may change. Quote request_id when you contact us.
from oddsrelay import InsufficientTokensError
try:
result = client.odds("dutching", region="uk")
except InsufficientTokensError as exc:
print(f"needs {exc.cost} tokens, {exc.remaining} left until {exc.resets_at}")
A 429 is retried for you: the client waits the Retry-After seconds and tries again, three requests in all. Pass
your own sleep= to OddsRelay() to change how it waits.
Tokens and rate limits
Every Result, and every APIError, carries the reply's headers:
tokens:cost,used,remaining,limitandreset, from theX-Tokens-*headersrate_limit:limit,remainingandreset, from theX-RateLimit-*headersheaders,etagandrequest_id
A header the reply did not carry reads as None.
Your key
The key travels only in the Authorization header. The client never puts it in a URL, a log line, a repr or an
exception message, and it is not forwarded if a reply ever redirects. Spaces and newlines around the key, common when
it is read from a file, are dropped.
Versions
oddsrelay.CONTRACT_VERSION names the version of the API description these methods follow. The API only adds to
/v2, so new fields and new error codes reach you without an upgrade.
More from OddsRelay
- oddsrelay-js: the JavaScript and TypeScript client,
npm install oddsrelay - oddsrelay-r: the R client
- oddsrelay-mcp: an MCP server that gives Claude, Cursor and other AI assistants read access, with a token cap
- oddsrelay-sheets: formulas and a template spreadsheet for Google Sheets
- examples: short programs to copy, one folder each
- Libraries and tools, the docs, the API reference and the OpenAPI file
- Contact: hello@oddsrelay.io
Licence
MIT. See LICENSE.
Metadata
Release files for oddsrelay 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| oddsrelay-0.2.0.tar.gz | 26.5 kB | With provenance | Details for oddsrelay-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| oddsrelay-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for oddsrelay-0.2.0-py3-none-any.whl |
Total release size: 39.1 kB
Release files / oddsrelay-0.2.0.tar.gz
| Download URL | oddsrelay-0.2.0.tar.gz |
|---|---|
| Size | 26.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a634f3bd20ff63effbaec259bbed7fc60fffd46607aa9c578bb2dd1b936d67c8
|
|
BLAKE2b-256 checksum How to use checksums |
ba682f2f25c756b0fb0d963c80f08e9363cb385f2726b63a9374dae5e9378e79
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.
Transparency logRelease files / oddsrelay-0.2.0-py3-none-any.whl
| Download URL | oddsrelay-0.2.0-py3-none-any.whl |
|---|---|
| Size | 12.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
11fc9a2e37a6dde8bb52ec4b38745d2b15ea081fdd782df05ac9c725b1e4bfb0
|
|
BLAKE2b-256 checksum How to use checksums |
4c0e5637ec617cfa04845d2beedbe3abe7cdc36cf77b352424d8a9607bbda2ff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.
Transparency logSecurity for oddsrelay 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for oddsrelay-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.