Skip to main content
The Yellow.pro WebSocket API provides real-time data streams, order notifications, account updates, and authenticated subscription access. All connections use a single endpoint:
Both authenticated and unauthenticated connections are supported. Unauthenticated connections can subscribe to public market data; authenticated connections additionally receive private account, order, and balance notifications. All messages are JSON.

Connecting

Every WebSocket connection — authenticated or not — must send a connect command immediately after the socket opens. This handshake establishes the session before any subscriptions or notifications are delivered.

Connection Requirements

  • Protocol: WebSocket (RFC 6455)
  • Authentication: Optional (token-based or header-based)
  • Reconnection: Automatic with exponential backoff (see Connection management)
  • Message format: JSON (the server may batch multiple JSON objects per frame, see Message batching)

Connect Handshake (Required)

Send an unauthenticated connect command right after the socket opens:
Success response:
A bare WebSocket connection that does not send the connect handshake will be closed by the server with error 3501 (bad request).

Authentication

To receive private notifications, authenticate the connection. Two methods are available.

Message format

All WebSocket messages follow a consistent JSON structure.

Outbound messages (client → server)

Each outbound command carries a unique, incrementing id and a single action object (connect, subscribe, or unsubscribe).

Inbound messages (server → client)

Response messages echo the request id:
Push notifications carry no id and are wrapped in a push envelope:

Message batching

The server may send multiple JSON objects in a single WebSocket frame, separated by newlines (NDJSON / newline-delimited JSON):
Calling JSON.parse(message) directly on a batched frame throws a SyntaxError. Split the frame by newline and parse each line individually:

Subscriptions

After a successful authenticated handshake, you are automatically subscribed to your private notification channel — no explicit subscribe is required. Public channels must be subscribed to explicitly (see Subscription management).

Private channel name format

  • Pattern: private.{wallet_address}
  • Example: private.0x1234567890abcdef1234567890abcdef12345678
All private notifications (account, order, balance, transfer events) are delivered on this single channel; the event type inside data.header distinguishes them.

Private channels

Private notifications are pushed on private.{wallet_address} for authenticated connections. Each notification carries a header with metadata and a type identifying the event.

Perpetuals account update

Account-level aggregate metrics for perpetuals (cross-margin). Pushed on balance/position changes (event-triggered) and periodically (timer-driven, default every 3s) for price-driven equity updates. Notification type: perpetuals_account.account_update

Perpetuals balance update

Real-time updates on perpetuals account balance changes for a specific collateral asset. Notification type: perpetuals_account.balance_update

Perpetuals position update

Real-time updates on perpetuals position snapshots (size, margin, leverage-related fields). Pushed on position open and on each fill, and after a successful leverage change for that market (one update per open leg). Not pushed on mark price changes alone. Notification type: perpetuals_account.position_update

Perpetuals funding payment

Emitted when a funding settlement is applied to an open position. Notification type: perpetuals_account.funding_payment

Perpetuals liquidation warning

Real-time warning for cross-margin perpetual accounts. Sent when the danger ratio reaches configured thresholds. Notification type: perpetuals_account.liquidation_warning
Trigger rules:
  • >= 80%: triggers once when crossing into this band; resets only after the ratio drops below 75%
  • >= 90%: triggers once when crossing into this band; resets only after the ratio drops below 85%
  • >= 95%: crossing can trigger a popup with a minimum 10m interval between popups; hourly reminders continue while still >= 95%
  • < 95%: final-level hourly reminders stop (clear by state/absence; no separate cleared event)
  • >= 100%: no warning popup (liquidation path takes priority)

Order updates

Real-time notifications for order state changes, delivered via two types: order.updated and order.cancelled.
Clients must listen for both order.updated and order.cancelled to receive all order notifications. Spot order notifications identify the order with order_id; perpetual order notifications use uuid.

order.updated — order state changes

Sent when an order is created, partially filled, or fully filled. Perpetual order example:
Spot order example:

order.cancelled — order cancellation

Sent when an order is cancelled. This is a separate event type from order.updated.

Order expiration

Notification for an expired order. Notification type: order.expired

Spot account state update

Real-time notification for spot account state changes (opened, closed, etc.). Notification type: spot_account.state_update

Spot balance update

Real-time updates on spot account balance changes for a specific asset. Delivered on the spot_account.balance_update channel. Notification type: spot_account.balance_update

Spot funds deposited

Notification when funds are successfully deposited into a spot account. Notification type: spot_account.funds_deposited

Spot withdrawal accepted

Notification when a withdrawal request is accepted and funds are reserved. Notification type: spot_account.withdrawal_accepted

Spot withdrawal completed

Notification when a withdrawal is successfully completed. Notification type: spot_account.withdrawal_completed

Spot withdrawal failed

Notification when a withdrawal attempt fails and funds are returned to the available balance. Notification type: spot_account.withdrawal_failed

Funds transferred (spot ↔ perpetuals)

Real-time notification when funds are transferred between spot and perpetuals accounts. Delivered on the transfer_updates channel. The notification is pushed when the transfer reaches a terminal or failure-relevant state. Notification type: account.funds_transferred
Failed transfer example:
After a successful transfer you will also receive spot_account.balance_update and perpetuals_account.balance_update notifications reflecting the updated balances on both sides.

Public channels

Public channels are available to all connections (authenticated or not) and must be subscribed to explicitly.

Mark price

Real-time mark price updates for a market. Channel pattern: public.mark_price.{MARKET} Subscribe:
Push notification:

Order book (incremental)

Real-time order book changes. Subscribing returns an initial snapshot followed by incremental updates. Channel pattern: public.orderbook.increment.{MARKET} Subscribe:
Initial snapshot response:
Incremental update:
Updates are aggregated within a short window (default 20ms): multiple changes to the same price level within a window are merged into the final state, and clients receive roughly 50 updates per second. A level set to 0 amount has been removed. Sequence numbers stay monotonically increasing — treat any gap as a reason to resubscribe.

Trade stream (snapshot + increment)

Aggregated trade executions for a market. Each subscription receives a snapshot followed by incremental updates with guaranteed sequence continuity. Channel pattern: public.trades.increment.{MARKET} Subscribe:
Snapshot response:
Incremental update:
Every subscription starts with a snapshot whose sequence_num matches the most recent increment. Sequence numbers are contiguous; if a gap or duplicate is detected, the server rebuilds and broadcasts a fresh snapshot. Treat any missing sequence number as invalid and resubscribe. Default snapshot depth is 50 aggregated entries per market.

24h ticker

24-hour ticker statistics for all markets. Channel: public.tickers.24h Subscribe:
Push notification:

Kline / candlestick

Real-time kline (candlestick) data for a market and interval. Channel pattern: public.kline.{MARKET}.{INTERVAL} Available intervals: 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 3d, 1w, 1M Subscribe:
Push notification:
The kline array is positional:

Subscription management

Subscribe to and unsubscribe from channels with subscribe / unsubscribe commands.
Each subscribe/unsubscribe message must use a unique, incrementing id (n+1). The id lets you match each request to its response.

Subscribe

Request:
Success response:
Error response:

Unsubscribe

Request:
Success response:

Connection management

Ping / pong

The server sends periodic ping frames to maintain connection health; clients respond with pong frames.
  • Ping interval: 5 minutes
  • Pong timeout: 5 minutes

Reconnection

Implement automatic reconnection with exponential backoff:
  • Initial delay: 1 second
  • Maximum delay: 60 seconds
  • Backoff multiplier: 2

Connection recovery

The WebSocket API supports recovery on reconnect:
  • Message positioning: resume from the last received message
  • Automatic resubscription: previous subscriptions are restored
  • State synchronization: account state is synchronized on reconnection

Order placement

Placing and canceling orders over WebSocket is not available. Use the REST API instead: Order notifications (order.updated, order.cancelled, order.expired) are still delivered over WebSocket on your private channel — see Order updates.

Error handling

Common error codes

Authentication errors:
  • 401 — Authentication failed or token invalid
  • 403 — Insufficient permissions for the requested operation
Subscription errors:
  • 400 — Invalid channel name or subscription parameters
  • 404 — Channel not found or not available
  • 409 — Already subscribed to the channel

Error message format

All error responses include structured error information:

Rate limits

WebSocket connections are subject to rate limiting to ensure fair usage:
  • Connection limit: 5 concurrent connections per user
  • Subscription limit: 100 active subscriptions per connection
  • Message rate limit: 100 messages per second per connection
Rate limiting violations result in connection termination.