Skip to main content

Market

Struct Market 

Source
pub struct Market { /* private fields */ }
Expand description

Market data API client.

Provides access to public market data endpoints.

Implementations§

Source§

impl Market

Source

pub async fn ping(&self) -> Result<()>

Test connectivity to the API.

§Example
let client = Binance::new_unauthenticated()?;
client.market().ping().await?;
Source

pub async fn server_time(&self) -> Result<ServerTime>

Get the current server time.

§Example
let client = Binance::new_unauthenticated()?;
let time = client.market().server_time().await?;
println!("Server time: {}", time.server_time);
Source

pub async fn exchange_info(&self) -> Result<ExchangeInfo>

Get exchange information (trading rules and symbol info).

§Example
let client = Binance::new_unauthenticated()?;
let info = client.market().exchange_info().await?;
for symbol in info.symbols {
    println!("{}: {}", symbol.symbol, symbol.status);
}
Source

pub async fn exchange_info_for_symbols( &self, symbols: &[&str], ) -> Result<ExchangeInfo>

Get exchange information for specific symbols.

§Arguments
  • symbols - List of symbols to get info for
§Example
let client = Binance::new_unauthenticated()?;
let info = client.market().exchange_info_for_symbols(&["BTCUSDT", "ETHUSDT"]).await?;
Source

pub async fn depth(&self, symbol: &str, limit: Option<u16>) -> Result<OrderBook>

Get order book depth.

§Arguments
  • symbol - Trading pair symbol (e.g., “BTCUSDT”)
  • limit - Number of entries to return. Valid limits: 5, 10, 20, 50, 100, 500, 1000, 5000. Default is 100; max is 5000.
§Example
let client = Binance::new_unauthenticated()?;
let depth = client.market().depth("BTCUSDT", Some(10)).await?;
for bid in depth.bids {
    println!("Bid: {} @ {}", bid.quantity, bid.price);
}
Source

pub async fn trades( &self, symbol: &str, limit: Option<u16>, ) -> Result<Vec<Trade>>

Get recent trades.

§Arguments
  • symbol - Trading pair symbol
  • limit - Number of trades to return. Default 500; max 1000.
§Example
let client = Binance::new_unauthenticated()?;
let trades = client.market().trades("BTCUSDT", Some(10)).await?;
Source

pub async fn historical_trades( &self, symbol: &str, from_id: Option<u64>, limit: Option<u16>, ) -> Result<Vec<Trade>>

Get older/historical trades.

This endpoint requires an API key but not a signature.

§Arguments
  • symbol - Trading pair symbol
  • from_id - Trade ID to fetch from
  • limit - Number of trades to return. Default 500; max 1000.
§Example
let client = Binance::new("api_key", "secret_key")?;
let trades = client.market().historical_trades("BTCUSDT", Some(12345), Some(100)).await?;
Source

pub async fn agg_trades( &self, symbol: &str, from_id: Option<u64>, start_time: Option<u64>, end_time: Option<u64>, limit: Option<u16>, ) -> Result<Vec<AggTrade>>

Get compressed/aggregate trades.

Trades that fill at the same time, from the same order, with the same price will have the aggregate quantity added.

§Arguments
  • symbol - Trading pair symbol
  • from_id - Aggregate trade ID to get from
  • start_time - Start time in milliseconds
  • end_time - End time in milliseconds
  • limit - Default 500; max 1000
§Example
let client = Binance::new_unauthenticated()?;
let trades = client.market().agg_trades("BTCUSDT", None, None, None, Some(10)).await?;
Source

pub async fn klines( &self, symbol: &str, interval: KlineInterval, start_time: Option<u64>, end_time: Option<u64>, limit: Option<u16>, ) -> Result<Vec<Kline>>

Get kline/candlestick data.

§Arguments
  • symbol - Trading pair symbol
  • interval - Kline interval
  • start_time - Start time in milliseconds
  • end_time - End time in milliseconds
  • limit - Default 500; max 1000
§Example
use binance_api_client::KlineInterval;

let client = Binance::new_unauthenticated()?;
let klines = client.market().klines("BTCUSDT", KlineInterval::Hours1, None, None, Some(10)).await?;
for kline in klines {
    println!("Open: {}, Close: {}", kline.open, kline.close);
}
Source

pub async fn ui_klines( &self, symbol: &str, interval: KlineInterval, start_time: Option<u64>, end_time: Option<u64>, limit: Option<u16>, ) -> Result<Vec<Kline>>

Get UI optimized kline/candlestick data.

This endpoint mirrors the /api/v3/klines response format.

§Arguments
  • symbol - Trading pair symbol
  • interval - Kline interval
  • start_time - Start time in milliseconds
  • end_time - End time in milliseconds
  • limit - Default 500; max 1000
§Example
use binance_api_client::KlineInterval;

let client = Binance::new_unauthenticated()?;
let klines = client
    .market()
    .ui_klines("BTCUSDT", KlineInterval::Hours1, None, None, Some(10))
    .await?;
Source

pub async fn avg_price(&self, symbol: &str) -> Result<AveragePrice>

Get current average price for a symbol.

§Arguments
  • symbol - Trading pair symbol
§Example
let client = Binance::new_unauthenticated()?;
let avg = client.market().avg_price("BTCUSDT").await?;
println!("Average price over {} mins: {}", avg.mins, avg.price);
Source

pub async fn ticker_24h(&self, symbol: &str) -> Result<Ticker24h>

Get 24hr ticker price change statistics.

§Arguments
  • symbol - Trading pair symbol
§Example
let client = Binance::new_unauthenticated()?;
let ticker = client.market().ticker_24h("BTCUSDT").await?;
println!("Price change: {}%", ticker.price_change_percent);
Source

pub async fn ticker_24h_all(&self) -> Result<Vec<Ticker24h>>

Get 24hr ticker price change statistics for all symbols.

§Example
let client = Binance::new_unauthenticated()?;
let tickers = client.market().ticker_24h_all().await?;
Source

pub async fn trading_day_ticker( &self, symbol: &str, time_zone: Option<&str>, symbol_status: Option<SymbolStatus>, ) -> Result<TradingDayTicker>

Get trading day ticker statistics (FULL).

§Arguments
  • symbol - Trading pair symbol
  • time_zone - Optional timezone (e.g., “0” or “-1:00”)
  • symbol_status - Optional symbol trading status filter
Source

pub async fn trading_day_ticker_mini( &self, symbol: &str, time_zone: Option<&str>, symbol_status: Option<SymbolStatus>, ) -> Result<TradingDayTickerMini>

Get trading day ticker statistics (MINI).

Source

pub async fn trading_day_tickers( &self, symbols: &[&str], time_zone: Option<&str>, symbol_status: Option<SymbolStatus>, ) -> Result<Vec<TradingDayTicker>>

Get trading day ticker statistics (FULL) for multiple symbols.

Source

pub async fn trading_day_tickers_mini( &self, symbols: &[&str], time_zone: Option<&str>, symbol_status: Option<SymbolStatus>, ) -> Result<Vec<TradingDayTickerMini>>

Get trading day ticker statistics (MINI) for multiple symbols.

Source

pub async fn rolling_window_ticker( &self, symbol: &str, window_size: Option<&str>, symbol_status: Option<SymbolStatus>, ) -> Result<RollingWindowTicker>

Get rolling window ticker statistics (FULL).

§Arguments
  • symbol - Trading pair symbol
  • window_size - Optional window size (e.g., “1d”, “15m”)
  • symbol_status - Optional symbol trading status filter
Source

pub async fn rolling_window_ticker_mini( &self, symbol: &str, window_size: Option<&str>, symbol_status: Option<SymbolStatus>, ) -> Result<RollingWindowTickerMini>

Get rolling window ticker statistics (MINI).

Source

pub async fn rolling_window_tickers( &self, symbols: &[&str], window_size: Option<&str>, symbol_status: Option<SymbolStatus>, ) -> Result<Vec<RollingWindowTicker>>

Get rolling window ticker statistics (FULL) for multiple symbols.

Source

pub async fn rolling_window_tickers_mini( &self, symbols: &[&str], window_size: Option<&str>, symbol_status: Option<SymbolStatus>, ) -> Result<Vec<RollingWindowTickerMini>>

Get rolling window ticker statistics (MINI) for multiple symbols.

Source

pub async fn price(&self, symbol: &str) -> Result<TickerPrice>

Get latest price for a symbol.

§Arguments
  • symbol - Trading pair symbol
§Example
let client = Binance::new_unauthenticated()?;
let price = client.market().price("BTCUSDT").await?;
println!("BTC/USDT: {}", price.price);
Source

pub async fn prices(&self) -> Result<Vec<TickerPrice>>

Get latest prices for all symbols.

§Example
let client = Binance::new_unauthenticated()?;
let prices = client.market().prices().await?;
for price in prices {
    println!("{}: {}", price.symbol, price.price);
}
Source

pub async fn prices_for(&self, symbols: &[&str]) -> Result<Vec<TickerPrice>>

Get latest prices for specific symbols.

§Arguments
  • symbols - List of symbols
§Example
let client = Binance::new_unauthenticated()?;
let prices = client.market().prices_for(&["BTCUSDT", "ETHUSDT"]).await?;
Source

pub async fn book_ticker(&self, symbol: &str) -> Result<BookTicker>

Get best price/qty on the order book for a symbol.

§Arguments
  • symbol - Trading pair symbol
§Example
let client = Binance::new_unauthenticated()?;
let ticker = client.market().book_ticker("BTCUSDT").await?;
println!("Best bid: {} @ {}", ticker.bid_qty, ticker.bid_price);
println!("Best ask: {} @ {}", ticker.ask_qty, ticker.ask_price);
Source

pub async fn book_tickers(&self) -> Result<Vec<BookTicker>>

Get best price/qty on the order book for all symbols.

§Example
let client = Binance::new_unauthenticated()?;
let tickers = client.market().book_tickers().await?;
Source

pub async fn book_tickers_for( &self, symbols: &[&str], ) -> Result<Vec<BookTicker>>

Get best price/qty on the order book for specific symbols.

§Arguments
  • symbols - List of symbols
§Example
let client = Binance::new_unauthenticated()?;
let tickers = client.market().book_tickers_for(&["BTCUSDT", "ETHUSDT"]).await?;

Trait Implementations§

Source§

impl Clone for Market

Source§

fn clone(&self) -> Market

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl Freeze for Market

§

impl !RefUnwindSafe for Market

§

impl Send for Market

§

impl Sync for Market

§

impl Unpin for Market

§

impl !UnwindSafe for Market

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more