1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//! ChainStream SDK for Rust
//!
//! This SDK provides a Rust client for interacting with the ChainStream API,
//! including both REST API and real-time WebSocket streaming capabilities.
//!
//! # Features
//!
//! - **REST API**: Auto-generated OpenAPI client for all ChainStream endpoints
//! - **Stream API**: Real-time WebSocket subscriptions using the Centrifuge protocol
//! - **Type-safe**: Strongly typed models for all API responses
//!
//! # Quick Start
//!
//! ```rust,no_run
//! use chainstream_sdk::{ChainStreamClient, stream::TokenCandle};
//!
//! #[tokio::main]
//! async fn main() {
//! // Create a client with your access token
//! let client = ChainStreamClient::new("your-access-token", None);
//!
//! // Subscribe to real-time token candles
//! let unsub = client.stream.subscribe_token_candles(
//! "sol",
//! "So11111111111111111111111111111111111111112",
//! "1s",
//! |candle: TokenCandle| {
//! println!("Open: {}, Close: {}", candle.open, candle.close);
//! },
//! None,
//! ).await.unwrap();
//!
//! // Keep the connection alive
//! tokio::time::sleep(tokio::time::Duration::from_secs(60)).await;
//!
//! // Unsubscribe when done
//! unsub.unsubscribe();
//!
//! // Close all connections
//! client.close().await;
//! }
//! ```
// Re-export main types at crate root
pub use ;
pub use ChainStreamError;
/// The default base URL for the ChainStream API
pub const CHAINSTREAM_BASE_URL: &str = "https://api.chainstream.io";
/// The default WebSocket URL for the ChainStream Stream API
pub const CHAINSTREAM_STREAM_URL: &str = "wss://realtime-dex.chainstream.io/connection/websocket";