matchbook-sdk
A Python client for the Matchbook Betting Exchange API (REST).
- One typed method per endpoint on a single
MatchbookClient - Responses are dataclasses; each keeps its raw JSON (
.raw) plussent_at,received_atandlatency_ms - Endpoints are grouped as
account,markets,betting,reportsandheartbeat
pip install matchbook-sdk
import matchbook
Quick Start
from matchbook import MatchbookClient
client = MatchbookClient(username, password)
client.login() # one session lasts ~6 hours; reuse it
events = client.get_events(sport_ids=[15], states=["open"], include_prices=True).events
market = events[0].markets[0]
runner = market.runners[0]
best_back = runner.available_to_back()[:1]
best_lay = runner.available_to_lay()[:1]
Offers
from matchbook import OfferRequest
from matchbook.utils import batch
offer = client.submit_offer(runner_id, "back", odds=2.5, stake=10,
keep_in_play=False, odds_type="DECIMAL").offers[0]
print(offer.status, offer.stake_matched, offer.remaining)
client.edit_offer(offer.id, new_odds=2.6)
client.cancel_offer(offer.id)
offers = [OfferRequest(runner_id=r, side="lay", odds=1.5, stake=5) for r in runner_ids]
for result in batch(client.submit_offers, offers, 10): # 10 per call
failed = [o for o in result.offers if o.status == "failed"]
client.cancel_offers(market_ids=[market_id]) # no filters cancels everything
- Each submitted offer succeeds or fails on its own; check
status(anderrorswhen"failed") - In play, an offer or edit that would match comes back
"delayed"and resolves after the delay
Paging
- Many endpoints are offset-paged (
offset,per_page). Apaginateutility is supplied:
from matchbook.utils import paginate
for page in paginate(client.get_events, sport_ids=[15], per_page=100):
...
Heartbeat
client.send_heartbeat(60) # cancel all open offers if nothing arrives for ~60s
client.delete_heartbeat()
Errors
- All errors derive from
MatchbookError:
from matchbook import MatchbookAPIError, MatchbookTransportError
try:
client.get_offer(123)
except MatchbookAPIError as exc: # error status: status_code, messages, codes, body
print(exc.status_code, exc.messages, exc.latency_ms)
except MatchbookTransportError as exc: # no response
print(exc, exc.latency_ms)
Execution
from matchbook.execution import add_ticks, round_down_to_nearest_price
round_down_to_nearest_price(5.55) # 5.5
add_ticks(1.99, 2) # 2.02
Tests
The live tests read MATCHBOOK_USERNAME and MATCHBOOK_PASSWORD from the
environment or .env, and skip without them. Matchbook has no sandbox, so the
tests that place offers also need MATCHBOOK_ALLOW_BETTING=1; they back at
1000.0 with MATCHBOOK_TEST_STAKE (default 1) and cancel straight away.
Metadata
Release files for matchbook-sdk 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| matchbook_sdk-0.1.0.tar.gz | 25.0 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| matchbook_sdk-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 59.0 kB
Release files / matchbook_sdk-0.1.0.tar.gz
| Download URL | matchbook_sdk-0.1.0.tar.gz |
|---|---|
| Size | 25.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e5b70e46cef431051398e1d458d801a39982c7f6b0dc9b77c4d8ea221a5d39f2
|
|
BLAKE2b-256 checksum How to use checksums |
5d64f37f5016af281d7e305cafb680c5058e5e482350439a938d4b4553ae302e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.
Transparency logRelease files / matchbook_sdk-0.1.0-py3-none-any.whl
| Download URL | matchbook_sdk-0.1.0-py3-none-any.whl |
|---|---|
| Size | 34.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ad03f062e532c7084d4c2e3091c2d20037441c5e14f106d38af18b65dedd3ccd
|
|
BLAKE2b-256 checksum How to use checksums |
408fb8f14cf5423a70a6c531cf9dae84365daace9efdbbea664e089561165c7d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.
Transparency logSecurity for matchbook-sdk 0.1.0
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for matchbook_sdk-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.
Transparency logA 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.