Skip to main content

A betfair parser

Project description

betfair_parser logo

GitHub Build Status PyPI Python Version License Code style: black

betfair_parser

A simple and fast betfair parser. Why you might like this library:

  • Complete: All betfair (non-vendor) client API included
  • Conventions: The API strictly follows pythonic naming conventions
  • Consistency: All data is type checked, API requests as well as responses
  • Comfort: All betfair enums and type definitions are included, to support IDE syntax completion
  • Clear errors: API errors don't just throw cryptic codes, but contain documentation about that error
  • Compatible: Use it with any HTTP library you like, including async libraries
  • Cheetah fast: Thanks to the magic of msgspec, megabytes of input parse in milliseconds

Usage

betfair_parser is built out of API building blocks, that can be used with any HTTP client you like. All API operations provide .headers(), .body() and a .parse_response() method.

The client module contains a sample, minimalistic client implementation. It may be used as is with any requests-compatible HTTP client or serve as an example, how to integrate betfair_parser with other HTTP clients.

import requests
from betfair_parser import client
from betfair_parser.spec import accounts, betting

session = requests.Session()  # or anything similar like httpx.Client()
client.login(session, "username", "password", "app_key")
client.request(session, accounts.GetAccountFunds.with_params())
# AccountFundsResponse(available_to_bet_balance=10000.0, exposure=0.0,
# retained_commission=0.0, exposure_limit=-10000.0, discount_rate=0.0,
# points_balance=10, wallet=<Wallet.UK: 'UK'>)

# Request with an invalid wallet parameter:
client.request(session, accounts.GetAccountFunds.with_params(wallet="AUS"))
# >>> AccountAPINGException: INVALID_PARAMETERS: Problem parsing the parameters,
#     or a mandatory parameter was not found

client.request(session, betting.ListCurrentOrders.with_params())
# CurrentOrderSummaryReport(current_orders=[], more_available=False)

# Support for other countries
from betfair_parser.endpoints import endpoint
endpoint_cfg = endpoint("ITA")  # alpha-3 code
client.login(session, "username", "password", "app_key", endpoints=endpoint_cfg)

See test_live.py for more API call examples.

Releasing

Releases are published automatically when a tag is pushed to GitHub.

# Set next version number
export RELEASE=x.x.x

# Create tags
git commit --allow-empty -m "Release $RELEASE"
git tag -a $RELEASE -m "Version $RELEASE"

# Push
git push --tags
git push

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_parser-0.19.2.tar.gz (56.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

betfair_parser-0.19.2-py3-none-any.whl (67.9 kB view details)

Uploaded Python 3

File details

Details for the file betfair_parser-0.19.2.tar.gz.

File metadata

  • Download URL: betfair_parser-0.19.2.tar.gz
  • Upload date:
  • Size: 56.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for betfair_parser-0.19.2.tar.gz
Algorithm Hash digest
SHA256 e11b1cd5caf42b88ecda8a1e0730b58bdf7cbdb4a6ceef7916a8d9d740398b4e
MD5 ee3163967f5c0e6b38264d6f7b61a96d
BLAKE2b-256 3c23259a323da8f0e75a20d1c89263547b871545ea2f7189ee3054224634d903

See more details on using hashes here.

File details

Details for the file betfair_parser-0.19.2-py3-none-any.whl.

File metadata

File hashes

Hashes for betfair_parser-0.19.2-py3-none-any.whl
Algorithm Hash digest
SHA256 94a2bb2f6709e508308e918acf85cf2950f2cadba256da99645d3dfa4982a521
MD5 72381ef941b6545cdb0bd0e127508774
BLAKE2b-256 8d90479c8371c0e7022f69b35e126905c260b220a38d167d28d4d2c51aca0ed4

See more details on using hashes here.

Supported by

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