|
Project Information
Featured
Downloads
|
Python (>= 2.6.3/2.7.x) library to communicate with the Betfair Betting Exchange IntroductionBfPy eases the communication with the Betfair API by:
BfPy supports:
BfPy uses (included in the sources):
Quick Exampleimport bfpy bf = bfpy.BfClient() try: bfresp = bf.login(username='yourusername', password='yourpassword') except bfpy.BfErrror, e: print "login error: %s" % str(e) else: print bfresp # And now execute a keepAlive try: bfresp = bf.keepAlive() except bfpy.BfErrror, e: print "keepAlive error: %s" % str(e) else: print bfresp If you followed the Betfair API documentation, this would have been the natural path for the login call
Once satisfied and to call the keepAlive call (that has no parameters):
And this time there were no parameters. You have probably perceived how the library has eased Session Management and created the "XXXReq" in the background (and the APIRequestHeader) and how everything was parsed in the background to give you a printable object. Extended Services
Sometimes it is impossible to know if placing a bet with keep In-Play will succeed or not because it is unknown if the market will turn In-Play. Calling placeBets with _nonIPRePlace set to True, the call will immediately re-Place the bet if it fails due to a non-In-Play error
It creates a blend of the original getEvents and getActiveEventTypes, to allow seamless recursion from the top events (the ActiveEventTypes) down to BFEvent and Markets
That simulates a betStatus='MU', which is not accepted by the Betfair API (M or U have to be passed) returning a unified list of current matched and unmatched bets Another Exampleimport bfpy bf = bfpy.BfClient() try: bfresp = bf.login(username='user', password='pass') except bfpy.BfError, e: print "login error: %s" % str(e) else: print bfresp try: bfresp = bf.getAllEventTypes() except bfpy.BfError, e: print "getAllEvents error: %s" % str(e) else: print bfresp More examples can be found in the sources under the a directory called tests. A working application is: Bfplusplus (http://code.google.com/p/bfplusplus) |