Market Data Endpoints

Get Market Depth

depth = client.get_order_book(symbol='BNBBTC')

Get Recent Trades

trades = client.get_recent_trades(symbol='BNBBTC')

Get Historical Trades

trades = client.get_historical_trades(symbol='BNBBTC')

Get Aggregate Trades

trades = client.get_aggregate_trades(symbol='BNBBTC')

Aggregate Trade Iterator

Iterate over aggregate trades for a symbol from a given date or a given order id.

agg_trades = client.aggregate_trade_iter(symbol='ETHBTC', start_str='30 minutes ago UTC')

# iterate over the trade iterator
for trade in agg_trades:
    # do something with the trade data

# convert the iterator to a list
# note: generators can only be iterated over once so we need to call it again
agg_trades = client.aggregate_trade_iter(symbol='ETHBTC', '30 minutes ago UTC')
agg_trade_list = list(agg_trades)

# example using last_id value
agg_trades = client.aggregate_trade_iter(symbol='ETHBTC', last_id=23380478)
agg_trade_list = list(agg_trades)

Get Kline/Candlesticks

candles = client.get_klines(symbol='BNBBTC', interval=Client.KLINE_INTERVAL_30MINUTE)

Get Historical Kline/Candlesticks

Fetch klines for any date range and interval

# fetch 1 minute klines for the last day up until now
klines = client.get_historical_klines("BNBBTC", Client.KLINE_INTERVAL_1MINUTE, "1 day ago UTC")

# fetch 30 minute klines for the last month of 2017
klines = client.get_historical_klines("ETHBTC", Client.KLINE_INTERVAL_30MINUTE, "1 Dec, 2017", "1 Jan, 2018")

# fetch weekly klines since it listed
klines = client.get_historical_klines("NEOBTC", Client.KLINE_INTERVAL_1WEEK, "1 Jan, 2017")

Get Historical Kline/Candlesticks using a generator

Fetch klines using a generator

for kline in client.get_historical_klines_generator("BNBBTC", Client.KLINE_INTERVAL_1MINUTE, "1 day ago UTC"):
    # do something with the kline

Get average price for a symbol

avg_price = client.get_avg_price(symbol='BNBBTC')

Get 24hr Ticker

tickers = client.get_ticker()

Get All Prices

Get last price for all markets.

prices = client.get_all_tickers()

Get Orderbook Tickers

Get first bid and ask entry in the order book for all markets.

tickers = client.get_orderbook_tickers()