Getting Started
The API uses API key authentication. This guide explains how to obtain and use your API key.
Warning: API keys are sensitive credentials. Store them securely and never expose them in client-side code or public repositories.
Include your API key in the X-API-Key header of every request:
No X-API-Key header at all is a request validation error:
The key is not a valid API key.
Solutions:
X-API-Key header, not AuthorizationThe key is valid but not allowed to do this. The detail says why:
detail | Meaning |
|---|---|
No valid subscription | The account has no active subscription (see below for sample responses). |
Betting is not enabled on this account. | The plan can read data but not place bets. |
Session does not belong to user (and similar wording) | The session_id is not one of your sessions. |
Session is not active | The session exists but is not running / registered. |
On an endpoint that has a sample, an unpaid 403 also carries the response header X-Bet337-Sandbox-Hint, telling you to send X-Bet337-Sandbox: 1.
Every account gets an API key, so you can try the API before you subscribe.
Until your account has an active subscription, the API answers
403 No valid subscription. To get a sample response instead, add this
header to your request:
Most endpoints in these docs then return an example with the same shape as
the real one, plus the fields below. The async /v3 routes (place_bet,
place_promo, stacked_srm, price_check, withdraw_balance, transactions, promos,
bonus_bets, promo_tokens, split_bonus_bet, start_session, restart_session)
return their sample with status 202; the live routes answer 200.
The response also carries the header X-Bet337-Sandbox: 1. A sample is never
real: no bet is placed, no balance is read and no session is started. Once
your subscription is active, the header is ignored and you get live data, so
you can leave it in your code.
These endpoints have no sample and keep answering 403 (or 401 for the demo
key) until you subscribe: GET /accounts/account-status,
POST /v3/place_bet_strategy, GET /v3/strategy_status/{group_id},
POST /v3/price, GET /v3/races,
GET /v3/race_markets, GET /v3/leagues, POST /v3/start_times,
POST /accounts/scrape_promos and the scheduled-bet / Betfair order routes.
To try any endpoint in these docs before you sign up, send the demo key
demo. It always returns the sample response, with no other header needed:
The demo key never reaches a real account. It is rate-limited to 30 requests
a minute per IP and 600 a minute across all callers; over either limit it
answers 429 with a Retry-After header (seconds). On an endpoint with no
sample it answers 401 Invalid API key. When you're ready for live data,
create an account and use your own key.
You can test your API key by making a simple request:
A successful response confirms your authentication is working: