Skip to main content

Module client

Module client 

Source
Expand description

WebSocket client for Bybit V5 with automatic reconnection and resubscription.

§Features

  • Connect to public or private WebSocket streams
  • Subscribe/unsubscribe topics
  • Automatic ping/pong heartbeat (20s)
  • Automatic reconnection with exponential backoff
  • Automatic re-subscription after reconnect
  • Implements futures::Stream for async iteration

§Example

use bybit_rust_api::ws::{WsClient, topics};
use futures_util::StreamExt;

let mut client = WsClient::connect("wss://stream.bybit.com/v5/public/linear").await?;
client.subscribe(vec![topics::orderbook(1, "BTCUSDT")]).await?;
while let Some(msg) = client.next().await {
    println!("{:?}", msg);
}

Structs§

WsClient
A WebSocket client for Bybit V5 streams with auto-reconnect.