<p>To obtain the information you seek:<br />
I use the a variable called kline and a json formatted request.<br />
It looks like this:</p>
<pre><code>kline = requests.get(url + '/api/v1/market/candles?type=1min&amp;symbol=
                     '+Cry+'&amp;startAt=1566703297&amp;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:&quot;Time&quot;,1:&quot;Open&quot;,
                2:&quot;Close&quot;,3:&quot;High&quot;,4:&quot;Low&quot;,5:&quot;Amount&quot;,6:&quot;Volume&quot;}, 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)
</code></pre>
<p>As you should know, once you have it as a dataframe you can manipulate it as you please.</p>

CC BY-SA 4.0
2022-12-21T20:38:53.867Z
Hi, thanks for your post! In the future, please edit your first post to update instead of posting another. I've deleted the obsolete prior answer, given that this seems to be an improved version of the same. Please let me know if I misunderstood that.
Murch
CC BY-SA 4.0
2022-12-19T01:40:00.160Z
2022-12-21T20:31:23.777Z
2022-12-21T20:31:23.777Z
user138660
<p>I need to access kucoin Open-high-low-close (OHLC) data from Kucoin API.</p>

<p>Looking in <a href="https://docs.kucoin.com/#get-trade-histories" rel="nofollow noreferrer">https://docs.kucoin.com/#get-trade-histories</a>, I deduced that to access OHLC data (for instance BTC versus USDT, with hourly timestamp), the address should be something like this : </p>

<pre><code>https://api.kucoin.com/api/v1/market/candles?symbol=BTC-USDT&amp;type=1hour
</code></pre>

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

<p>What I am doing wrong ?</p>

<p>ps : same method worked very well on kraken api (e.g. <a href="https://api.kraken.com/0/public/OHLC?pair=xbtusd" rel="nofollow noreferrer">https://api.kraken.com/0/public/OHLC?pair=xbtusd</a> )</p>

<p>ps2: this question was originally asked on <a href="https://stackoverflow.com/questions/56572249/how-to-access-kucoin-ohlc-data-from-api">https://stackoverflow.com/questions/56572249/how-to-access-kucoin-ohlc-data-from-api</a> but with no response for the moment. Perhaps this bitcoin stackexchange is better adapted.</p>

<p>Thank you very much in advance for your help !</p>

<exchanges><json-rpc><api><buy-bitcoins><exchange-software>
Access Kucoin OHLC data from API?
daveturner
# Access Kucoin OHLC data from API?

(Asked by: username_0 on 2019-06-13)

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 !

**Tags:** exchanges, json-rpc, api, buy-bitcoins, exchange-software


---

## 1 answers

### Answer by username_1 on 2022-12-19. Score: 0

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.

> **Comments:**
> **username_2**: Hi, thanks for your post! In the future, please edit your first post to update instead of posting another. I've deleted the obsolete prior answer, given that this seems to be an improved version of the same. Please let me know if I misunderstood that.  

---

