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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//! # Pyth Price Feed API Wrapper (Rust)
//!
//! A high-performance, async Rust SDK to query and stream live crypto prices using the [Pyth Hermes API](https://hermes.pyth.network/docs/).
//!
//! Built to provide a simpler way to interract with Pyth Hermes crypto price feeds. Search by symbols, get token prices and price streams.
//!
//! ## ✨ Features
//!
//! - Fetch live and historical token prices (price + EMA)
//! - Stream real-time price updates
//! - Filter tokens by human-readable symbols
//! - Powered by `reqwest`, `tokio`, `serde`, `futures`
//!
//! ## 📚 Examples
//!
//! ```rust,no_run
//! #[tokio::main]
//! async fn main() -> anyhow::Result<()> {
//! use simple_pyth_client_rs::*;
//! // Search for specific crypto/USD pairs
//! let symbols = vec!["BTC", "ETH", "USDC", "SOL", "USDT"];
//! let price_feeds = search_by_token_symbols(symbols).await?;
//! println!("{:?}", price_feeds);
//! Ok(())
//! }
//! ```
//!
//! ## 📂 Data Types
//!
//! ### PriceFeed
//!
//! ```rust
//! pub struct PriceFeed {
//! pub id: String,
//! pub attributes: Attr,
//! }
//!
//! pub struct Attr {
//! pub asset_type: String,
//! pub base: String,
//! pub description: String,
//! pub display_symbol: String,
//! pub generic_symbol: String,
//! pub quote_currency: String,
//! pub schedule: String,
//! pub symbol: String,
//! }
//! ```
//!
//! ### TokenPriceInfo
//!
//! ```rust
//! pub struct TokenPriceInfo {
//! pub name: String,
//! pub token_id: String,
//! pub token_symbol: String,
//! pub price_30s: f64,
//! pub price_1m: f64,
//! pub timestamp: i64,
//! pub fluctuation_pct: f64,
//! }
//! ```
//!
//! ## 🔧 Core Methods
//!
//! - `get_price_feeds()` — Get metadata for all supported crypto/USD price feeds
//! - `get_token_price_info(ids)` — Get current price info for specific or all tokens
//! - `get_live_price_stream(ids, callback)` — Stream price updates and handle them with a callback
//! - `get_price_stream_for_duration(ids, duration_secs, tx)` — Stream prices for a set duration
//! - `search_by_token_symbols(symbols)` — Search and fetch prices using readable token symbols
//!
//! ## ✅ Requirements
//!
//! - Rust 1.70+
//! - Tokio async runtime
//!
//! ## 📅 License
//!
//! MIT
//!
//! ---
//!
//! Built with ❤️ by [Joshthebuilda](https://joshuaokechukwu.vzy.io/)
pub use ;