Expand description
ยงPyth Price Feed API Wrapper (Rust)
A high-performance, async Rust SDK to query and stream live crypto prices using the Pyth Hermes API.
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
#[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
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
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 feedsget_token_price_info(ids)
โ Get current price info for specific or all tokensget_live_price_stream(ids, callback)
โ Stream price updates and handle them with a callbackget_price_stream_for_duration(ids, duration_secs, tx)
โ Stream prices for a set durationsearch_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
Re-exportsยง
pub use client::get_live_price_stream;
pub use client::get_price_feeds;
pub use client::get_price_stream_for_duration;
pub use client::get_token_price_info;
pub use client::search_by_token_symbols;