Typed, concurrency-optimized Python client for the Pytheum API — the verified Kalshi × Polymarket prediction-market graph, live prices, and real-time context.
Project description
pytheum-sdk — Python SDK for Pytheum
A typed, concurrency-optimized Python client for the pytheum REST API: the settlement-verified cross-venue prediction-market graph (Kalshi × Polymarket), live prices, and real-time context. The same 27 capabilities the MCP server exposes, as a library.
# from GitHub today (PyPI release pending):
pip install "git+https://github.com/pytheum/pytheum-sdk"
# once published:
pip install pytheum-sdk # httpx is the only runtime dep
Quickstart
import asyncio
from pytheum_sdk import AsyncClient
async def main():
async with AsyncClient() as px: # single pooled client
st = await px.status()
print(st["equivalence"]["pairs_loaded"]) # 142_941
# the arb radar — matched pairs ranked by executable, fee-netted edge
radar = await px.find_divergences(limit=20)
# fan out safely: the governor bounds real in-flight requests
refs = [p["kalshi"]["id"] for p in radar["pairs"]]
cores = await px.get_markets(refs) # concurrent, rate-safe
asyncio.run(main())
Synchronous is a first-class, real client (not asyncio-wrapped):
from pytheum_sdk import Client
with Client() as px:
for m in px.search("bitcoin", limit=10)["markets"]:
print(m["question"], m["volume_usd"])
CLI
Installing the package also gives you a command line (pytheum-sdk, or the short
psdk) over the same client — great for quick looks, ops, and shell pipelines:
$ pytheum-sdk status
$ pytheum-sdk matched --sort net_edge --limit 20
$ pytheum-sdk divergences # the live arb radar
$ pytheum-sdk get kalshi:KXBTC-26 polymarket:2702984 # hydrated concurrently
$ pytheum-sdk search bitcoin --json | jq '.markets[0]'
Default output is a compact, aligned view (TTY-aware); --json emits raw payloads for
piping. Global flags: --json, --base-url, --concurrency, --timeout.
Why it's production-grade
- Connection pooling — one reused
httpxclient per instance. - Concurrency governor — an in-flight semaphore (default 8) keeps a caller inside the API's per-IP envelope while maximizing throughput; fan out freely.
- Transparent resilience — bounded retries with exponential backoff + full jitter;
429s honor
Retry-After; timeouts / 5xx retried. Your code rarely sees a transient error. - Typed — every route is a typed method; optional dataclass models via
pytheum_sdk.models. - Lean —
import pytheum_sdkpulls no server code; httpx + stdlib only.
Typed responses (optional)
Methods return the parsed JSON payload (forward-compatible; new API fields just appear). For typed, attribute-access objects, wrap a payload in a model:
from pytheum_sdk import Client, models
st = models.Status.from_dict(Client().status())
st.equivalence_pairs_loaded # 142_941
st.platforms["kalshi"].markets # typed; st.raw keeps the original dict
from_dict is lenient: unknown keys are ignored, missing keys tolerated, and the full
original payload is preserved on .raw.
Tuning
AsyncClient(
base_url="https://api.pytheum.com",
max_concurrency=8, # in-flight governor
max_retries=3, # per request
connect_timeout=5.0, read_timeout=30.0,
max_connections=20, max_keepalive=10,
)
Errors
All derive from PytheumError:
RateLimitError (429, carries .retry_after), NotFoundError (404),
AuthError (401/403), ServerError (5xx), PytheumTimeout, ConnectionFailed, and
the base APIError (carries .status, .body, .hint).
Surface
Meta: status · quality · about · guide.
Discovery: search · screen · get_market.
Cross-venue graph: equivalents · matched_pairs · find_divergences · related · rules.
Context: context · bundle_context · context_batch · event_related_markets.
Market data: orderbook · trades · ohlcv · open_interest · history · flow.
Trader intel: leaderboard · trader · holders · whale_trades.
Batch helpers: gather · get_markets · equivalents_many.
The public edge is keyless (per-IP rate-limited); pass api_key=... only if your account
requires one.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytheum_sdk-0.1.0.tar.gz.
File metadata
- Download URL: pytheum_sdk-0.1.0.tar.gz
- Upload date:
- Size: 45.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e255edbbad042193d14358f9f3b39d14a0b77cc724a858b386f66774e28260e9
|
|
| MD5 |
88b88c32687542dcb01063b227e87531
|
|
| BLAKE2b-256 |
19c0407090c48b8ad334300be8fe7d7747ae00e5eb95db3e5eb75b2c03199733
|
File details
Details for the file pytheum_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pytheum_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 24.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e5407049ab1d3c5dcb4f0385258fa8cb6f9c7d1981e7cd9f006a561c7ed9208
|
|
| MD5 |
1fef74f4ef4d1e7e8e661439c8c281fd
|
|
| BLAKE2b-256 |
5d1cd4c1e472502622b8ca7885f5762bfb9a9ca082f8dfedf4570c371f6fde2f
|