Issues in getting OHLC Prices

Anuj
Hi,

I am trying to get OHLC Prices. Here is the code:

def get_quote(stock, api_key, access_token):
url="https://api.kite.trade/instruments/NSE/"+stock+"?api_key="+api_key+"&access_token="+access_token
response = requests.get(url)
response_dict=response.json()
return(response_dict['data']['ohlc']['open'])

This code returns error in many cases. The error being:
File "xx.py", line 35, in get_quote
return(response_dict['data']['ohlc']['open'])

KeyError: 'data'

Can you please help resolve?
This discussion has been closed.