#cryptocurrency #blockchain #trading #websocket

crypto-ws-client

A versatile websocket client that supports many cryptocurrency exchanges

120 stable releases

4.12.11 Feb 26, 2023
4.12.9 Dec 28, 2022
4.12.8 Oct 31, 2022
4.11.8 Jul 10, 2022
0.4.0 Dec 31, 2020

#2052 in Magic Beans

Download history 21/week @ 2023-10-17 80/week @ 2023-10-24 303/week @ 2023-10-31 225/week @ 2023-11-07 15/week @ 2023-11-14 196/week @ 2023-11-21 474/week @ 2023-11-28 14/week @ 2023-12-05 191/week @ 2023-12-12 17/week @ 2023-12-19 370/week @ 2023-12-26 12/week @ 2024-01-02 16/week @ 2024-01-09 332/week @ 2024-01-16 32/week @ 2024-01-23 726/week @ 2024-01-30

1,108 downloads per month
Used in 2 crates (via crypto-crawler)

Apache-2.0

245KB
5.5K SLoC

crypto-ws-client

A versatile websocket client that supports many cryptocurrency exchanges.

Usage

use crypto_ws_client::{BinanceSpotWSClient, WSClient};

#[tokio::main]
async fn main() {
    let (tx, rx) = std::sync::mpsc::channel();
    tokio::task::spawn(async move {
        let symbols = vec!["BTCUSDT".to_string(), "ETHUSDT".to_string()];
        let ws_client = BinanceSpotWSClient::new(tx, None).await;
        ws_client.subscribe_trade(&symbols).await;
        // run for 5 seconds
        let _ = tokio::time::timeout(std::time::Duration::from_secs(5), ws_client.run()).await;
        ws_client.close();
    });

    for msg in rx {
        println!("{}", msg);
    }
}

Dependencies

~9–23MB
~347K SLoC