binance_lite
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.
โจ Features
- Fetch candlestick market data (
open,high,low,close, timestamp, etc.) - Extract price history as
Vec<f64> - Minimal dependencies
- Asynchronous (uses
reqwest+tokio) - JSON serialization support
๐ฆ Installation
Add to your Cargo.toml:
[]
= "0.1.0"
(Replace with your crate version.)
๐ Quick Example
use MarketData;
async
๐ API Overview
MarketData::get_data_for(symbol, interval, limit) -> MarketData
Fetches candlestick data for:
symbol: market pair base (ex:"BTC")interval: Binance interval string ("1m","5m","1h","1w", etc.)limit: number of candlesticks to fetch
MarketData::price() -> Vec<f64>
Extracts the price values (from newest โ oldest).
MarketData::serialize() -> Result<String>
Serializes the entire dataset into pretty JSON.
๐งช Testing
A built-in test validates that at least one candlestick is returned:
async