Skip to main content

Python SDK for the Heisenberg prediction-market intelligence API.

Project description

Heisenberg Python SDK

Python client for the Heisenberg prediction-market intelligence API — generated from the same spec snapshot as the TypeScript SDK, with the same resource model, venue abstraction, gating semantics, and streaming.

Read-only and synchronous (no async client yet). The REST client uses only the Python standard library (no required deps).

Install

pip install heisenberg_ai            # REST
pip install "heisenberg_ai[stream]"  # + real-time streaming (websocket-client)

Quickstart

from heisenberg import Heisenberg

hb = Heisenberg(token="…")  # or set HEISENBERG_TOKEN

# Free tier — no subscription needed.
markets = hb.polymarket.markets({"min_volume": 1000, "closed": False, "limit": 5}).page()
profile = hb.wallets.profile("0xabc…", {"window_days": 15}).page()

# Iterate a Query to auto-paginate every row.
for trade in hb.polymarket.trades({"condition_id": "0x…"}):
    ...

# Real-time trades (Polymarket only; needs the [stream] extra).
for trade in hb.stream.trades({"condition_id": "0x…"}):
    print(trade.get("price"), trade.get("side"))

Pagination & rate limits

Iterating a Query auto-paginates. The API is rate limited (≈50 req/window); each Page carries page.rate_limit ({"limit","remaining","reset"}, reset in seconds) so you can pace bulk .all() calls, and the client backs off by x-ratelimit-reset on a 429.

Two axes

  • Venueshb.polymarket, hb.kalshi, hb.hyperliquid; each exposes the capabilities the spec says it supports (hb.polymarket.supports("orderbook")).
  • Intelligencehb.wallets, hb.smart_money, hb.leaderboards, hb.markets, hb.sports, hb.audience, hb.social.

Escape hatch for anything not wrapped: hb.query(agent_id, params).

Gated endpoints

Sport/audience endpoints require a subscription and raise a typed PlanError (preserving the API message, plus .required_plan / .endpoint). hb.requires(agent_id) and hb.catalog() report the sport/audience add-on plans — but they are not an exhaustive pre-flight check: access is a property of your token, so some venues (e.g. Hyperliquid) and endpoints can still return PlanError. Always be ready to catch it.

Develop

python -m unittest discover -s tests

Generated code lives in heisenberg/_generated/ (produced by ../scripts/generate.mjs from ../spec/source). Never edit it by hand.

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

heisenberg_ai-1.0.0.tar.gz (23.0 kB view details)

Uploaded Source

Built Distribution

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

heisenberg_ai-1.0.0-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

Details for the file heisenberg_ai-1.0.0.tar.gz.

File metadata

  • Download URL: heisenberg_ai-1.0.0.tar.gz
  • Upload date:
  • Size: 23.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for heisenberg_ai-1.0.0.tar.gz
Algorithm Hash digest
SHA256 4b88b0317b4e5f1b8961e92e907639b8a8087a9f408d11f15033e107c5bbcdd2
MD5 a6f485dd137c6f08530c4682d6815ec1
BLAKE2b-256 f6c0d838d617973c42daaf8968ca863e36507ccaa14bb60d602553c304950165

See more details on using hashes here.

Provenance

The following attestation bundles were made for heisenberg_ai-1.0.0.tar.gz:

Publisher: release.yml on SeshatLabs/heisenberg-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 heisenberg_ai-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: heisenberg_ai-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 21.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for heisenberg_ai-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fe3902dc79f5f3ea30cc0bb23485279c706c435d8a6cd414a6843910f226b0b1
MD5 757ffda317f03c6ca7470617c14b421f
BLAKE2b-256 3a1a569c6e4e9a92fc4dc7e82b5a850e5a591d1eb0597f7d05653d5b439eb579

See more details on using hashes here.

Provenance

The following attestation bundles were made for heisenberg_ai-1.0.0-py3-none-any.whl:

Publisher: release.yml on SeshatLabs/heisenberg-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