Access Kucoin OHLC data from API?
Access Kucoin OHLC data from API?
Loading saved threads...
daveturner · External communityPost link
External question — Bitcoin Stack Exchange
Author: daveturner
Original post: https://bitcoin.stackexchange.com/questions/88352
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
I need to access kucoin Open-high-low-close (OHLC) 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
)
ps2: this question was originally asked on
https://stackoverflow.com/questions/56572249/how-to-access-kucoin-ohlc-data-from-api
but with no response for the moment. Perhaps this bitcoin stackexchange is better adapted.
Thank you very much in advance for your help !
Quote
Report
user138660 · External communityPost link
External answer — Bitcoin Stack Exchange
Author: user138660
Original post: https://bitcoin.stackexchange.com/a/116442
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
To obtain the information you seek:
I use the a variable called kline and a json formatted request.
It looks like this:
kline = requests.get(url + '/api/v1/market/candles?type=1min&symbol=
'+Cry+'&startAt=1566703297&endAt=1566789757')
# Then I convert it to json
kline = kline.json()
# turn that into a dataframe where I pull the data dictionary
kline = pd.DataFrame(kline['data'])
# Then I rename the columbs as so
kline = kline.rename({0:"Time",1:"Open",
2:"Close",3:"High",4:"Low",5:"Amount",6:"Volume"}, axis='columns')
# Set the index as time
kline.set_index('Time', inplace=True)
# To assist I will call the head and and print for you
kline.head()
print(kline)
As you should know, once you have it as a dataframe you can manipulate it as you please.
Quote
Report
Lucas Blake · External communityPost link
External answer — Bitcoin Stack Exchange
Author: Lucas Blake
Original post: https://bitcoin.stackexchange.com/a/131018
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
Your endpoint format looks correct, but the issue may be related to the available historical data or the time range returned by the KuCoin candles endpoint. Try specifying
startAt
and
endAt
as Unix timestamps, and also confirm that
BTC-USDT
is the exact currently supported symbol for the API version you are using. For example:
/api/v1/market/candles?symbol=BTC-USDT&type=1hour&startAt=...&endAt=...
If the request succeeds but returns an empty
data
array, checking the current KuCoin API documentation is worthwhile, as the endpoint and supported market symbols may have changed since this question was originally posted.
Quote
Report
Post Reply
Checking account access…