pythonbinancebinance-api-client

Can you get any data from the Binance API without authentification?


I am using the Binance Futures API. I am using wrapper library python-binance.

I understand you won't be able to get personal data without authentication, but is there any data available publicly?

Where is this specified?


Solution

  • Yes there is. You can initialize Client() without any api key or secret (documentation):

    import binance
    
    client = binance.Client()
    r = client.get_historical_klines('ETHBTC', client.KLINE_INTERVAL_1DAY, '1-Dec-2017', '1-Dec-2017')
    print(r)
    

    Output:

    [[1512086400000, '0.04368400', '0.04432900', '0.04227500', '0.04239700', '83006.12100000', 1512172799999, '3596.96984104', 76803, '40633.85900000', '1761.03625471', '269562.18933427']]
    

    If you don't want to use the python-binance wrapper, you can call the Binance API directly.

    Check out the Binance API documentation. You can check the different security types and its authentication requirements here.

    For example, you can retreive kline/candlestick data without authentication:

    import requests
    
    url = "https://api.binance.com/api/v3/klines?symbol=BTCUSDT&interval=15m"
    
    payload={}
    headers = {}
    
    response = requests.request("GET", url, headers=headers, data=payload)
    
    print(response.text)
    

    The limits for the Binance API are tracked per IP address, and in every endpoint documentation, there is a weight attached to that call.