Skip to main content
Join the official Python Developers Survey 2018 and win valuable prizes: Start the survey!

Python client for the Betfair API (

Project description is a Python wrapper for the Betfair API


$ pip install


  • Python >= 2.7 or >= 3.3


To run tests

$ py.test

Application Keys

You will need an Application Key to log in to the Betfair API. You can find instructions for creating a key at

SSL Certificates

For non-interactive login, you must generate a self-signed SSL certificate and upload it to your Betfair account. includes tools for simplifying this process. To create a self-signed certificate, run

invoke ssl

This will generate the following files in the certs directory


You can write SSL certificates to another directory by passing the --name parameter

invoke ssl --name=path/to/certs/betfair

Once you have generated the files, you can upload the betfair.crt file to Betfair at


Create a Betfair client and log in

from betfair import Betfair
client = Betfair('app_key', 'certs/betfair.pem')
client.login('username', 'password')

Refresh session token


Log out


List all tennis markets

from betfair.models import MarketFilter
event_types = client.list_event_types(
print(len(event_types))                 # 2
print(event_types[0]   # 'Tennis'
tennis_event_type = event_types[0]
markets = client.list_market_catalogue(
markets[0].market_name                  # 'Djokovic Tournament Wins'


Joshua Carp (jmcarp)


MIT licensed. See the bundled LICENSE file for more details

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date (13.4 kB) Copy SHA256 hash SHA256 Source None Jul 8, 2015

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page