Skip to main content

A package with functions for getting Betfair Exchange odds on upcoming Premier League matches.

Project description

betfair_ex_connection

A package that allows an easy connection to the Betfair Exchange API, provided valid credentials are given. The package contains a class which stores the credentials provided, and allows the user to get basic delayed (~3mins) market odds information on premier league matches. The current version of the package only allows getting odds for matches that are listed on the betfair exchange at the time of running the function. There is no feature for getting odds on historical matches yet.

For more information on getting started with the Betfair API, read through the Getting Started docs.

This package was created to be used as a subpackage in a wider project - PSUSANNX.

Package Functions

  • list_upcoming_pl_matches()
  • get_betfair_exchange_odds()

Installation

pip install betfair_ex_connection

Usage

# Import the class object from the package
from betfair_ex_connection.betfair_ex_conn_class import BetfairExchangeConnection

# Get some info about the class object
help(BetfairExchangeConnection) 

Once the class has been imported and you've read the help, you can create an instance of the class to allow you to interact with your betfair account through the API. Make sure you have the required credentials at hand. You need the following information & you need to follow the steps in the links to use the class properly:

# Create an instance of the class with all the credentials & keys
betfair_ex_conn = BetfairExchangeConnection(
    username="<betfair-username>",
    password="<betfair-password>",
    app_key="<application-key",
    crt_path="<path-to-crt-key>",
    pem_path="<path-to-pem-key>"
)

The betfair_ex_conn object can now be used to call the above functions and get delayed (~3mins) match odds on the exchange.

list_upcoming_pl_matches function

# Use the betfair_ex_conn to get the upcoming premier league matches listed on the betfair exchange
upcoming_matches_df = betfair_ex_conn.list_upcoming_pl_matches()

# Print out the next 5 matches, their ID's on the exchange and their kickoff times
upcoming_matches_df.head()

get_betfair_exchange_odds function

# Get the delayed exchange odds for an upcoming premier league match
match_odds_df = betfair_ex_conn.get_betfair_exchange_odds(
    home_team='<home-team>', 
    away_team='<away-team>'
)

# Lood at the odds dataframe
match_odds_df

If the <home-team> Vs <away-team> match isn't available to bet on on the betfair exchange then the function will return a dataframe with NA values for the odds.

Notes

  • The package is quite restricted in what it can do, but it only needs to do things that are required by the parent project so there won't be much development.
  • A potential new feature to add to the package is the ability to get odds on matches that are not currently listed on the betfair exchange on runtime. This would require storing historical odds information in a public place.
  • If you want to develop similar functions for other leagues/sports I highly recommend using the API Demo Tools for testing out & generating API requests in your browser. It is hard to navigate through requests on your won so these tools allow you to use an interface to find your selections, then you can go into developer tools in your browser and copy the exact request that generated the results from your browser and use it in our code.

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

betfair_ex_connection-0.1.4.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

betfair_ex_connection-0.1.4-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file betfair_ex_connection-0.1.4.tar.gz.

File metadata

  • Download URL: betfair_ex_connection-0.1.4.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7

File hashes

Hashes for betfair_ex_connection-0.1.4.tar.gz
Algorithm Hash digest
SHA256 53b5c10795d95223dc45b08fdf5e90776586cd8b37bc70c3b25598c5c78c170e
MD5 df328ea29d5299e9bd2707f7a68bf99e
BLAKE2b-256 a38e9c572349e92a4fca7ae43acf747771b555c0e2fba703bb1246c0ccbe531b

See more details on using hashes here.

File details

Details for the file betfair_ex_connection-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: betfair_ex_connection-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7

File hashes

Hashes for betfair_ex_connection-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a1a887b595b2259687309a5f41d291cc2593b4aa9aa98d1a4a327cf353ee5348
MD5 14a54dd5b7518bc9f049d7cc20793aa1
BLAKE2b-256 ddbc11e209bd8a29cb681934cb8dda9653a5cc31622817a251ff8d7e4f93a2c1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page