betdex
A Python client for the BetDEX Exchange API (REST and Stream).
- One typed method per endpoint on a single
BetDexClient - Responses are dataclasses; each keeps its raw JSON (
.raw) plussent_at,received_atandlatency_ms - A blocking stream with pluggable listeners.
pip install betdex
Quick Start
from betdex import BetDexClient
client = BetDexClient(app_id, api_key, wallet_id, environment="sandbox") # or "prod"
client.create_session()
markets = client.get_markets(statuses=["Open"], size=10).markets
live = [m for m in markets if m.is_in_play]
book = client.get_market_prices_v2(markets[0].id).prices[0]
best_back = book.available_to_back(outcome_id)[:1]
best_lay = book.available_to_lay(outcome_id)[:1]
Orders
from betdex.utils import batch, new_reference
order = client.create_order(market_id, outcome_id, "For", price=2.5, stake=10,
keep_when_in_play=False, reference=new_reference("bot_")).orders[0]
print(order.status, order.stake_matched, order.liability)
for result in batch(client.create_orders, requests): # 50 per call
...
client.cancel_orders(wallet_ids=[wallet_id])
Paging
- Many endpoints are paginated. A
paginateutility is supplied:
from betdex.utils import paginate
for page in paginate(client.get_markets, event_ids=["123"]):
...
Errors
- All errors derive from
BetDexError:
from betdex import BetDexAPIError, BetDexTransportError
try:
client.get_order("123")
except BetDexAPIError as exc: # error status: status_code, title, details, response
print(exc.status_code, exc.title, exc.latency_ms)
except BetDexTransportError as exc: # no response
print(exc, exc.latency_ms)
Streaming
import threading
from betdex.streaming import MarketBook, OrderUpdate, StreamListener
listener = StreamListener()
stream = client.create_stream(listener)
stream.subscribe_to_orders()
stream.subscribe_to_market_prices(["123"]) # or no argument for every market
threading.Thread(target=stream.start, daemon=True).start()
while True:
update = listener.output_queue.get()
if isinstance(update, MarketBook):
best_back = update.available_to_back(outcome_id)[:1]
elif isinstance(update, OrderUpdate):
filled = update.stake_matched
start()blocks;stop()ends it from any thread- On a dropped connection
start()raisesBetDexSocketError; call it again to reconnect and resubscribe - Updates missed while disconnected aren't replayed; catch up on orders with
get_orders - For raw frames, subclass
BaseListenerand overrideon_data(raw)
Execution
from betdex.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
Metadata
Release files for betdex 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 | |
|---|---|---|---|
| betdex-0.1.0.tar.gz | 32.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| betdex-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 77.9 kB
Release files / betdex-0.1.0.tar.gz
| Download URL | betdex-0.1.0.tar.gz |
|---|---|
| Size | 32.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2795cdb5be0dc601823cd350feb3e4511016d1af8420dee686836f9b2cfb04bf
|
|
BLAKE2b-256 checksum How to use checksums |
51326e9c35611dceebccdbef40ff7a2f1a0de54ee7dc76347f0d02ebf2ef142c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 9, 2026.
Transparency logRelease files / betdex-0.1.0-py3-none-any.whl
| Download URL | betdex-0.1.0-py3-none-any.whl |
|---|---|
| Size | 45.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
112afb58aab31f110495972e9bb34b180a7e544b92f406f3398301d1ba9fd03b
|
|
BLAKE2b-256 checksum How to use checksums |
31c6098cd26c272b6728477e2f98bbd151009cd525b9de9731711b202c4a47f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 9, 2026.
Transparency log