The Betfair API Headache: How to Get Exchange Odds Without the Red Tape
Looking for the Betfair API? Here’s What They Don’t Tell You Upfront
You found it. The Betfair Exchange API exists, and yes, it’s technically “free” to access. But before you start dreaming of building your next trading bot, let me save you some time.
Here’s what actually happens when you try to get Betfair Exchange odds:
| Requirement | Reality |
|---|---|
| Activation Fee | £299 one-time fee to go live |
| Account | KYC-verified Betfair account required |
| Authentication | SSL certificates + session tokens |
| Session Expiry | 20 minutes (Italy/Spain), 4 hours (UK) |
| Testing | No sandbox – use real money or delayed data |
| Geography | Blocked in US, most of Asia, and many other regions |
And that’s before you’ve written a single line of code. The Betfair API requires you to generate SSL certificates, manage session tokens that expire, and deal with their non-interactive bot login flow. All to access one bookmaker.
The “Third Option” for Betfair Exchange Data
What if you could skip the £299 fee, the SSL certificates, and the session management entirely?
OddsPapi aggregates odds from 300+ bookmakers – including Betfair Exchange. One API key. One authentication method. No certificates.
| Feature | Betfair Direct API | OddsPapi |
|---|---|---|
| Cost to Start | £299 activation | Free tier |
| Authentication | SSL certs + session tokens | Simple API key |
| Session Management | Required (expires every 20min-4hr) | Not needed |
| Geo Restrictions | Yes (US, Asia blocked) | No |
| Other Bookmakers | Betfair only | 300+ (Pinnacle, SBOBet, Singbet) |
| Historical Data | Separate paid product | Included on free tier |
Understanding Betfair Exchange: Back vs Lay Odds
Betfair is an exchange, not a traditional bookmaker. This means you’re betting against other users, not the house. The exchange offers two types of odds:
- Back odds – The price you can BUY an outcome at (betting FOR something to happen)
- Lay odds – The price you can SELL an outcome at (betting AGAINST something to happen)
This is what makes exchange data valuable for arbitrage and trading strategies. You can back on one platform and lay on another to lock in profit regardless of the result.
OddsPapi exposes both sides of the Betfair exchange book through the exchangeMeta field:
# Betfair Exchange response structure
{
"exchangeMeta": {
"availableToBack": [
{"price": 3.65, "size": 13.43},
{"price": 3.60, "size": 137.91}
],
"availableToLay": [
{"price": 3.70, "size": 68.50},
{"price": 3.75, "size": 326.30}
]
}
}
That’s the full depth of the exchange order book – multiple price levels with available liquidity at each.
Tutorial: Get Betfair Exchange Odds in Python
Let’s build a working example that fetches Betfair Exchange odds for a Premier League match.
Step 1: Set Up Authentication
First, grab your free API key from oddspapi.io. Authentication is a single query parameter – no certificates required.
import requests
API_KEY = "YOUR_API_KEY"
BASE_URL = "https://api.oddspapi.io/v4"
# All requests use this simple pattern
params = {"apiKey": API_KEY}
Step 2: Find Premier League Fixtures
# Get Premier League tournament (ID: 17)
response = requests.get(
f"{BASE_URL}/fixtures",
params={"apiKey": API_KEY, "tournamentId": 17}
)
fixtures = response.json()
# Find fixtures with available odds
for fixture in fixtures:
if fixture.get('hasOdds'):
print(f"ID: {fixture['fixtureId']}")
print(f"{fixture['participant1Name']} vs {fixture['participant2Name']}")
print(f"Kickoff: {fixture['startTime']}")
break
Step 3: Fetch Betfair Exchange Odds
# Get odds for a specific fixture, filtered to Betfair Exchange only
fixture_id = "id1000001761300947" # Man United vs Man City
response = requests.get(
f"{BASE_URL}/odds",
params={
"apiKey": API_KEY,
"fixtureId": fixture_id,
"bookmakers": "betfair-ex"
}
)
data = response.json()
# Access Betfair Exchange data
betfair = data['bookmakerOdds']['betfair-ex']
print(f"Betfair fixture link: {betfair['fixturePath']}")
Step 4: Parse Back and Lay Prices
Here’s the full path to access exchange odds. Market 101 is Full Time Result (1X2).
# Market 101 = Full Time Result
# Outcome 101 = Home Win, 102 = Draw, 103 = Away Win
market = betfair['markets']['101']
outcomes = {
'101': 'Home Win',
'102': 'Draw',
'103': 'Away Win'
}
for outcome_id, outcome_name in outcomes.items():
outcome = market['outcomes'].get(outcome_id)
if outcome:
player = outcome['players']['0']
exchange = player.get('exchangeMeta', {})
# Best available back and lay prices
back_prices = exchange.get('availableToBack', [])
lay_prices = exchange.get('availableToLay', [])
best_back = back_prices[0]['price'] if back_prices else None
best_lay = lay_prices[0]['price'] if lay_prices else None
print(f"{outcome_name}: Back @ {best_back} | Lay @ {best_lay}")
Output:
Home Win: Back @ 3.65 | Lay @ 3.70
Draw: Back @ 4.0 | Lay @ 4.1
Away Win: Back @ 2.38 | Lay @ 2.40
Step 5: Compare with Pinnacle (Optional)
Want to spot value? Fetch multiple bookmakers in one request:
response = requests.get(
f"{BASE_URL}/odds",
params={
"apiKey": API_KEY,
"fixtureId": fixture_id,
"bookmakers": "betfair-ex,pinnacle,sbobet"
}
)
data = response.json()
# Now you have exchange AND sharp bookmaker odds
for slug, bookmaker_data in data['bookmakerOdds'].items():
print(f"\n{slug}:")
market = bookmaker_data['markets'].get('101', {})
# ... parse prices
Why Developers Choose OddsPapi Over Direct Betfair API
300+ Bookmakers – The Betfair API gives you Betfair. OddsPapi gives you Betfair Exchange plus Pinnacle, SBOBet, Singbet, and 297 other bookmakers. Sharps, softs, Asian books, crypto books – all in one call.
Free Historical Data – Need to backtest your exchange trading model? Historical odds data is included on the free tier. Betfair charges separately for this.
No Geographic Restrictions – Access Betfair Exchange odds from anywhere. No VPN gymnastics required.
Available Markets
OddsPapi provides Betfair Exchange data for all major markets:
| Market | ID |
|---|---|
| Full Time Result (1X2) | 101 |
| Both Teams To Score | 104 |
| Over/Under 2.5 Goals | 1010 |
| Asian Handicap 0 | 1072 |
| Asian Handicap -0.5 | 1068 |
| Asian Handicap +0.5 | 1076 |
Get Started in 5 Minutes
Stop wrestling with SSL certificates and session tokens. Get Betfair Exchange odds with a free API key.
- Sign up at oddspapi.io
- Copy your API key
- Make your first request
curl "https://api.oddspapi.io/v4/odds?apiKey=YOUR_KEY&fixtureId=id1000001761300947&bookmakers=betfair-ex"
That’s it. No £299 fee. No certificates. No session management.