| Crates.io | binance_lite |
| lib.rs | binance_lite |
| version | 1.0.1 |
| created_at | 2025-11-26 23:30:41.437963+00 |
| updated_at | 2025-11-26 23:38:30.392004+00 |
| description | A lightweight Binance API wrapper |
| homepage | |
| repository | https://github.com/blackh-t/binance_lite |
| max_upload_size | |
| id | 1952677 |
| size | 42,922 |
A lightweight Rust library for fetching market candlestick data from the Binance public API. Designed to be minimal, fast, and easy to integrate into trading bots or analytics tools.
open, high, low, close, timestamp, etc.)Vec<f64>reqwest + tokio)Add to your Cargo.toml:
[dependencies]
binance_lite = "0.1.0"
(Replace with your crate version.)
use binance_lite::MarketData;
#[tokio::main]
async fn main() {
// Fetch BTC weekly data (2 candlesticks)
let data = MarketData::get_data_for("BTC", "1w", 2).await;
// Extract prices
let prices = data.price();
println!("Prices: {:?}", prices);
// Serialize to JSON
let json = data.serialize().unwrap();
println!("As JSON:\n{}", json);
}
MarketData::get_data_for(symbol, interval, limit) -> MarketDataFetches candlestick data for:
symbol: market pair base (ex: "BTC")interval: Binance interval string ("1m", "5m", "1h", "1w", etc.)limit: number of candlesticks to fetchMarketData::price() -> Vec<f64>Extracts the price values (from newest โ oldest).
MarketData::serialize() -> Result<String>Serializes the entire dataset into pretty JSON.
A built-in test validates that at least one candlestick is returned:
#[tokio::test]
async fn test_market_data() {
let res = MarketData::get_data_for("BTC", "1w", 2).await;
assert!(!res.record.is_empty());
}