Skip to main content

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

  • Venues — hb.polymarket, hb.kalshi, hb.hyperliquid; each exposes the capabilities the spec says it supports (hb.polymarket.supports("orderbook")).
  • Intelligence — hb.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.

Metadata

Release files for heisenberg-ai 1.0.0

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

Source distribution (sdist)

Source distribution for heisenberg-ai 1.0.0
File Size Uploaded Provenance Actions
heisenberg_ai-1.0.0.tar.gz 23.0 kB With provenance Details for heisenberg_ai-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for heisenberg-ai 1.0.0
File Interpreter ABI Platform Actions
heisenberg_ai-1.0.0-py3-none-any.whl Python 3 none any Details for heisenberg_ai-1.0.0-py3-none-any.whl

Total release size: 44.6 kB

Release files / heisenberg_ai-1.0.0.tar.gz

Download URL heisenberg_ai-1.0.0.tar.gz
Size 23.0 kB
Tags Source
SHA-256 checksum
How to use checksums
4b88b0317b4e5f1b8961e92e907639b8a8087a9f408d11f15033e107c5bbcdd2
BLAKE2b-256 checksum
How to use checksums
f6c0d838d617973c42daaf8968ca863e36507ccaa14bb60d602553c304950165
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.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 Jul 20, 2026.

Transparency log

Release files / heisenberg_ai-1.0.0-py3-none-any.whl

Download URL heisenberg_ai-1.0.0-py3-none-any.whl
Size 21.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fe3902dc79f5f3ea30cc0bb23485279c706c435d8a6cd414a6843910f226b0b1
BLAKE2b-256 checksum
How to use checksums
3a1a569c6e4e9a92fc4dc7e82b5a850e5a591d1eb0597f7d05653d5b439eb579
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.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 Jul 20, 2026.

Transparency log

Security for heisenberg-ai 1.0.0

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 heisenberg_ai-1.0.0.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 Jul 20, 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