Skip to main content

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.

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 httpx client 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.
  • Leanimport pytheum_sdk pulls 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytheum_sdk-0.1.1.tar.gz (45.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytheum_sdk-0.1.1-py3-none-any.whl (24.5 kB view details)

Uploaded Python 3

File details

Details for the file pytheum_sdk-0.1.1.tar.gz.

File metadata

  • Download URL: pytheum_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 45.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pytheum_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c51232064483aed6aad66407f89dd67e4cc5f46df64b3316756564243c32c786
MD5 6ea0cf6a0706162e95d7685def3d3e70
BLAKE2b-256 090f461e89167dbb6575311daf9273deceb0088a1a4c996b65b0c48235baa617

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytheum_sdk-0.1.1.tar.gz:

Publisher: publish.yml on pytheum/pytheum-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytheum_sdk-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pytheum_sdk-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 24.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pytheum_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3641038b05c87a662a4a3f45aae4af0fc6f75d7b6fd89b838bc3839140be0507
MD5 9dd5ced414612d91375e9d16b6c5aca6
BLAKE2b-256 59b48903d2ff310b9c43860d0ad7dd6a6d6dd13be70771b47858f84fd810f967

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytheum_sdk-0.1.1-py3-none-any.whl:

Publisher: publish.yml on pytheum/pytheum-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page