Channels
Use the SDK channel helpers to avoid formatting mistakes.
Connect and subscribe
- TypeScript
- Python
- Rust
subscribe() returns only after the server responds.
Partial acceptance
A subscription acknowledgement can accept some channels and reject others. Always inspect both lists:channelscontains the accepted channels that the SDK will restore after reconnectrejectedcontains{ channel, reason }entriesactive_subscriptionsis the resulting server-side count
Book events replace state
Every receivedperps_book event is a complete replacement snapshot. Replace the prior bids and asks; do not merge it as a delta.
A successful subscription acknowledgement confirms that the channel is active; it does not mean a book snapshot has already arrived. The managed cache returns no book until the first perps_book event. If startup requires state within a fixed readiness deadline, read the V3 perps orderbook and replace it with subsequent WebSocket snapshots.
The managed clients retain the latest complete book:
- TypeScript
- Python
- Rust
Reconnect and gaps
Automatic reconnect is enabled by default. After reconnect, the SDK resubscribes only the previously accepted channels and emits an explicit reconnect notice. The perps WebSocket does not replay messages missed while disconnected. Every reconnect notice setsgap_possible to true. Recover state as follows:
- ticker, BBO, statistics, and book consumers can wait for a fresh event or refetch the matching REST endpoint
- book consumers should discard the old book and wait for a new complete snapshot
- trades and klines consumers should use the V3 REST routes to fill the time interval if continuity matters
Backpressure and lag
Two different warnings can occur:- TypeScript
- Python
- Rust
Terminal closes
Authentication close code4401 and connection-cap close code 4429 are terminal. The SDK does not loop forever on credentials or account limits that require user action.
Correct the API key or close another connection before starting a new client.
Unknown messages
Additive protocol messages remain observable:- TypeScript:
message.type === 'unknown' - Python:
PerpsUnknownMessage - Rust:
PerpsMessage::Unknown
Unsubscribe and close
- TypeScript
- Python
- Rust

