Skip to main content

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) plus sent_at, received_at and latency_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 paginate utility 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() raises BetDexSocketError; 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 BaseListener and override on_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.2.1

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

Source distribution (sdist)

Source distribution for betdex 0.2.1
File Size Uploaded Provenance
betdex-0.2.1.tar.gz 33.3 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for betdex 0.2.1
File Interpreter ABI Platform
betdex-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 79.5 kB

Release files / betdex-0.2.1.tar.gz

Download URL betdex-0.2.1.tar.gz
Size 33.3 kB
Tags Source
SHA-256 checksum
How to use checksums
dc0dda960f69c5e46cee697255b9320fccc8b98bc149364420092bcde4523ae7
BLAKE2b-256 checksum
How to use checksums
6f34896cb766ad2973e6170b4197a1fb376d564dd465b11ebe347235d556fcb5
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 log

Release files / betdex-0.2.1-py3-none-any.whl

Download URL betdex-0.2.1-py3-none-any.whl
Size 46.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fe2c8c7dac287609a6f66d8670b404f092942ca9654eb43ba9733a2477a6fc63
BLAKE2b-256 checksum
How to use checksums
3b618f0624aeebfc3587e35f68ac90cd1267f8f9f0b1eb1a496f4bbf999723d8
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 log

Security for betdex 0.2.1

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.

Select from 2 files

Attestation for betdex-0.2.1.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 log

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