Market Data Endpoints

Create a client to access market data

For accesing market data both PublicClient or AuthenticatedClient can be used but since AuthenticatedClient requires an API Key and API Secret, it is simmpler to use PublicClient when only market data is needed.

from binance.client import PublicClient
client = PublicClient()

Test Connectivity

client.ping()

Get Server Time

server_time =  client.get_server_time()

Get Exchange Information

exchange_info = client.get_exchange_info()

Get Symbol Information

symbol_info = client.get_symbol_info()

Get Order Book

order_book = client.get_order_book(symbol='BNBBTC', limit=100)

Get Recent Trades

recent_trades = client.get_recent_trades(symbol='BNBBTC', limit=100)

Get Aggregate Trades

trades = client.get_agg_trades(symbol='BNBBTC',
                               formId=26129,
                           startTime=1500541200,
                           endTime=1500541250,
                           limit=100)

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 Current average price for a symbol

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

Get 24hr Ticker price change statistics

tickers = client.get_24hr_ticker(symbol='BNBBTC')

Get Symbol Ticker

tickers = client.get_price_ticker(symbol='BNBBTC')

Get Orderbook Tickers

tickers = client.get_orderbook_ticker(symbol='BNBBTC')