Overview
Connect to receive real-time orderbook data for a specific market, including initial snapshots and incremental updates.To avoid ambiguity, we denote the smallest possible multiple of USDC (0.000001 USDC) as one
uusdc,
which stands for µUSDC (micro-USDC), and denote the smallest possible multiple of a contract (0.01 contract)
as one ccontract (centicontract).User-facing USDC balances are specified as fixed-point strings (e.g. "1.2625" for USDC). Contract quantities
in the API and SDK are specified as integer ccontracts strings (e.g. "1050" for 10.50 contracts at precision 2).Connection
string
required
The Kalshi market ticker (e.g.,
KXBTC-100K-DEC31)Example Connection
Message Types
The Orderbook WebSocket sends two types of messages:Snapshot Message
Sent immediately upon connection, providing the complete current orderbook state.string
Always
"orderbook_snapshot"string
Market ticker for this orderbook
array
Array of YES side price levels, ordered by price
array
Array of NO side price levels, ordered by priceStructure is the same as
yes array.Delta Message
Sent for each orderbook change, providing an incremental update.string
Always
"orderbook_delta"string
Market ticker for this update
string
Either
"yes" or "no"string
Price level being updated (µUSDC integer string)
string
Change in ccontracts (integer string; positive for additions, negative for removals)
Maintaining Accurate State
To maintain an accurate orderbook:
- Initialize with the snapshot on connection
- Apply each delta by adding it to the current ccontracts at that price level
- Remove price levels when their ccontracts reaches zero or below
Example: Orderbook Display
Use Cases
Order Book Depth
Display full market depth with all price levels
Trading Interfaces
Build professional trading UIs with real-time order flow
Market Making
Monitor liquidity for algorithmic trading strategies
Price Discovery
Analyze order book imbalances and market sentiment
Best Practices
1
Initialize with Snapshot
Always start by processing the initial snapshot message to establish baseline state.
2
Apply Deltas Incrementally
Add delta values to existing ccontracts rather than replacing them.
3
Clean Up Zero Ccontracts
Remove price levels from your orderbook when their ccontracts reach zero or below.
4
Sort Price Levels
Sort bids descending and asks ascending for proper display.
5
Handle Reconnection
On reconnection, the snapshot will reset your state automatically.