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.

EnvironmentWebSocket URL
Stagingwss://staging.kyan.sh/ws
Productionwss://api.kyan.sh/ws

Quick Start

  1. Connect to the WebSocket endpoint
  2. Authenticate with your API key (Authentication)
  3. Subscribe to market data channels (Commands)
  4. Monitor your trades and account state
  5. 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 is BTC, ETH, or ARB and QUOTE is USDC
  • MATURITY: DDMMMYY format (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., 1d500 for 1.5)
  • TYPE: C for Call options, P for 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.

ChannelDescriptionGuide
index_priceUnderlying asset price updatesIndex Price
instrumentsAvailable instruments updatesInstruments
fundingFunding rate updates (perps)Funding
interest_rateInterest rate changesInterest Rate
ivImplied volatility (SVI) surfaceIV (SVI)

Orderbook

Order lifecycle events — placements, cancellations, fills. See Orderbook.

ChannelDescriptionGuide
orderbook_perpsPerpetual order eventsOrderbook Perps
orderbook_optionsOption order eventsOrderbook Options
orderbook_makerMaker-specific order monitoringOrderbook Maker

Account

Account state, positions, fills, and risk events. See Account.

ChannelDescriptionGuide
account_stateMargin, equity, portfolio GreeksAccount State
positionPer-position mark prices and GreeksPosition
tradeTrade execution eventsTrade
transferDeposit and withdrawal eventsTransfer
account_liquidationAccount liquidation eventsAccount Liquidation
bankruptcyInsurance fund loss eventsBankruptcy
mmpMarket Maker Protection freeze eventsMMP

Trading

Specialized trading workflows. See Trading.

ChannelDescriptionGuide
rfqRequest-for-quote (block trades)RFQ

Event Types

When subscribed to channels, you'll receive events with the following types:

Event TypeDescriptionAssociated Channel
index_priceIndex price updateindex_price
instrumentsInstruments list updateinstruments
post_orderNew order postedorderbook_options, orderbook_perps, orderbook_maker
cancel_orderOrder cancellationorderbook_options, orderbook_perps, orderbook_maker
update_orderOrder fill status updateorderbook_options, orderbook_perps, orderbook_maker
ob_maker_ordersMaker orders snapshotorderbook_maker
tradeTrade executiontrade
depositDeposit to accounttransfer
withdrawalWithdrawal from accounttransfer
fundingFunding rate updatefunding
interest_rateInterest rate updateinterest_rate
sviStochastic Volatility updateiv
rfq_requestNew RFQ requestrfq
rfq_post_responseNew response to RFQrfq
rfq_cancel_responseCancelled RFQ responserfq
account_stateAccount state updateaccount_state
positionPosition updateposition
account_liquidationLiquidation eventaccount_liquidation
bankruptcyAccount bankruptcy eventbankruptcy
mmp_triggeredMMP triggered eventmmp

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 milliseconds
  • creation_timestamp: Order/request creation time in seconds (Unix timestamp)
  • Format: Varies by field type:
    • timestamp: 13-digit number (milliseconds) - e.g., 1677721600000
    • creation_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_ms for event processing and ordering
  • Parse creation_timestamp as 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

Next Steps