Skip to main content

chainstream_sdk/stream/
mod.rs

1//! WebSocket Stream API for real-time data subscriptions
2//!
3//! This module provides real-time streaming capabilities using the Centrifuge protocol.
4//!
5//! # Example
6//!
7//! ```rust,no_run
8//! use chainstream_sdk::stream::{StreamApi, TokenCandle};
9//!
10//! #[tokio::main]
11//! async fn main() {
12//!     let api = StreamApi::new(
13//!         "wss://realtime-dex.chainstream.io/connection/websocket",
14//!         "your-access-token",
15//!     );
16//!
17//!     // Connect to the WebSocket server
18//!     api.connect().await.unwrap();
19//!
20//!     // Subscribe to token candles
21//!     let unsub = api.subscribe_token_candles(
22//!         "sol",
23//!         "So11111111111111111111111111111111111111112",
24//!         "1s",
25//!         |candle: TokenCandle| {
26//!             println!("Candle: {:?}", candle);
27//!         },
28//!         None,
29//!     ).await.unwrap();
30//!
31//!     // Later: unsubscribe
32//!     // unsub.unsubscribe();
33//! }
34//! ```
35
36mod client;
37mod fields;
38mod models;
39
40pub use client::{StreamApi, StreamCallback, Unsubscribe};
41pub use fields::{get_available_fields, get_field_mappings, replace_filter_fields};
42pub use models::*;