Skip to main content

Overview

The Rust SDK provides a Socket.IO-based WebSocketClient for:
  • orderbook and trade streams
  • market and price updates
  • authenticated order, fill, position, and transaction streams
  • automatic reconnect with subscription replay

Setup

Create a WebSocket client from the root SDK client:
Or configure it directly:

Connect and disconnect

WebSocketConfig

Event handlers

Use on() for raw JSON handlers, once() for one-shot handlers, and off() to unregister:

Typed handlers

The SDK also provides typed event handlers:

Subscribing to channels

After connecting, subscribe to specific channels:
Authenticated channels are re-authenticated on every subscribe_* message against the handshake timestamp, which the server accepts for 30 seconds. Issue SubscribePositions, SubscribeOrderEvents and SubscribeTransactions immediately after connect(). To add one later, call ws.disconnect().await? then ws.connect().await? (the SDK signs a fresh timestamp on connect) before subscribing.
The server answers every subscribe_market_prices call, first or repeat, with one orderbookUpdate per CLOB slug carrying the full current book, including books with empty bids and asks. You do not need a REST call to seed local state. See Initial snapshot.

Public channels

Authenticated channels

SubscriptionOptions

Unsubscribing

The server has no generic unsubscribe. For subscribe_market_prices, re-emit the subscription with the remaining slug set; the server replaces the previous set:
For market lifecycle, use the dedicated channel:
ws.unsubscribe() in 1.1.0 emits an event the server does not handle and returns Err(LimitlessError::WebSocket("ack timeout after 5s")) while the server keeps streaming; avoid it.

Updating credentials

You can rotate credentials at runtime:
If the socket is already connected, the client reconnects automatically with the new credentials.

Auto-reconnect

When auto_reconnect is enabled, the client reconnects and replays saved subscriptions automatically.
The Rust client preserves normalized subscription options internally, so reconnects restore previous subscriptions without extra application code.