Docs.
Four keys, plain JSON, one private token. Nothing to install.
Base URL
url
https://api.spainodds.com/<TOKEN>/records/<key>
- Your private token goes in the path. Keep it server-side; do not ship it in browser code.
- Responses are gzip-compressed when you send
Accept-Encoding: gzip. - Send your own
User-Agent(any name for your app). - Times are ISO 8601 in UTC.
checked_athas millisecond precision.
Keys
- index
- Every active match starting in the next 14 days, with its full
latest_urlandhistory_url. - latest_<event_id>
- The last capture of one match: every book, the best price per outcome,
combined_book. - history_<event_id>
- Every capture of one match, rewritten every 30 min and at kick-off; the newest capture is always in
latest_(Pro). - movimientos
- Which book moves first, per league and Madrid time band (Pro).
Polling
- No push or webhooks: you poll.
- Captures run every 2 minutes in the 72 h before kick-off and every 10 minutes before that.
latest_refresh_minutestells you which applies to each match. - Poll
index, then fetchlatest_<event_id>only for matches whoselast_capture_started_atchanged. Ifcapture_started_atis unchanged since your last poll, there is no new capture. - For matches with
latest_refresh_minutes10,latest_is rewritten about every 10 min; comparelatest.capture_started_at. - Basic keys: 10-minute snapshots.
- Polling faster than the capture cadence returns the same data.
- A match freezes at kick-off and leaves the index. Its records are deleted 72 h after the start. A match no book has quoted for 30 min before its start also leaves the index, with status
withdrawn.
Fields
index
- schema_version
- Version string of the format.
- feed_updated_at
- When the index was last written.
- leagues[]
- League ids covered:
la_liga,segunda,acb,euroleague. - window_days
- How far ahead matches are listed (14).
- two_minute_window_hours
- Hours before kick-off with 2-minute captures (72).
- notes[]
- Plain-text notes about the feed (in Spanish).
- events[]
- One object per match, below.
index · events[]
- event_id
- Stable id, e.g.
ev_10c7a4fd2246. Used inlatest_andhistory_keys. - sport · league
footballorbasketball; league id.- home · away · start
- Team names and scheduled start (UTC).
- market · period
1x2atregular_timefor football (90 min + stoppage, no extra time);moneylineatincluding_overtimefor basketball.- status
activewhile listed.- latest_refresh_minutes
- Current capture cadence for this match: 2 or 10.
- bookmakers_in_latest
- Number of books in the last capture.
- last_capture_started_at
- Start of the last capture. Compare it between polls.
- captures
- Number of captures stored for the match.
- latest_url · history_url
- Full URLs for this match, token included.
latest_<event_id>
- event{} · notes[] · summary{}
- Match header, notes for the sport, capture summary.
- status · feed_updated_at · latest_refresh_minutes
status:active,started(frozen at kick-off) orwithdrawn;feed_updated_atandlatest_refresh_minutesas in the index.- latest.capture_started_at
- When this capture started.
- latest.best
- Per outcome (
"1","X","2"; basketball"1","2"):bookmaker,effective_odds,stake_share(share of a stake on that outcome to equalise the payout across outcomes). - latest.combined_book
- Sum of 1 / best effective odds across outcomes.
- latest.is_surebet
truewhencombined_bookis below 1. Computed fromeffective_odds, not confirmed with the books.- latest.bookmakers[]
- One row per book, below.
latest.bookmakers[]
- bookmaker
- Book id, e.g.
kambi_pafes,betfair_exchange_es. - bookmaker_event_id · bookmaker_start
- The book's own id and start time for the match.
- checked_at
- When this book answered (ms). Median ~3 s after
capture_started_at, p95 ~10 s.nullif not recorded. - odds{}
- Decimal odds as published.
- effective_odds{}
- What you would get. Equal to
oddsexcept Betfair Exchange, net of a 5% commission. - changed_since_previous
trueif this book changed any price since its previous capture.- data_delayed
truefor Betfair Exchange.- refresh_minutes
- This book's cadence. William Hill appears only in the 10-minute passes.
history_<event_id>
- captures[]
- Same header as
latest_, plus every capture of the match, each shaped likelatest. Rewritten every 30 min and at kick-off; the newest capture is always inlatest_.
movimientos
- by_league_and_band[]
- One entry per
leagueandtime_band_madrid(00-08, 08-14, 14-20, 20-24). - bookmakers[].moves
- Price moves seen for that book.
- bookmakers[].first
- Times it moved first and at least one other book followed in the same direction within 30 min.
- bookmakers[].followed
- Times it followed another book.
- bookmakers[].median_follow_delay_min
- Its median delay when following, in minutes;
nullif it never followed.
Examples
curl
curl -s --compressed "https://api.spainodds.com/$TOKEN/records/index" curl -s --compressed "https://api.spainodds.com/$TOKEN/records/latest_<event_id>" # event_id / latest_url from index
python 3 · standard library
import gzip, json, os, time, urllib.request
TOKEN = os.environ["SPAINODDS_TOKEN"]
BASE = f"https://api.spainodds.com/{TOKEN}/records/"
def get(url):
req = urllib.request.Request(url, headers={"Accept-Encoding": "gzip", "User-Agent": "my-app/1.0"})
with urllib.request.urlopen(req, timeout=30) as r:
body = r.read()
if r.headers.get("Content-Encoding") == "gzip":
body = gzip.decompress(body)
return json.loads(body)
seen = {} # event_id -> capture_started_at already printed
while True:
index = get(BASE + "index")
for ev in index["events"]:
if seen.get(ev["event_id"]) == ev["last_capture_started_at"]:
continue # no new capture
latest = get(ev["latest_url"])["latest"]
if seen.get(ev["event_id"]) == latest["capture_started_at"]:
continue # latest_ not rewritten yet
seen[ev["event_id"]] = latest["capture_started_at"]
best = {k: (v["bookmaker"], v["effective_odds"]) for k, v in latest["best"].items()}
print(ev["home"], "-", ev["away"], latest["capture_started_at"], best)
time.sleep(120)
javascript · node 18+
const BASE = `https://api.spainodds.com/${process.env.SPAINODDS_TOKEN}/records/`;
const seen = new Map(); // event_id -> capture_started_at already printed
async function get(url) {
const r = await fetch(url); // Node's fetch sends Accept-Encoding and decompresses gzip
if (!r.ok) throw new Error(`${r.status} ${url.split("/records/")[1]}`);
return r.json();
}
async function poll() {
const index = await get(BASE + "index");
for (const ev of index.events) {
if (seen.get(ev.event_id) === ev.last_capture_started_at) continue; // no new capture
const { latest } = await get(ev.latest_url);
if (seen.get(ev.event_id) === latest.capture_started_at) continue; // latest_ not rewritten yet
seen.set(ev.event_id, latest.capture_started_at);
console.log(ev.home, "-", ev.away, latest.capture_started_at, latest.best);
}
}
poll().catch(console.error);
setInterval(() => poll().catch(console.error), 120_000);