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:

Public channels

Authenticated channels

SubscriptionOptions

Unsubscribing

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.