Private
WebSocket API
Overview
The WebSocket API allows real-time communication with our platform. Use it to stream market data, subscribe to updates, and interact with the order book.
Key Identifier Types
The WebSocket API uses two primary identifier types throughout the trading system:
-
order_id: Unique identifier for individual limit orders. Generated as a 32-character hexadecimal string when a limit order is posted to the orderbook. Used for order management, cancellation, and tracking order lifecycle events.
-
trade_id: Unique identifier for executed trades. Generated as a 32-character hexadecimal string when a market order is filled against limit orders. Used for tracking individual trade executions and settlement records.
Relationship: Multiple trades can reference the same order_id when a single limit order is filled across multiple market orders (partial fills). Each trade execution generates a unique trade_id.
Key Timestamp Types
The WebSocket API uses two timestamp formats that are important to understand:
- timestamp_ms: Event wrapper timestamps in milliseconds (13 digits) - used for event ordering and processing
- timestamp: Data payload timestamps, usually in milliseconds (13 digits)
- creation_timestamp: Order/request creation times in seconds (10 digits)
Learn More: For detailed timestamp format explanations, see the Timestamp Formats section below.
Learn More: For detailed explanations and trading scenarios, see the Order ID vs Trade ID Guide.
| Environment | WebSocket URL |
|---|---|
| Staging | wss://staging.kyan.sh/ws |
| Production | wss://api.kyan.sh/ws |
Quick Start
- Connect to the WebSocket endpoint
- Authenticate with your API key (Authentication)
- Subscribe to market data channels (Commands)
- Monitor your trades and account state
- Execute trades via REST API while monitoring via WebSocket
Supported Markets
- Trading Pairs: BTC_USDC, ETH_USDC, ARB_USDC
- Base Tokens: BTC, ETH, ARB
- Instruments: Options and Perpetual Futures
Instrument Naming Format
Options
- Format:
{PAIR}-{MATURITY}-{STRIKE}-{TYPE} - Examples:
BTC_USDC-31OCT25-130000-C(BTC call option)ETH_USDC-31OCT25-4700-P(ETH put option)ARB_USDC-31OCT25-0d300-C(ARB call option with decimal strike)
Perpetuals
- Format:
{PAIR}-PERPETUAL - Examples:
BTC_USDC-PERPETUAL,ETH_USDC-PERPETUAL,ARB_USDC-PERPETUAL
Format Components
- PAIR:
{BASE}_{QUOTE}where BASE isBTC,ETH, orARBand QUOTE isUSDC - MATURITY:
DDMMMYYformat (e.g., "31OCT25" for October 31, 2025)- Months: JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC
- STRIKE: Integer for BTC/ETH, decimal notation with "d" for ARB (e.g.,
1d500for 1.5) - TYPE:
Cfor Call options,Pfor Put options
Available Channels
Channels are organized by their use in a trading workflow:
Market Data
Reference data — prices, rates, vol surface, instruments. See Market Data.
| Channel | Description | Guide |
|---|---|---|
index_price | Underlying asset price updates | Index Price |
instruments | Available instruments updates | Instruments |
funding | Funding rate updates (perps) | Funding |
interest_rate | Interest rate changes | Interest Rate |
iv | Implied volatility (SVI) surface | IV (SVI) |
Orderbook
Order lifecycle events — placements, cancellations, fills. See Orderbook.
| Channel | Description | Guide |
|---|---|---|
orderbook_perps | Perpetual order events | Orderbook Perps |
orderbook_options | Option order events | Orderbook Options |
orderbook_maker | Maker-specific order monitoring | Orderbook Maker |
Account
Account state, positions, fills, and risk events. See Account.
| Channel | Description | Guide |
|---|---|---|
account_state | Margin, equity, portfolio Greeks | Account State |
position | Per-position mark prices and Greeks | Position |
trade | Trade execution events | Trade |
transfer | Deposit and withdrawal events | Transfer |
account_liquidation | Account liquidation events | Account Liquidation |
bankruptcy | Insurance fund loss events | Bankruptcy |
mmp | Market Maker Protection freeze events | MMP |
Trading
Specialized trading workflows. See Trading.
| Channel | Description | Guide |
|---|---|---|
rfq | Request-for-quote (block trades) | RFQ |
Event Types
When subscribed to channels, you'll receive events with the following types:
| Event Type | Description | Associated Channel |
|---|---|---|
index_price | Index price update | index_price |
instruments | Instruments list update | instruments |
post_order | New order posted | orderbook_options, orderbook_perps, orderbook_maker |
cancel_order | Order cancellation | orderbook_options, orderbook_perps, orderbook_maker |
update_order | Order fill status update | orderbook_options, orderbook_perps, orderbook_maker |
ob_maker_orders | Maker orders snapshot | orderbook_maker |
trade | Trade execution | trade |
deposit | Deposit to account | transfer |
withdrawal | Withdrawal from account | transfer |
funding | Funding rate update | funding |
interest_rate | Interest rate update | interest_rate |
svi | Stochastic Volatility update | iv |
rfq_request | New RFQ request | rfq |
rfq_post_response | New response to RFQ | rfq |
rfq_cancel_response | Cancelled RFQ response | rfq |
account_state | Account state update | account_state |
position | Position update | position |
account_liquidation | Liquidation event | account_liquidation |
bankruptcy | Account bankruptcy event | bankruptcy |
mmp_triggered | MMP triggered event | mmp |
Timestamp Formats
WebSocket events use consistent timestamp formatting across all message types:
Event Wrapper Timestamps:
timestamp_ms: Event generation time in milliseconds (Unix timestamp)- Format: 13-digit number (e.g.,
1677721600000) - Location: Present in all event and response wrappers
Data Payload Timestamps:
timestamp: Data-specific timestamp, usually in millisecondscreation_timestamp: Order/request creation time in seconds (Unix timestamp)- Format: Varies by field type:
timestamp: 13-digit number (milliseconds) - e.g.,1677721600000creation_timestamp: 10-digit number (seconds) - e.g.,1677721600
Examples:
{
"kind": "event",
"type": "trade",
"timestamp_ms": 1677721600000,
"data": {
"timestamp": 1677721600000,
"creation_timestamp": 1677721600
}
}Important Notes:
- Always use
timestamp_msfor event processing and ordering - Parse
creation_timestampas seconds when working with order lifecycle data - All timestamps are UTC with no timezone offset
Public Channels (No Auth Required)
For unauthenticated market data streams (L2 orderbook, BBO, trades, index prices, candles) via Centrifugo, see the Public API.
Related Guides
- Order ID vs Trade ID - Understanding order and trade identifier lifecycle
- API Key Guide - Obtaining and configuring API keys
- EIP-712 Signatures - Signing orders and trading operations
- Funding Rate Specification - Perpetual funding mechanics
Next Steps
- Authentication - Connect and authenticate
- Commands - Subscribe, query instruments, and manage subscriptions
- Connection Management - Reconnection, error handling, rate limits
Updated 5 days ago
