Skip to main content

Installation

Quick Start

See Market Data → Search Markets for the full list of filters. The SDK signs every REST request and WebSocket handshake locally with Ed25519. Your private key never leaves the process. See Authentication for the canonical-string spec if you need to verify what the SDK is producing.

Async Support

Trading

Place an Order

List Orders

Cancel an Order

Complex Orders

Complex orders let you place iceberg slices, pegged orders, smart-taker orders, and take-profit / stop-loss triggers. Pass exactly one of iceberg_order_params, peg_order_params, smart_taker_order_params, or conditional_order_params along with subaccount_id and either river_id or generic_asset_id. The endpoint returns 202 with the order in PENDING status — it’s activated asynchronously.

Iceberg

Peg

Smart Taker

Take-profit attached to a parent order

Standalone stop

  • Prices and limit_price are 0–1 (Kalshi-style probability), not dollars.
  • For TP/SL you must supply parent_river_order_id (or parent_complex_order_id to chain). For standalone STOP, omit parents and set stop_order_price.
  • TriggerOrder.price is required when order_type="LIMIT", omit for "MARKET".

Portfolio

Get Positions

Get Fills

Market Data

Search Markets

When using a free-text q=, always pair it with date filters (expiration_date_start, start_datetime_after/before) and status="active" — otherwise results include long-expired markets and the ranking is dominated by historical noise. See the Quick Start above for the recommended shape.

Parameters

q
string
Search query.
exchange_name
string
Filter by exchange name (KALSHI, POLYMARKET).
category
list[string]
Filter by canonical category. Pass a list to filter to multiple: Sports, Crypto, Politics, Finance, Entertainment, Science & Tech, Weather, World Affairs, Health, Social, Other.
subcategory
string
Filter by subcategory (e.g. Basketball, Football).
status
InstrumentStatus
Filter by instrument status. Defaults to active markets.
expiration_date_start
string (ISO 8601)
Start of expiration date range (inclusive).
expiration_date_end
string (ISO 8601)
End of expiration date range (exclusive).
start_datetime_after
string (ISO 8601)
Filter to markets with start_datetime >= this.
start_datetime_before
string (ISO 8601)
Filter to markets with start_datetime < this.
event_ticker
string
Filter by event_ticker (exact match).
sort_by
string
Sort mode for event-based pagination: trending, volume, newest, ending-soon, start-time.
limit
integer
default:"20"
Maximum number of results (1–1000).
offset
integer
default:"0"
Offset for pagination.
event_limit
integer
Paginate by events instead of markets. Up to 200 by default; values above that require start_datetime_after or start_datetime_before.
event_offset
integer
Event offset for event-based pagination.

Orderbook

Price History

Realtime (WebSockets)

The async client exposes three live data feeds at client.realtime. Each returns a Subscription you use as an async context manager and async iterator. Disconnects are handled transparently — the client reconnects and re-sends the active subscription set, so iteration just resumes. The underlying wire protocol is documented under WS API Reference.

Orderbook stream

You can mutate the subscription on the fly:

Order status stream

Order updates are pinned to one subaccount at handshake — there is no subscribe/unsubscribe frame.

Trade tape

Notes

  • All three subscriptions reconnect transparently on disconnect; the iterator simply pauses and resumes.
  • In Jupyter, drop asyncio.run(...) and use top-level await directly in a cell.
  • Subscription works as a context manager — exiting the async with block closes the socket cleanly.
  • Message.type is always set; endpoint-specific fields (data, river_id, orders, code, message) are accessed as attributes or via msg.model_extra.

Subaccounts

Error Handling

The SDK raises typed exceptions for API errors:

Configuration

GitHub

View the source code and contribute on GitHub.