The Betfair API is the developer access Betfair offers to its betting exchange. Betfair runs an exchange where customers bet against each other, and it has a developer programme for its Exchange API, which programs use to read markets and prices and, with the right account and permissions, to place bets. If you searched for it, you most likely want exchange prices in your own code, or you want to automate betting on Betfair itself.
What you get, how you authenticate, which countries can use it and what it costs are all set by Betfair, and they change. Read Betfair's own developer documentation before you plan around any of it. This guide covers the part that doesn't change: what exchange prices mean once they're in your program, and the arithmetic you'll need either way.
What an exchange price is
A sportsbook sets one price per side and keeps a margin. An exchange shows a ladder of offers from other customers on both sides of every outcome:
- Back prices are what you can get by betting that something happens.
- Lay prices are what you can get by betting that it doesn't, which means you take the other side of someone's back bet.
- Each price comes with the amount available at it, so a price without its size is half the information.
Prices on an exchange are usually shown in decimal odds. A back offer at 2.50 with a lay offer at 2.52 next to it is a tight market. The gap between the best back and best lay is the spread, and a wide one tells you the price is less reliable as an estimate of the true chance.
Turning a back and a lay into numbers you can use
Store the decimal price and do every conversion in one place. For a back price of 2.50:
| Measure | Formula | Result |
|---|---|---|
| Implied chance | 1 / 2.50 | 40.00% |
| American odds | (2.50 - 1) x 100 | +150 |
| Profit on a $10 back bet | 10 x (2.50 - 1) | $15.00 |
Laying is where code goes wrong most often. If you lay $10 at 2.52, you win the backer's $10 stake when the outcome fails, and you pay out their profit when it happens. Your liability is the stake times the price minus one: 10 x 1.52 = $15.20. Keep stake and liability as separate fields. Treating a lay stake as the amount at risk understates your exposure by the whole of the price minus one.
The midpoint of 2.50 and 2.52 in implied chance is between 40.00% and 39.68%, so about 39.8%. That's a reasonable fair estimate for a liquid market. In a thin one, with a few dollars on each side, the midpoint can be miles from the truth.
Commission changes the price you actually get
An exchange like this generally makes its money from charges such as commission on net winnings, rather than from a margin built into the price. That means the quoted decimal price is not what you're paid. A simple way to model it:
def decimal_after_commission(decimal_price: float, commission: float) -> float:
if decimal_price <= 1.0:
raise ValueError("decimal price must be above 1.0")
if not 0.0 <= commission < 1.0:
raise ValueError("commission is a fraction, e.g. 0.05")
return 1.0 + (decimal_price - 1.0) * (1.0 - commission)
# A 2.50 back price with an example commission of 5%
print(round(decimal_after_commission(2.50, 0.05), 3)) # 2.425
At 2.425 the break-even chance is 1 / 2.425 = 41.24%, not 40.00%. That 1.24-point difference decides whether many apparent edges exist at all. The 5% above is an example figure only. Betfair publishes how its commission works and what rate applies to whom, and it can depend on the market and the account, so take the rate from Betfair's pages, not from a blog.
Betfair API cost and access
The honest answer to "betfair api cost" is that it's Betfair's to state, and it may depend on what you're building and whether it's for your own use. The things to check in Betfair's developer documentation and terms before you write code:
- Whether your country and account type can use the exchange and the API at all.
- What an application key costs, if anything, and what each kind of key may be used for.
- Request limits and data weighting, which shape how often you can poll.
- Whether streaming is offered for your use, and on what terms.
- What you may store, display or redistribute. Showing exchange data to other people is often treated differently from using it yourself.
Access to exchange betting varies by country and by US state, so a US developer should confirm availability before building anything.
Where ZippyOddsAPI fits
ZippyOddsAPI is independent and not affiliated with Betfair. It's a sports odds API that reads each operator's own public data, keeps the time every price was observed, and returns sportsbook, exchange and pick'em prices in one schema. Betfair isn't named in its documentation, so check the coverage page for which exchanges are feeding before you count on any one.
For exchanges it does carry, the arithmetic above is already done:
- Rows from
/v1/evcarrydecimal_after_feesandfee_verified. An exchange whose fee schedule isn't on file getsfee_verified: false, and its row is never counted as plausible. - Outcomes on exchange markets can carry
liquidity, the size available at that price. /v1/smart-moneysets an exchange price with known depth beside the best sportsbook price on the other side.
The ZippyOddsAPI docs cover each of those, including how keys are issued.
Related reading
If what you really want is a single feed across many US books rather than one exchange, start with our guide to choosing a sportsbook API. Pick'em apps raise a different set of questions, covered in what a PrizePicks API search is really after and the guide to Underdog Fantasy API options.