Skip to main content

Market Data Endpoints

Real-time and historical market data. No authentication required for most endpoints.

Binance API Reference: Market Data Endpoints

Order Book (Depth)

Get the order book for a symbol.

val book: F[OrderBook] = client.depth("BTCUSDT", limit = Some(10))
// OrderBook(lastUpdateId, bids: List[OrderBookEntry], asks: List[OrderBookEntry])
EndpointGET /api/v3/depth
AuthNone
Weight5-50 (depends on limit)

Recent Trades

Get the most recent trades for a symbol.

val trades: F[List[Trade]] = client.trades("BTCUSDT", limit = Some(50))
EndpointGET /api/v3/trades
AuthNone
Weight25

Aggregate Trades

Get compressed, aggregated trades.

val aggTrades: F[List[AggTrade]] = client.aggTrades("BTCUSDT", limit = Some(100))
EndpointGET /api/v3/aggTrades
AuthNone
Weight4

Kline / Candlestick Data

Get kline/candlestick bars for a symbol. Klines are uniquely identified by their open time.

import io.github.rafafrdz.binance4s.domain.KlineInterval

val klines: F[List[Kline]] = client.klines("BTCUSDT", KlineInterval.`1h`, limit = Some(100))

Available intervals: 1s, 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 3d, 1w, 1M

EndpointGET /api/v3/klines
AuthNone
Weight2

Response model:

case class Kline(
openTime: Long, open: String, high: String, low: String,
close: String, volume: String, closeTime: Long,
quoteAssetVolume: String, numberOfTrades: Int,
takerBuyBaseAssetVolume: String, takerBuyQuoteAssetVolume: String
)
note

Klines are returned as JSON arrays, not objects. Binance4s includes a custom Circe decoder that maps positional array elements to named fields.

Current Average Price

Get the current average price for a symbol.

val avg: F[AvgPrice] = client.avgPrice("BTCUSDT")
// AvgPrice(mins: Int, price: String)
EndpointGET /api/v3/avgPrice
AuthNone
Weight2

24hr Ticker

Get 24-hour rolling window price change statistics.

val tickers: F[List[Ticker24h]] = client.ticker24h(Some("BTCUSDT"))
EndpointGET /api/v3/ticker/24hr
AuthNone
Weight2-80

Symbol Price Ticker

Get the latest price for a symbol.

// Single symbol (returns object)
val price: F[TickerPrice] = client.tickerPrice("BTCUSDT")

// All symbols (returns array)
val prices: F[List[TickerPrice]] = client.tickerPrice
EndpointGET /api/v3/ticker/price
AuthNone
Weight2-4

Book Ticker

Get the best bid/ask price and quantity.

val tickers: F[List[BookTicker]] = client.bookTicker(Some("BTCUSDT"))
EndpointGET /api/v3/ticker/bookTicker
AuthNone
Weight2-4

UI Klines

Get kline/candlestick data optimized for presentation (modified by Binance for display purposes).

import io.github.rafafrdz.binance4s.api.market.UiKlinesReq

val uiKlines: F[List[Kline]] = client.execute(UiKlinesReq("BTCUSDT", KlineInterval.`1h`, limit = Some(100)))
EndpointGET /api/v3/uiKlines
AuthNone
Weight2

Trading Day Ticker

Get price change statistics for the trading day.

import io.github.rafafrdz.binance4s.api.market.TradingDayTickerReq

val ticker: F[List[TradingDayTicker]] = client.execute(TradingDayTickerReq(symbol = Some("BTCUSDT")))
EndpointGET /api/v3/ticker/tradingDay
AuthNone
Weight4

Rolling Window Ticker

Get rolling window price change statistics with configurable window size.

import io.github.rafafrdz.binance4s.api.market.RollingTickerReq

val ticker: F[List[RollingTicker]] = client.execute(RollingTickerReq(symbol = Some("BTCUSDT"), windowSize = Some("1h")))
EndpointGET /api/v3/ticker
AuthNone
Weight4

Reference Price

Get the reference price for a symbol.

val ref: F[ReferencePrice] = client.referencePrice("BTCUSDT")
EndpointGET /api/v3/referencePrice
AuthNone
Weight2