API Reference
Smaller live /v3 routes that don't need a page of their own: league
discovery, a bulk odds feed, start times for a batch of events, scheduled
bets, Betfair order management, and cash out.
Base URL: https://api.b337.ai · Header: X-API-Key: YOUR_API_KEY
Error bodies follow the same rules as everywhere else: FastAPI's
{"detail": "..."} for request errors, and {"error": "..."} for the
read endpoints' 429 / 503 answers.
GET /v3/leagues — every league on the treeEvery (sport, country, league) currently listed, with live event counts —
the tokens /v3/events?league= and
/v3/league_odds?league= accept. A league appears the moment its first event
is listed and disappears when its last one expires.
| Param | Type | Required | Description |
|---|---|---|---|
sport | string | No | Only one sport group, e.g. american_football. |
fixtures are bettable head-to-head events; outrights are futures
markets (see Events on outrights). Sorted
most fixtures first. Limited to 30 requests/min per key (429 +
Retry-After); 503 when the event index is unavailable.
GET /v3/league_odds — a whole league, cross-book, one callOdds API only. This is part of the bet337 Odds API, not the standard betting API. Any other key gets
403:{"error": "League odds are part of the bet337 Odds API.", "code": "odds_api_required"}.
Aligned cross-book odds for every fixture in one league (outrights are
excluded — get those from /v3/events?include_outrights=true +
/v3/markets).
| Param | Type | Required | Description |
|---|---|---|---|
league | string | Yes | League token from /v3/leagues, e.g. nfl. |
country | string | No | Narrows a league listed in several countries. |
date | string | No | Event day, YYYY-MM-DD. |
markets | string | No | Comma-separated market keys, e.g. head_to_head,player_receiving_yards. |
limit | int | No | Events per response, default 20, max 40. Soonest day first. |
offset | int | No | Skip the first N fixtures: page a big league with offset=0,20,40… instead of one oversized call. The response echoes offset; truncated says whether fixtures remain past this page. |
placement | bool | No | true = each book's full cell plus market_ref / site_event_id ready for Place Bet (see below). |
books | string | No | Comma-separated bookies, e.g. bet365,sportsbet. Only those books are returned, and the response is much faster. Recommended for big leagues (NBA) with placement=true. |
By default each odds value is a bare decimal and the response is cached
for ~15s — polling faster than that returns the same body.
placement=true replaces each decimal with the book's full cell
(odds, proposition_id, market_id, bettable, the book's raw
wording) plus market_ref, site_event_id, book_selection_id and
book_market_id; each event gains bookie_event_ids and per-book
scraped_at, and the top level gains market_ref_betting_enabled per book.
A null market_ref means "not safely placeable by id", never "not sold".
A cell whose price came from a live price check (bet365 today) also carries
priced_at (UTC ISO, newer than that book's scraped_at) and
price_source: "price_check"; without them the price is as old as scraped_at.
When bet365 refuses a multi below its floor, the live price it quoted for each
leg is written back the same way. If that quote is far from the published
price, the selection is withheld instead (no price) for up to 15 minutes, so a
bet365 selection can briefly disappear rather than show a price bet365 will not
take. Use POST /v3/price_check (category: "sports") for a live read
through your own bet365 session before placing.
Placement responses are ~15x heavier and never cached — narrow them with
markets and date.
Limited to 20 requests/min per key, shared by both modes (429 +
Retry-After). 422 for a missing league or limit out of range;
503 when the event index is unavailable.
POST /v3/start_times — countdowns for a batch of eventsStart time and lifecycle state for up to 500 epks (sports) or pks
(racing) in one call. Built to be polled: 120 requests/min per key.
| Field | Values |
|---|---|
kind | racing or sports |
start_time | ISO-8601 UTC, or null |
state | upcoming, in_play, finished, abandoned, unknown |
source | Which evidence decided state: spine, betfair, archive or none |
assumed | Terminal states only (finished/abandoned). true = inferred from the clock or from the event leaving our catalogue; false = backed by a signal we observed. A postponed fixture can read finished/abandoned with assumed: true while it will still be played. Lifecycle is not a result: never settle money on it, use the bookmaker's own result. |
Every key you send comes back, including ones we know nothing about
(state: "unknown", source: "none"), so you never have to handle a hole.
Errors: 400 — body not JSON, epks not a list of strings, or more than
500 ({"error": "too many epks: N (max 500)", "hint": "split into several requests"}
— refused, never truncated); 429 — rate limit (batch your keys into one
call); 503 — our cache is unavailable.
POST /v3/bet_results — current result for a batch of your betsOur current result for bets you already placed, looked up by the bookie's own bet id. Use it to catch up on any settlement you missed: poll it for the bets you still hold open. Read-only, sync, up to 500 ids per call, 60 calls/min.
results. not_found = no bet with that id on an
account your key owns.status: "settled" with verified: false is a provisional grade that a
later pass may still correct; keep polling it until verified is true.I; an id sent without it still matches.closing_odds, clv_pct and closing_source are the bet's
closing-line value, filled a few hours after the event starts on sports
singles. clv_pct = (odds / closing_odds − 1) × 100; positive means
you beat the close. The close is the last price before the actual off,
preferring Pinnacle with the margin removed (fair:pinnacle), then a
no-margin consensus of 3+ books that priced every side
(fair:consensus:<n>), then the median offered price
(offered:median:<n>). null = not priced: racing, multis and SGMs
(no per-leg CLV either), a bet placed after the off, no close recorded, or
not filled in yet. Same numbers as the CLV column on the API Bets page.Errors: 400 — bookie_bet_ids missing, not a list of strings, or more than
500; 429 — rate limit; 503 — the bets store is unavailable.
GET /v3/scheduled_bets — bets queued with execute_atA Place Bet with execute_at is held on
your client until that time. This lists the ones your key has queued, soonest
first. A row drops off about 15 minutes after its execute_at.
status is scheduled, cancelled, or rejected (with an error
string) once the bet has fired and failed. For the real outcome, poll the
row's correlation_id on POST /api/bet_status as usual.
POST /v3/cancel_scheduled_bet — cancel before it firesCancels one or more not-yet-fired bets on the session's client: both
execute_at bets and bets still waiting on a random_delay timer. A
cancelled delayed bet resolves its own correlation_id with a terminal
cancelled failure, so the poll ends instead of timing out.
| Field | Type | Required | Description |
|---|---|---|---|
session_id | string | Yes | The session the bets were placed on |
correlation_ids | string[] | Yes | Non-empty list of the bets' correlation_ids |
Cancel is best-effort: an id that is already placing, placed or unknown
is a no-op, and cancelled_correlation_ids echoes what you asked to cancel —
the bet's own status on /api/bet_status is the source of truth.
Errors: 400 missing session_id / empty correlation_ids; 403 the
session isn't yours or isn't active; 404 session not found; 503 your
client is offline — the bet lives only on that client, so while it is offline
it can neither be cancelled nor fire.
POST /v3/betfair_cancel_order — cancel a resting Betfair orderCancels the unmatched remainder of one Betfair exchange order. Works on
any Betfair session you own, with or without the api strategy. Async: HTTP 200
with a pending envelope, then poll POST /api/bet_status.
| Field | Type | Required | Description |
|---|---|---|---|
session_id | string | Yes | Your Betfair session |
market_id | string | Yes | Betfair market id, e.g. 1.234567890 |
betfair_bet_id | string | Yes | Betfair's bet id for the order |
size_reduction | number | No | Cancel only this much of the unmatched size. Omit to cancel the whole unmatched remainder. Matched size is never affected. |
The poll result is { "success": bool, "size_cancelled": number, "status": string, "error": string | null }.
POST /v3/cash_out — cash out a placed betCashes out a bet you placed, at the bookie's current cash-out offer. Works
across the books listed below; the book is taken from the account that placed
the bet. The session must be the one that placed the bet and must be online.
Async: HTTP 200 with a pending envelope, then poll POST /api/bet_status.
You send the offer you saw, and the cash out happens only at exactly that amount. If the bookie's offer has moved, the request is refused as "offer changed", nothing moves, and you can re-quote and try again.
| Field | Type | Required | Description |
|---|---|---|---|
session_id | string | Yes | The session (account) that placed the bet |
bet_id | string | One of | Our bet id, as returned by place_bet / bet_results. Send this OR bookie_bet_id, not both |
bookie_bet_id | string | One of | The bookie's id for a bet on this session's account. No match, or more than one match, is a 404; use bet_id then |
cash_out_amount | number | Yes | The bookie's current full cash-out offer, in dollars, above 0 (rounded to 2dp) |
partial_amount | number | No | TAB only. Dollars to take now, whole cents, at least 0.01 and not more than cash_out_amount. Equal to cash_out_amount is a full cash out |
sports | boolean | No | bet365 only. Overrides the sports/racing detection. Normally omit. |
Supported books: bet365, sportsbet, pointsbet, unibet, tab (full and
partial), ladbrokes, neds, betright, nextbet, playup, picklebet, betr, dabble, the
Amused brands (betnation, betdeluxe, surge, noisy, pulsebet, bigbet, yesbet,
mightybet, betjet, betexpress) and the BetCloud brands (bet777, betgalaxy,
betprofessor, betstride, chromabet, epicodds, fiestabet, goldenbet888,
juicybet, junglebet, questbet, slambet, sterlingparker, templebet, titanbet,
voltbet, wellbet). betway is not yet supported. Any other book is a 400:
cash out is not supported for <bookie>.
The poll result is { "success": bool, "status": "cashed_out" | "refused" | "unknown", "amount": number, "error": string | null, … }.
cashed_out: confirmed, at amount.refused: the bookie declined, or the offer changed. Nothing moved, so it is safe to re-quote and retry.unknown: the request reached the bookie but the outcome could not be confirmed. Check the bet before retrying; do not blindly retry.Errors: 400 bad body (missing session_id, both or neither of bet_id / bookie_bet_id,
cash_out_amount not a number above 0, sports not a boolean, a bad partial_amount,
partial_amount on a book that has no partial cash out), the book is not supported, the session isn't
the account that placed the bet, or the bet has no bookie bet id recorded; 403 the session isn't yours;
404 session not found, or the bet is not found / not yours (also a bookie_bet_id matching none, or more than one,
bet on the session's account); 409 the bet is already settled, or a cash out for it is already in
progress (60s lock); 503 the
session's PC is offline, or the bet lookup failed.
POST /v3/bet365_cash_out — cash out a bet365 bet (legacy)Legacy. Use
POST /v3/cash_outinstead; it covers bet365 and every other book above. This route stays live for existing integrations.
Cashes out a bet365 bet you placed through the API, in full, at bet365's live
cash-out offer. bet365 only. The bet365 session that placed the bet must be
online on an up-to-date client. Async: HTTP 200 with a pending envelope, then
poll POST /api/bet_status.
bet365 pays a cash out only at its exact current offer, so you don't send the
offer: your client reads it live from bet365 and closes the bet at exactly
that figure. cash_out_amount is the least you'll accept. If the offer
is below it, or cash out is suspended, nothing is sent and the result is
refused. If the offer moves between reading it and closing, the client
re-reads it and tries once more (still never below your minimum). Send
0.01 to take whatever bet365 is offering.
| Field | Type | Required | Description |
|---|---|---|---|
session_id | string | Yes | The bet365 session that placed the bet |
bet_id | string | One of | Our bet id, as returned by place_bet / bet_results. Send this OR bookie_bet_id, not both |
bookie_bet_id | string | One of | bet365's receipt for the bet (e.g. RT4501080581I), looked up on the account behind session_id. No match, or more than one match, is a 404; use bet_id then |
cash_out_amount | number | Yes | Dollars, 2dp, above 0. The minimum you'll accept; the bet closes at bet365's live offer, never below this. Partial cash out is not supported. |
sports | boolean | No | Overrides the sports/racing detection. Normally omit. |
The poll result is { "status": "cashed_out" | "refused" | "error", "amount": number, "bid": ..., "raw": ..., "error": string | null }.
amount is what bet365 paid (the live offer) — treat it as authoritative.
refused means the bet was not cashed out: the offer was below your minimum,
cash out was suspended or the bet is no longer open (raw is null,
nothing was sent), or bet365 declined (raw holds its reply, e.g.
<id>|BetSorry). error means the outcome is unknown (network etc.): check
the bet before retrying, do not blindly retry.
Errors: 400 bad amount, both or neither of bet_id / bookie_bet_id, not a bet365 bet, the session isn't the account
that placed the bet, or the bet has no bet365 id; 404 bet not found (or the receipt matches none, or
more than one, bet on the session's account) or not yours; 409 the bet is already settled, or a cash out for it is already in
progress (60s); 503 the session's PC is offline.
POST /v3/get_betfair_positions — list current Betfair ordersRead-only list of a Betfair session's current exchange orders. Same ownership
rules and async envelope as betfair_cancel_order.
| Field | Type | Required | Description |
|---|---|---|---|
session_id | string | Yes | Your Betfair session |
market_ids | string[] | No | Only these Betfair markets. Omit for every current order on the account. |
The poll result is { "success": bool, "positions": [...], "count": int, "error": string | null }.
Each position carries bet_id, market_id, selection_id, side,
price, size, size_matched, size_remaining, size_lapsed,
size_cancelled, average_price_matched, status,
persistence_type, order_type and placed_date.
Errors (both Betfair endpoints): 400 a required field missing,
size_reduction not a number, or market_ids not a list; 403 "Invalid
session_id or session does not belong to user"; 404 session not found;
503 "PC is not online. Please ensure the client is running."
POST /v3/price on a Betfair session — top 3 back/lay levels per runnerSend POST /v3/price with a Betfair
session_id and it returns Betfair top-of-book instead of a bookie price.
Read-only. No category is needed. Same async envelope as every
/v3/price (200 pending plus correlation_id, optional callback_url;
the result arrives via POST /api/bet_status or your callback). Other
bookies are unchanged.
| Field | Type | Required | Description |
|---|---|---|---|
session_id | string | Yes | Your Betfair session (must be active) |
market_ids | string[] | One of | 1 to 10 Betfair market ids, e.g. "1.234567890". Duplicates are dropped. |
pk | string | One of | A race pk (from GET /v3/races); we look up the race's Betfair markets. |
track, race_num, date, country | string / int | With race | Instead of pk: all four are required, plus race_type (default "(R)"). |
market_type | string | No | WIN or PLACE (case-insensitive) returns only those markets. Omitted = every market for the race (win and place). Race lookups only. |
The poll result is { "success": bool, "markets": [...], "errors": { market_id: reason }, "error": string | null }.
Each market carries market_id, status, inplay, runners and, when
requested by race, market_type (WIN or PLACE). PLACE markets also
carry places (2 or 3). A race can have both a 2-place and a 3-place market;
all are returned, ordered WIN, place 2, place 3. Each runner carries
selection_id, runner_name, saddle_cloth, status (ACTIVE,
REMOVED, ...), back and lay: up to 3 { "price": float, "size": float }
levels each (back highest price first, lay lowest first). A side can
have fewer than 3 levels, and a REMOVED runner has empty ladders.
runner_name, saddle_cloth, market_type and places are omitted when
unknown, so do not require them. Requests by market_ids return markets
without market_type or places. success is true when at least one
market was read; a market that could not be read appears in errors
instead of failing the call.
Illustrative (trimmed to one runner per market; the place sizes and places
value are examples).
Errors: 400 neither market_ids nor a race given, market_ids empty,
over 10 or containing empty strings, or market_type other than WIN or
PLACE (market_type must be WIN or PLACE); 404 No Betfair win market found for that race; 404 No Betfair place market found for that race
(market_type PLACE and the race has none).
epkmarket_refs