Skip to main content

psusannx_betfair

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 psusannx_betfair

Usage

# Import the package
import psusannx_betfair

# Get some info about the class object
help(psusannx_betfair.PsusannxBetfair) 

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 = PsusannxBetfair(
    username="<betfair-username>",
    password="<betfair-password>",
    app_key="<application-key",
    crt_path="<path-to-crt-key>",
    pem_path="<path-to-pem-key>".
    team_mapping={"team_name": "new_team_name"}
)

The betfair 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.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.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 output on your own, 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 your code.

Metadata

Release files for psusannx-betfair 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for psusannx-betfair 0.0.3
File Size Uploaded Provenance Actions
psusannx_betfair-0.0.3.tar.gz 7.0 kB Without provenance Details for psusannx_betfair-0.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for psusannx-betfair 0.0.3
File Interpreter ABI Platform Actions
psusannx_betfair-0.0.3-py3-none-any.whl Python 3 none any Details for psusannx_betfair-0.0.3-py3-none-any.whl

Total release size: 14.5 kB

Release files / psusannx_betfair-0.0.3.tar.gz

Download URL psusannx_betfair-0.0.3.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ab1e48cdd4a1210d53d3842442f01d5dd32298e318571885b990fd433eaab3a7
BLAKE2b-256 checksum
How to use checksums
10a1b7256521c4b5aca77ce27413906881955b152f4d8ef87e321bf7244598f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / psusannx_betfair-0.0.3-py3-none-any.whl

Download URL psusannx_betfair-0.0.3-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0848274eb863fc8bd449f1c46bba6bdf8fbd8a7b7e5aab46d1664d66c653429a
BLAKE2b-256 checksum
How to use checksums
24cdc3bd2d6897c5331cae7667fd59106adefc18c0453e064220212e3fd72be1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Security for psusannx-betfair 0.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page