Expand description
WebSocket Stream API for real-time data subscriptions
This module provides real-time streaming capabilities using the Centrifuge protocol.
§Example
use chainstream_sdk::stream::{StreamApi, TokenCandle};
#[tokio::main]
async fn main() {
let api = StreamApi::new(
"wss://realtime-dex.chainstream.io/connection/websocket",
"your-access-token",
);
// Connect to the WebSocket server
api.connect().await.unwrap();
// Subscribe to token candles
let unsub = api.subscribe_token_candles(
"sol",
"So11111111111111111111111111111111111111112",
"1s",
|candle: TokenCandle| {
println!("Candle: {:?}", candle);
},
None,
).await.unwrap();
// Later: unsubscribe
// unsub.unsubscribe();
}Re-exports§
pub use crate::openapi::types::Resolution;
Structs§
- DexPool
Balance - DEX pool balance data
- DexProtocol
- DEX protocol information
- NewToken
- New token data
- Ranking
Token List - Ranking token list data
- Social
Media - Social media links
- Stream
Api - Stream API client for real-time data subscriptions
- Token
Activity - Token activity data
- Token
Bonding Curve - Token bonding curve data
- Token
Candle - Token candlestick data
- Token
Holder - Token holder information
- Token
Liquidity - Token liquidity data
- Token
MaxLiquidity - Token max liquidity data (max liquidity in a single pool)
- Token
Metadata - Token metadata
- Token
Stat - Token statistics with multi-timeframe data
- Token
Supply - Token supply data
- Token
Total Liquidity - Token total liquidity data (total liquidity across all pools)
- Trade
Activity - Trade activity data
- Unsubscribe
- Unsubscribe handle
- Wallet
Balance - Wallet balance data
- Wallet
Pnl - Wallet profit and loss data
- Wallet
Token Pnl - Wallet token profit and loss data
Enums§
- Channel
Type - Channel type for subscriptions
- Dex
- DEX (Decentralized Exchange) type
- Metric
Type - Metric type for measurements
- Ranking
Type - Ranking type for token rankings
- Token
Activity Type - Token activity type
Functions§
- get_
available_ fields - Get available field names for a specific subscription method
- get_
field_ mappings - Get field mappings for a specific subscription method
- replace_
filter_ fields - Replace long field names with short field names in filter expressions Automatically adds meta. prefix if not present
Type Aliases§
- Stream
Callback - Callback type for stream subscriptions