Header illustration for automate betfair api
Matched Betting

How to Automate Betfair Betting with the API

March 30, 2026·Last updated: March 30, 2026

Learn how the Betfair API works and how to automate your betting strategy. From API key setup to your first Python script, this guide covers everything.

💡

Quick Summary

The Betfair API lets you interact with Betfair Exchange programmatically: browse markets, read live prices, and place bets automatically through code. It replaces manual clicking with logic you control. With the right setup, you can execute in-play strategies in milliseconds, run systematic back and lay models overnight, and eliminate the human errors that come from manual betting at speed. This guide walks you from zero to your first automated script: API key, authentication, key endpoints, a Python example, and a comparison of third-party tools for non-coders.

What Is the Betfair API?

💡

Definition

The Betfair API (API-NG) is a REST-based programming interface that gives direct access to the Betfair Exchange. It allows software to browse markets, read current odds, place back bets and lay bets, manage open orders, and retrieve account information, all without touching the Betfair website. It communicates using JSON over HTTPS.

When you use the Betfair website or the mobile app, you are clicking buttons that call the same API behind the scenes. The API just removes the browser layer entirely, letting your code talk directly to Betfair's servers.

The current version is called API-NG. It replaced the old SOAP-based XML API years ago. API-NG is simpler, faster, and far easier to work with. All modern tools and libraries are built on top of it.

There are two main parts to the API. The Betting API handles everything related to markets and orders: browsing, placing bets, cancelling bets, and checking results. The Accounts API handles your account balance, funds transfers, and developer application settings.

Betfair also provides a Streaming API, which pushes real-time updates to your application instead of requiring you to poll for data. This is important for speed-sensitive strategies and is covered in the data feeds section below.

Why Automate Your Betting?

Manual betting on an exchange has real limits. Prices move in seconds, especially in in-play markets. The human reaction time between seeing a price, deciding to bet, and clicking confirm can mean the opportunity is gone. Automation removes that lag entirely.

There are three main reasons serious bettors move to the API.

Speed. In in-play markets, a price change can last less than a second before other bots absorb all available liquidity. A bot can respond in under 100 milliseconds. A human cannot.

Systematic execution. When you code your strategy, it runs exactly as designed every time. No emotional decisions. No skipping a bet because it "feels wrong." The rules are applied consistently across every market, every day.

Scale. A human bettor might place 20 to 50 bets per day across multiple markets. An automated bot can monitor hundreds of markets simultaneously and place thousands of bets per day, all while you sleep.

The biggest gain from automating is not speed. It is consistency. When I ran manual strategies, I would unconsciously skip certain bets, take slightly different stakes, or hesitate on in-play triggers. A bot does none of that. It either fires or it does not, based purely on the logic you wrote. That consistency is what lets you actually measure whether your strategy has an edge.

Getting Access: Developer Account and API Key

To use the Betfair API, you need a Betfair account and an API key. The process takes about 30 minutes if you follow it in order.

Important: the Betfair API is not available in all countries. Betfair operates under different licenses depending on the jurisdiction. Users in the UK, Ireland, and most of Europe have full API access. However, Betfair is restricted or unavailable in countries including the United States, France, Turkey, and several Asian markets. In some countries, Betfair operates through a local license with different terms. Before investing time in setting up API automation, verify that Betfair is fully accessible in your country. If you are a professional bettor in a restricted market and need exchange API access, reach out to us on Discord to discuss modern exchange API alternatives.

Step 1: Create a developer application

Log in to your Betfair account and go to developer.betfair.com. Navigate to the API-NG section and create a new application. Give it a name. You will see two keys appear: a Delayed Data key and a Live key.

The delayed data key gives you access to market data with a 5-second delay. You can use this for testing and for non-latency-sensitive strategies. The live key gives you access to place real bets and to use the full API functionality.

Step 2: Create an SSL certificate

Betfair requires SSL certificate-based authentication for the non-interactive login flow that bots use. You need to generate a self-signed certificate and private key, then upload the public certificate to your Betfair developer account.

On Linux or Mac, you can do this with OpenSSL in a single command. On Windows, you can use Git Bash or OpenSSL for Windows. Once uploaded, Betfair will use this certificate to verify your bot's login requests.

Step 3: Authenticate via SSOID session token

When your bot starts, it calls Betfair's identity endpoint with your username, password, and certificate. Betfair returns an SSOID session token. This token goes into the header of every subsequent API call as X-Authentication. Tokens expire after roughly four hours of inactivity, so production bots need to handle re-authentication automatically.

Key API Endpoints Explained

The Betting API has around 20 endpoints. In practice, most automated bettors use a small core set. Here are the most important ones.

Every API call requires the X-Application header (your API key) and the X-Authentication header (your session token). All requests are sent to the endpoint at https://api.betfair.com/exchange/betting/rest/v1.0/ with the operation name appended.

Python Example: List Upcoming Premier League Markets

Python is the most widely used language for Betfair automation. The betfairlightweight library wraps the API into clean Python objects, handling authentication and request construction for you. Install it with pip install betfairlightweight.

Here is a commented example that logs in and retrieves all upcoming Premier League match odds markets. This is typically the first script any bot developer writes.

Once you have a market ID from listMarketCatalogue, the next step is to call listMarketBook with that ID to get live prices. From there, you pass those prices through your strategy logic. If the logic says to bet, you build an instruction object and call placeOrders.

Third-Party Tools for Non-Coders

Not everyone wants to write Python scripts. Several desktop applications connect to the Betfair API through a graphical interface, letting you build automation rules without code. These tools offer spreadsheet-linked trading interfaces, custom automation rules, and ladder views for in-play markets.

The key consideration is whether a third-party tool supports your strategy and the markets you trade. Many professional traders use these tools as their primary interface instead of the Betfair website. If you want to compare the available options, we have a separate guide covering arbitrage and automation software.

For bettors who want exchange API access in countries where Betfair is restricted, or who need a modern API with lower commission, contact us on Discord to discuss alternative exchange API solutions. We work with professional bettors internationally to provide access to exchange liquidity through modern integrations.

Data Feeds: Free vs Real-Time

The Betfair API offers two levels of data access, and the difference matters for your strategy choice.

The free data feed comes with every API key. It provides market data with a 5-second delay. For pre-race strategies, model-based betting, or any approach that does not depend on split-second timing, this is perfectly adequate. Most hobbyist bots run on the free feed without issues.

The Streaming API provides near-real-time price updates over a persistent WebSocket connection. Instead of polling listMarketBook every few seconds, your application subscribes to specific markets and receives push notifications as prices change. This is essential for in-play trading, scalping, and any latency-sensitive strategy. The Streaming API is free and included with standard API access.

For commercial-grade low-latency data, Betfair offers paid subscriptions through its Exchange Data program. These feeds are used by professional trading firms and are not necessary for individual bettors.

Premium Charge and Volume Considerations

The Betfair premium charge is a critical factor for automated bettors. It applies when your lifetime net profit exceeds a threshold and your market profit percentage drops below 60%. In practice, this means consistently profitable bettors pay an additional charge on top of the standard exchange commission.

Automated bots accumulate volume quickly. A bot placing hundreds of bets per day can trigger the premium charge far sooner than a manual bettor. The charge can reach 20% of gross profits, or even 40% or 60% in extreme cases, which significantly changes your profitability calculations.

Before scaling any automated strategy, run a projection of expected volume, win rate, and premium charge impact. A strategy that shows 5% ROI before the charge may show 1% or less after it. Tracking your profits accurately from day one is essential for knowing when you are approaching the threshold.

Common Strategies to Automate

Most Betfair API bots fall into one of these categories.

Pre-race value betting. A model predicts the true probability of each outcome based on form, conditions, and other data. The bot compares its predicted probability to the current exchange price and bets when it finds value. This runs well on the free data feed since timing is not critical before the race starts.

In-play trading. The bot monitors live events and trades based on momentum, score changes, or market patterns. Speed is critical here, and the Streaming API is a requirement. Common in football, tennis, and horse racing.

Lay-the-field. The bot lays every runner in a market at short prices, aiming to profit from the overall market margin. This is primarily used in horse racing and works best in markets with many runners.

Arbitrage and matched betting. The bot monitors prices across bookmakers and the exchange, placing offsetting bets when a guaranteed profit exists. Speed and accurate price data are essential. Tools like dedicated arb software can complement your own API scripts for finding opportunities.

The Betfair API opens up a level of control and precision that manual betting cannot match. Whether you write Python scripts or use exchange trading software, the ability to define your strategy in rules and execute automatically removes human error and lets you scale. Start with the free data feed and a simple script. Get comfortable with the authentication flow and the core endpoints. Then layer in complexity as your edge becomes clear. The API is the foundation that every serious exchange bettor eventually builds on.

Find Your Next Edge

Sharkbetting's Oddsmatcher compares thousands of odds lines in real time and surfaces the best opportunities across European bookmakers.

Ready to Start Matched Betting?

Join 1,200+ bettors finding guaranteed profits every day