Please also be aware that other Betfair customers may have access to data that is faster and/or more accurate than the data shown on the Betfair site. If you rely on this data to place bets, you do so entirely at your own risk. Along with match data the service provides recent odds data from all major sportsbooks (11 currently including Bwin, Paddy Power, Betfair etc.) Results can be obtained for a maximum of 3 days back in the free plan. There is also a data-dump database of historical data for sale.
- Colts Neck Data Horse Racing
- Horse Racing Nation
- Horse Racing Results
- Betfair Historical Data Horse Racing Only Rare Earth
- Trackus Data Horse Racing
- Gulfstream Park Horse Racing
Lightweight, super fast (uses c libraries) pythonic wrapper for Betfair API-NG allowing all betting operations (including market and order streaming) and most account operations, see examples.
Note that Betfair Exchange prices are available to logged in customers only and are not included in the best odds calculation. Timeform is a sports data and content provider, specialising in horse racing and greyhound racing. Bet £10 get £30 in Free Bets + £10 on any Horse Racing. New Customers only - £10 minimum deposit.
Colts Neck Data Horse Racing
Currently tested on Python 2.7, 3.4, 3.5, 3.6 and 3.7.
In order to connect to the Betfair API you will need an App Key, SSL Certificates and a username/password.
App Key
Follow these instructions to get your app key. You can either go for a delayed or a live key.
SSL certificates
Follow these instructions to set up your SSL certificates. Save your .ctr and .key files to a local directory. The default directory where the library is looking for the keys if '/certs' but you can specify any other directory.
Using the library
The library can then be used as follows:
or the following for interactive login (no certs)
Following endpoints are available:
- trading.login
- trading.keep_alive
- trading.logout
- trading.betting
- trading.account
- trading.navigation
- trading.scores
- trading.streaming
- trading.historical
- trading.in_play_service
- trading.race_card
Currently two listeners available, below will run the base listener which prints anything it receives. Stream listener is able to hold an order stream or a market stream (one per listener). The listener can hold a cache and push market_books/order_books out via a queue.
In development so breaking changes likely.
The historic endpoint provides some basic abstraction for the historicdata api:
Taking advantage of the streaming code lightweight can parse/output historical data in the same way it process streaming data allowing backtesting or with a custom listener, csv creation (see examples).
In development so breaking changes likely.
or use the stream generator:
Active4 years, 11 months ago
I would like to access certain content on betfair.com, I have been looking over the Betfair API documentation but I have no idea how to create Application Keys and sessionToken's I want to be able to go through the horseracing pages and get horse names and prices.
On a video from Pycon, 'learn python through public data hacking', the Chicago transit authority had bus route info in xml format which made it easy to get any required info.
So my questions are, is there something similar in the betfair API, do I need to create application keys and sessionToken's and if so how do I do it?
![Trackus data horse racing Trackus data horse racing](/uploads/1/2/6/3/126311593/476910297.jpg)
I will be using Python.
Padraic CunninghamPadraic Cunningham140k14 gold badges141 silver badges216 bronze badges
3 Answers
Horse Racing Nation
The following is based on my experience using the SOAP API rather than the new API-NG:
If you have an active account, you can use the free API calls at the specified calls/minute rates specified using the product ID of 82. If you want higher frequency API calls and access to those not within the free API, consider the payment option for full personal access.
You can compare products at this link.
Note that even using the free API you will incur charges even if you stay within the limits of calls per minute but exceed a number of calls per second. Details of this are here enter link description here.
For example lets say using the free API you made 60 calls to GetMarketPricesCompressed, but you did them all within one second. Your calls would succeed but subsequent calls would fail due to exceeding the throttle of 60 per second - at least until a minute elapses. Even though you adhere to the API limits you would still be in danger of exceeding the data usage limits and run the risk of getting charged. I have made this mistake before myself when delpoying a betfair application - I once omitted a sleep call from my code and the above example is exactly what happened in my app.
Note also that the betfair documentation here states that the SOAP API 6.0 is being pulled in November 2014 and encourages the use of the API-NG.
As for your question regarding the session tokens, you will receive this with a successful call of the API Login method using a registered (and active) betfair user account. In my experience active usually means an account with greater than 100 betfair points.
For getting the horse runners and prices you will want combinations of
GetMarket
to get runner names and IDs followed by GetMarketPrices
and/or GetMarketPricesCompressed
to get the prices themselves. You can also use GetMarketTradedVolume
and its compressed alternative if you want a full breakdown of all money matched across all prices at the time the call is made. Using this you can get the rough equivalent of the candlestick charts used for tracking stocks and shares. Note that horse racing is tricky as non-runners introduce a reduction factor across all historical prices matches of all remaining runners when a horse is removed from the market. This can be very tricky to deal with.If you have further questions there is the betfair developers forum itself as well as a number of betfair bot forums where you can ask seasoned betfair bot programmers (as well as about APIs for other betting exchanges too)
mathematician1975mathematician197517.9k6 gold badges42 silver badges87 bronze badges
It sounds like you are looking at the API-NG which is a json interface rather than the current service which is WSDL-based. API-NG is a new service which is still in development, and in particular the documentation isn't great at the moment. For API-NG this is what I did:
- Log in to the Betfair site using a browser with your account credentials.
- Inspect the session's cookies (in Chrome this is in the Resources tab of the developers tools
- find the ssoid cookie value - that is your session token to use in this test page
- create an application key using your application name
- use the examples code on the betfair api-ng github to get started
On the other hand, if you are happy to use the existing WSDL service, then I understand quite a few people use this free python interface to it or this open source version.
Lastly, the free service is free so long as you have a funded account and operate within the throttling limits described, which should be fine at least to get you started if not much longer depending on what you want to do.
CardinalPCardinalP
According to the web page you need:
An active Betfair account The Free Access API productId, which is '82' - use this along with your Betfair credentials in the log-in protocol. The Betfair API WSDL URL's:
Horse Racing Results
The sessionToken is returned from the login.
Note the charges for using the free API.
Betfair Historical Data Horse Racing Only Rare Earth
Steve BarnesTrackus Data Horse Racing
Steve Barnes21.7k5 gold badges43 silver badges53 bronze badges