Skip to main content

Client library for Betfair API Next-Generation

Project description

betfairng: A client library for Betfair API-NG

.. image::

Betfair API-NG is the next-gen version of the longstanding SOAP-based Betfair API v6. As of November 2014, API-NG will be the only way to programmatically access the Betfair exchange.

API-NG is a REST-based design rather than SOAP, and has improved consistency and convention that make it easier to work with. betfairng makes it easier still, with pythonic naming and sensible defaults.

.. code-block:: pycon

>>> market_filter = {
'eventTypeIds': [7],
'marketCountries': ['GB'],
'marketTypeCodes': ['WIN'],
'sort': 'FIRST_TO_START',
>>> next_race = api.list_market_catalogue(filter=market_filter, marketProjection=['RUNNER_METADATA'], maxResults=1)[0]
>>> book = api.list_market_book(marketIds=['1.114185343'], priceProjection=dict(priceData=['EX_BEST_OFFERS']))

betfairng also provides a backwards-compatibility layer so you can continue to use the SOAP naming conventions (e.g. placeBets instead of place_orders, getMarketPrices instead of list_market_book, etc).


From pypi::

pip install betfairng


Betfair API-NG requires 2-way SSL for non-interactive logins (i.e. for bots or automated tools). Instructions for creating your certificate and registering it with Betfair `can be found on Betfair's website <>`_.

Once done, simply pass the paths to the .crt and .key files to the authenticate function along with your username and password.

.. code-block:: pycon
>>> from betfairng import authenticate
>>> cert = ('path/to/file.crt', 'path/to/file.key')
>>> resp = authenticate(cert, username, password)
>>> resp['loginStatus']
>>> resp['sessionToken']

Project details

Download files

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

Source Distribution

betfairng-0.1.6.tar.gz (6.7 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page