jsonbitcoincryptocurrencycryptoapi

How to access Kucoin OHLC data from API?


I need to access kucoin Open-high-low-close data from Kucoin API.

Looking in https://docs.kucoin.com/#get-trade-histories, I deduced that to access OHLC data (for instance BTC versus USDT, with hourly timestamp), the address should be something like this :

https://api.kucoin.com/api/v1/market/candles?symbol=BTC-USDT&type=1hour

Doing that, I get empty list for the data {'code': '200000', 'data': []} (according to kucoin API doc, code 200000 correspond to a good request)

What I am doing wrong ?

ps : same method worked very well on kraken api (e.g. https://api.kraken.com/0/public/OHLC?pair=xbtusd )


Solution

  • Kukoin docs also mention two more arguments: startAt and endAt that are start and end of time interval in unix time format.

    I tried

    curl "https://api.kucoin.com/api/v1/market/candles?symbol=BTC-USDT&type=1hour&startAt=1562460061&endAt=1562467061"
    

    (7000 seconds interval).

    and got the result

    {"code":"200000","data":[["1562464800","11233.3","11186.4","11236.1","11185.2","145.83911572","1635403.570428367"],["1562461200","11196.7","11227.2","11236.5","11163.9","179.29402628","2009821.31982076"]]}