Betfair & Betdaq APIs 2026
Sports Exchanges API Integration Guide
Betting exchange APIs explained: back, lay, and why exchanges allow automation
A betting exchange is a peer-to-peer marketplace where bettors back (bet for an outcome) or lay (bet against an outcome), matched against each other rather than against a house. The exchange earns commission on net winnings rather than building margin into prices — meaning exchanges price markets efficiently and have no incentive to restrict winning accounts.
This business model makes exchanges uniquely API-friendly. Betfair and Betdaq both provide fully documented APIs that allow you to read order books, stream real-time price changes, and place back or lay orders programmatically. Betfair is the world's largest betting exchange by volume; Betdaq is the main alternative, with lower standard commission and no Premium Charge.
Betfair Exchange API: setup, authentication, and key endpoints
The Betfair API consists of three layers:
- Betting API: listMarkets, listMarketBook, placeOrders, cancelOrders, replaceOrders
- Account API: balance, statement, transfer
- Streaming API: real-time market data via a persistent TCP/TLS connection
Application Key types
| Key Type | Data Delay | Cost | Use |
|---|---|---|---|
| Delayed App Key | 1 minute | Free — instant | Development and testing |
| Live App Key | Real-time | Free — requires approval | Production strategies |
Betfair Streaming API
The Streaming API replaces REST polling for production strategies. It delivers a full initial snapshot of market state, then sends lightweight delta messages on every price change — far more efficient than repeated listMarketBook calls. Key characteristics:
- Persistent TLS connection to
stream.betfair.com:443 - Subscribe up to ~200 markets per connection
- Choose ladder levels (1 = best price only, 10 = full 10-level depth)
- Handles market lifecycle: pre-match → in-play → suspended → closed
- betfairlightweight's
StreamingClienthandles all serialisation
Betdaq API: lower commission, no Premium Charge
Betdaq is the second-largest betting exchange, owned by Ladbrokes Coral. Its API offers full back/lay functionality similar to Betfair. Key differences that matter for automated strategies:
| Factor | Betfair | Betdaq |
|---|---|---|
| Standard commission | 5% (can vary by market/loyalty tier) | 2% standard |
| Premium Charge | Yes — up to 60% of net profit | No |
| Liquidity | Dominant — highest volume globally | Lower — sufficient in UK horse racing |
| API quality | REST + Streaming, well-documented | REST (SOAP legacy available) |
| Developer community | Large — many open-source tools | Smaller — fewer libraries |
The practical approach: run strategies on Betfair for maximum liquidity. If you become subject to Betfair's Premium Charge (requires consistent substantial profitability), Betdaq's 2% commission and zero Premium Charge may produce better net returns on markets where its liquidity is adequate.
Betfair vs Betdaq: exchange API comparison
| Feature | Betfair | Betdaq |
|---|---|---|
| API documentation | developer.betfair.com | betdaq.com/api |
| Real-time streaming | Yes — Streaming API | REST polling only |
| Python libraries | betfairlightweight, flumine | Limited third-party support |
| Lay betting | Yes | Yes |
| In-play markets | Yes — high liquidity | Yes — lower liquidity |
| Account restrictions | No limits on winners (Exchange) | No limits on winners |
Wiring a Betfair API pipeline: step-by-step
-
Create a developer app and get an Application Key
Log in to developer.betfair.com and create a new application. You receive a Delayed App Key immediately (free, 1-minute delayed data — suitable for development). To get a Live App Key (real-time data — required for production), submit an application describing your use case. Approval typically takes 1–3 business days. The Application Key is passed as the X-Application header on all requests.
-
Authenticate and get a Session Token
POST to https://identitysso.betfair.com/api/login with username and password. The response contains a session token valid for approximately 4 hours. Pass this as the X-Authentication header on all subsequent API calls. Implement proactive token refresh in your pipeline — if the token expires mid-strategy, all order placements will fail.
-
Discover markets with listMarkets
Call listMarkets with a MarketFilter (eventTypeIds, marketCountries, marketTypes) to find tradeable markets. Each market has a marketId — the unique identifier used for all subsequent operations. Also call listMarketCatalogue to get runner names and metadata. Cache this information; runner IDs do not change within a market's lifetime.
-
Subscribe to real-time prices via Streaming API
For production strategies, replace REST polling with the Streaming API. Open a persistent TLS connection to stream.betfair.com:443. Send an AuthenticationMessage, then a MarketSubscriptionMessage with your marketIds and ladderLevels (1–10). You receive a full initial snapshot, then lightweight delta messages on each price change. Maintain a local order book cache updated by each delta.
-
Place and manage orders via placeOrders / replaceOrders
Submit back or lay instructions via placeOrders. Batch multiple instructions in a single call for efficiency. Use replaceOrders to atomically cancel and re-place at a new price. For partial cancellation of unmatched exposure, use cancelOrders with a sizeReduction. Monitor matched/unmatched size via your Streaming cache — partially matched bets are common at outer ladder levels.
Python code sample: betfairlightweight price subscription
import betfairlightweight
from betfairlightweight import filters
from betfairlightweight.streaming.listener import StreamListener
# ── Authentication ─────────────────────────────────────────────────────────
client = betfairlightweight.APIClient(
username="your_username",
password="your_password",
app_key="your_live_app_key",
)
client.login()
# ── Find markets ───────────────────────────────────────────────────────────
market_filter = filters.market_filter(
event_type_ids=["1"], # Soccer
market_countries=["GB"],
market_types=["MATCH_ODDS"],
)
markets = client.betting.list_market_catalogue(
filter=market_filter,
market_projection=["RUNNER_DESCRIPTION", "EVENT"],
max_results=10,
)
for m in markets:
print(f" {m.market_id}: {m.event.name} — {m.market_name}")
# ── Streaming subscription ─────────────────────────────────────────────────
class PriceListener(StreamListener):
def on_change(self, change):
# change.market_books: list of MarketBook snapshots
for market_book in change.market_books:
for runner in market_book.runners:
best_back = runner.ex.available_to_back[0].price if runner.ex.available_to_back else None
best_lay = runner.ex.available_to_lay[0].price if runner.ex.available_to_lay else None
print(f" Runner {runner.selection_id}: back={best_back} lay={best_lay}")
stream = client.streaming.create_stream(listener=PriceListener())
market_ids = [m.market_id for m in markets]
stream.subscribe_to_markets(
market_filter=filters.streaming_market_filter(market_ids=market_ids),
market_data_filter=filters.streaming_market_data_filter(ladder_levels=3),
)
stream.start() # blocks — runs until connection closed
Exchange API use cases: arb, value betting, market making
| Strategy | Exchange role | Description |
|---|---|---|
| Sportsbook arbitrage | Lay leg | Back a soft book, lay the same outcome on Betfair — guaranteed profit if odds differ enough |
| Dutching / hedging | Lay leg | After a back bet at a soft book, lay on Betfair to lock in profit if the odds have shortened |
| Market making | Back + Lay | Post both back and lay orders around the fair price, capturing the spread from matched volume |
| In-play scalping | Back + Lay | Enter and exit positions on price movements during live events using Streaming API |
| Value betting execution | Back leg | When a soft book's odds exceed the Betfair exchange price (devigged), the exchange price validates the edge |
Betting Exchanges API Frequently Asked Questions
What is the difference between a back bet and a lay bet on Betfair?
A back bet is betting FOR an outcome to happen — the same as a traditional sportsbook bet. A lay bet is betting AGAINST an outcome — you act as the bookmaker, accepting a backer's bet. If you lay at 3.00 for £10, you collect £10 if the outcome does NOT happen, or pay £20 (£10 × (3.00 - 1)) if it does. The ability to lay opens market-making, arbitrage, and hedging strategies not possible at traditional books.
Is the Betfair API free to use?
The API itself is free. Betfair charges a small fee per successful execution request (approximately £0.001 per placeOrders call). Data subscriptions (for the Streaming API) have no additional cost. The significant cost for profitable accounts is the Premium Charge — an additional levy on cumulative profits for accounts where winnings substantially exceed commission paid. Premium Charge can reach up to 60% of net weekly profit.
What is the best Python library for Betfair automation?
betfairlightweight is the most widely used — handles authentication, all REST endpoints, and the Streaming API connection with minimal abstraction. flumine is a higher-level framework built on top of betfairlightweight — adds order management, worker loops, middleware, and logging. Start with betfairlightweight for direct control; use flumine when you want to focus on strategy logic and not infrastructure.
How does Betfair's Premium Charge work?
The Premium Charge applies when: (1) your cumulative net profit exceeds £250,000, AND (2) your total commission paid is less than 20% of your gross profit. If both conditions are met, a weekly charge of up to 60% applies to that week's net profit. Strategies that generate high turnover relative to profit (market making, scalping) tend to have higher effective commission rates that offset the Premium Charge threshold.
Why use Betdaq over Betfair?
Betdaq offers lower standard commission (typically 2% vs Betfair's 5%) and has no Premium Charge, making it more profitable for high-volume strategies once your Betfair account reaches Premium Charge territory. The tradeoff is significantly lower liquidity — Betdaq handles a fraction of Betfair's volume. Betdaq is most useful as a complement to Betfair, not a replacement, or for markets where its liquidity is competitive (certain horse racing, some football).
Can I run market-making strategies on Betfair via API?
Yes — market making (placing both back and lay orders to capture the spread) is fully supported via the API and is one of the primary use cases. You need a Live App Key and should use the Streaming API for real-time price feeds. Betfair considers market makers beneficial (they provide liquidity) and does not restrict this activity. Profitability depends on the spread, matched volume, and your order management discipline.
How many markets can I stream simultaneously on Betfair?
Betfair recommends no more than 200 markets per streaming connection. For broader coverage, open multiple connections. The Streaming API uses efficient delta encoding — subscribing to 200 active markets often generates less bandwidth than a single REST listMarketBook call covering the same markets. Filter by eventTypeId and marketType to avoid subscribing to markets you will never trade.