Skip to main content

predxt

CI PyPI Python License: MIT

Read-only market-data ingestion for prediction market builders.

predxt streams websocket data and reads REST market-data snapshots from Polymarket, Kalshi, and Opinion. It is built for dashboards, recorders, research tools, monitoring agents, market scanners, and orderbook visualizations. It is not a trading, execution, account, or financial-advice library.

Install

pip install predxt

For local development:

uv sync --group dev
uv run pytest -q -s

60-second Polymarket demo

Polymarket market websockets are public. Use any valid Polymarket CLOB asset id:

predxt stream polymarket --asset-id 1234567890 --limit 5 --jsonl

Or from Python:

import asyncio

from predxt.polymarket import PolymarketWsClient


async def main() -> None:
    client = PolymarketWsClient()
    await client.connect()
    await client.subscribe(
        ["market"],
        {"assets_ids": ["1234567890"], "initial_dump": True},
    )

    async for message in client.messages():
        print(message.event_type, message.asset_id, message.raw_data)
        break

    await client.close()


asyncio.run(main())

Venue matrix

Venue Public stream REST market data Auth Current support
Polymarket Yes Yes None for public market data books, price changes, trades, market search/detail, orderbook snapshots
Kalshi No Yes signed headers for authenticated paths orderbook snapshots/deltas, market search/detail, orderbook snapshots
Opinion No Yes API key depth diffs, last price/trade, market list/detail, orderbook snapshots

API contract

Core imports:

from predxt import (
    OrderBookState,
    VenueMessage,
    typed_event_from_message,
)

Venue imports:

from predxt.polymarket import (
    PolymarketRestClient,
    PolymarketSubscriptionConfig,
    PolymarketWsClient,
)
from predxt.kalshi import (
    KalshiRestClient,
    KalshiWsClient,
    build_kalshi_auth_headers,
)
from predxt.opinion import (
    OpinionRestClient,
    OpinionSubscriptionConfig,
    OpinionWsClient,
)

Every client emits VenueMessage objects with:

  • venue
  • event_type
  • market_id
  • asset_id
  • timestamp_ms
  • received_at_ms
  • raw_data

Use typed_event_from_message(message) when you want dataclass events such as OrderBookSnapshot, OrderBookDelta, TradeEvent, or PriceChangeEvent. Use OrderBookState when you need a small in-memory orderbook helper.

REST clients expose read-only market-data methods:

from predxt.polymarket import PolymarketRestClient

client = PolymarketRestClient()
markets = await client.search_markets("weather", limit=5)
book = await client.get_orderbook("CLOB_TOKEN_ID")
await client.close()

Connection managers own their background websocket reader. Use their public start() and stop() methods for lifecycle management; stop() also handles idle streams and is safe to call before start() or more than once. Consumers do not need to access private task attributes.

CLI

Offline parser demo:

predxt parse-fixture --venue polymarket --jsonl tests/fixtures/polymarket_order_books.json

Live streams:

predxt stream polymarket --asset-id 1234567890 --limit 10 --jsonl
KALSHI_KEY_ID=... KALSHI_PRIVATE_KEY_PATH=... predxt stream kalshi --market MARKET-TICKER
OPINION_API_KEY=... predxt stream opinion --market-id 2764

Examples

This repository keeps minimal examples in examples/. Public showcase starters:

What this is not

predxt does not place orders, derive trading credentials, manage positions, execute strategies, bypass venue restrictions, or provide financial advice. It is a read-only market-data SDK. Keep credentials in environment variables or a secret manager; never hard-code them in examples or agent prompts.

Documentation

Development

uv sync --group dev
uv run ruff check .
uv run mypy
uv run pytest -q -s
uv build
uv run twine check dist/*

Release

Releases use SemVer and tags like v0.1.0. See docs/releasing.md.

Download files

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

Source Distribution

predxt-0.2.2.tar.gz (62.7 kB view details)

Uploaded Source

Built Distribution

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

predxt-0.2.2-py3-none-any.whl (37.3 kB view details)

Uploaded Python 3

File details

Details for the file predxt-0.2.2.tar.gz.

File metadata

  • Download URL: predxt-0.2.2.tar.gz
  • Upload date:
  • Size: 62.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for predxt-0.2.2.tar.gz
Algorithm Hash digest
SHA256 120cc93cd8f68f062e1dfe3de5ba471616e8f9327c21d7de8e3a34fc6f143916
MD5 c15f3ed4acb4a163895493ccbfd7593e
BLAKE2b-256 c21ceba2e134f80f9817fde62c984b194e524b8a2b7744043f851cab998646aa

See more details on using hashes here.

Provenance

The following attestation bundles were made for predxt-0.2.2.tar.gz:

Publisher: release.yml on hzprotocol/predxt

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

File details

Details for the file predxt-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: predxt-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 37.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for predxt-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8124965b5ac7031cb59bb164d226baae52ef4fcb85ffcf04e53f5fc5c7f993af
MD5 69b4bd85a8a0b4c1f74ae92ff3778643
BLAKE2b-256 95e209592c11e442918acf14d553406aca030b25e3562df716be226482a42f1b

See more details on using hashes here.

Provenance

The following attestation bundles were made for predxt-0.2.2-py3-none-any.whl:

Publisher: release.yml on hzprotocol/predxt

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

Release history Release notifications | RSS feed

0.3.0

2 files

This release

0.2.2 This release

2 files

0.2.1

2 files

0.2.0

2 files

0.1.0

2 files

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