betfairlightweight
Lightweight python wrapper for Betfair API-NG
What it is and what it does
betfairlightweight is a client library that bridges Python code to the Betfair exchange API, handling authentication, market queries, order placement, and real-time streaming of market and order data. It wraps the Betfair API-NG endpoints and provides pythonic abstractions for betting operations (listing events, placing bets, managing orders) and account operations (checking balances, viewing statements). The library can optionally use C and Rust libraries for faster parsing and serialization when installed with the [speed] extra.
Typically used by traders and bots that need to connect to Betfair programmatically—either for one-off queries via the REST endpoints or for continuous market monitoring and order management via streaming listeners. It handles session management (login, keep-alive, logout), caches market and order state, and can push updates through a queue for asynchronous processing. Historical data can also be parsed and replayed using the same streaming infrastructure.
Use it for:
- Build a trading bot that subscribes to live market streams, processes price updates, and places orders based on custom logic.
- Backtest a betting strategy by replaying historical market data through the same streaming listeners used for live trading.
- Query account balances, statement history, and available funds programmatically for portfolio management or reporting.
- Monitor in-play events and race status in real time to trigger conditional bets or risk management actions.
- Aggregate market data across multiple event types or regions and export to CSV or a database for analysis.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A Python wrapper for the Betfair API-NG that handles betting operations, market and order streaming, and account management with optional C and Rust acceleration.
Yes. The package is actively maintained, has low install friction, carries no security vulnerabilities, and is licensed permissively. Install it if you need a programmatic Betfair client; the only real prerequisite is having valid Betfair credentials and understanding the API authentication model (app key, SSL certs, or interactive login).
Install
betfairlightweight on PyPI
pip
pip install betfairlightweightuv
uv add betfairlightweightpoetry
poetry add betfairlightweightInstalling betfairlightweight
Before you install
Low friction install with a single runtime dependency (requests). The project is actively maintained with recent commits and has been stable since 2016, tested on Python 3.9 through 3.14.
License in practice
MIT License permits commercial and private use, modification, and distribution with minimal restrictions—standard permissive terms that impose no meaningful constraint on adoption.
Quickstart
pip install betfairlightweight
import betfairlightweight
trading = betfairlightweight.APIClient('username', 'password', app_key='app_key', certs='/certs')
trading.login()
event_types = trading.betting.list_event_types()
Requires Betfair account credentials (username, password, app key) and SSL certificates for non-interactive login; interactive login available without certs but less secure.
Verify before relying
- Whether C/Rust acceleration via the [speed] extra meaningfully improves latency for typical streaming or order-placement workloads.
- Performance characteristics under high-frequency order updates or large market subscriptions.
- Stability and completeness of support for all Betfair API endpoints across different market types and regions.
Package facts
| License | MIT License Copyright (c) 2026, Liam Pauling Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — requests |
| Maintenance | actively maintained — 151 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 73,990/month — #14,893 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: betfairlightweight-2.23.2-py3-none-any.whl
Tags
More Internet packages
Botocore provides low-level, data-driven access…
permissive · top 100 on PyPI
aiobotocoreProvides an async client for AWS services using…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
filelockProvides a platform-independent file locking…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
googleapis-common-protosProvides common Protocol Buffer message…
permissive · top 100 on PyPI
nautilus_traderNautilusTrader is a Rust-native event-driven…
copyleft · top 15,000 on PyPI
schwab-pyUnofficial wrapper for the Charles Schwab API…
permissive · top 15,000 on PyPI
pycoingeckoPython wrapper around the CoinGecko API (v3)…
permissive · top 15,000 on PyPI
simplefixSimplefix provides a lightweight FIX (Financial…
permissive · top 15,000 on PyPI
ccxtCCXT is a unified API library for connecting to…
permissive · top 5,000 on PyPI
tradingview-taRetrieves technical analysis indicators and…
permissive · top 15,000 on PyPI
forex-pythonFetches current and historical foreign exchange…
permissive · top 15,000 on PyPI
alpaca-trade-apiPython client library for the Alpaca Commission…
unclear · top 15,000 on PyPI
backtestingBacktesting.py lets you define and test trading…
agpl · top 15,000 on PyPI
twythonTwython is a Python wrapper for the Twitter API…
permissive · top 15,000 on PyPI