0
    def get_historical_candles(self, symbol, interval):
        data = dict()
        data['symbol'] = symbol
        data['interval'] = interval
        data['limit'] = 1000

        response = requests.get('https://api.binance.com/api/V3/kline', data)

        raw_candles = response.json()

        candles = []

        if raw_candles is not None:
            for c in raw_candles:
                candles.append([c[0], float(c[1]), float(c[2]), float(c[3]), float(c[4]), float(c[5])])

        print(candles)

How can i avoid the error mentioned in the title?

I have tried

Fetch Candlestick/Kline data from Binance API using Python (preferably requests) to get JSON Dat

and it works well.

However, i need to find out a solution for this approach

 response = requests.get('https://api.binance.com/api/V3/kline', data)
zaster
  • 161
  • 1
  • 4
  • 14

1 Answers1

0
  1. Please read binance API document carefully: https://binance-docs.github.io/apidocs/spot/en/#kline-candlestick-data
  2. To debug this error: Obviously it comes from raw_candles = response.json(). Therefore, before deserialize the response content, it is a good idea to check the status code and text by response.status_code and response.text

TL;DR:

An s is missing. The path should be api/v3/klines

halfelf
  • 9,737
  • 13
  • 54
  • 63