@sujith - I am facing the same error. I am using the right access token. have confirmed it multiple times. I am using Pi. Kindly suggest a way out here
@sujit - need your guidance and recommendation for hosting server where kiteconnet API works fine. Was thinking to host my Python application at pythonanywhere but seek your guidance or recommendations if any other server
My historical data api giving invalid api & access token for my existing app after renewing the subscription. For the same key combination other apis are working fine. pls assist. request :
@dheeraj, Your subscription seems fine. Are you sure you are sending the authorization header properly? Can you enable debug logs of the Kite Connect library and paste the complete stack trace in a private message? We will check and get back to you.
(kite3) 01:22 ~/tisha $ python kite3.py
Traceback (most recent call last):
File "kite3.py", line 6, in
print(kite.ltp("NSE:INFY"))
File "/home/Tisha1806/.virtualenvs/kite3/local/lib/python3.6/site-packages/kiteconnect/connect.py", line 571, in ltp
return self._get("market.quote.ltp", {"i": ins})
File "/home/Tisha1806/.virtualenvs/kite3/local/lib/python3.6/site-packages/kiteconnect/connect.py", line 693, in _get
return self._request(route, "GET", params)
File "/home/Tisha1806/.virtualenvs/kite3/local/lib/python3.6/site-packages/kiteconnect/connect.py", line 762, in _request
raise exp(data["message"], code=r.status_code)
kiteconnect.exceptions.TokenException: Incorrect `api_key` or `access_token
For your information, I am running below python coding when I get above problem: let me know any issue of coding in that.
from kiteconnect import KiteConnect
api_key=open('api_key.txt','r').read()
api_secret=open('api_secret.txt','r').read()
kite=KiteConnect(api_key=api_key)
kite.set_access_token(open('access_token.txt','r').read())
print(kite.ltp("NSE:INFY"))
Are you using Pi or NEST?
And access token through kite Zerodha
"https://kite.trade/?status=success&request_token=zhemy8jkwdp8dkedj3jgq3uaor7od8qt"
I am using above request token as access token in python coding.
If access and request token is not same. let me know how to generate access token.
You can have look at this thread.
request :
https://api.kite.trade/instruments/historical/5533185/15minute?from=2025-03-20&to=2025-04-29&api_key=uvms4x335hbs17tt&access_token=KqbWHYlmUSWbn837ktIF6jYLu207DK3w
response :
{
"status": "error",
"message": "Invalid `api_key` or `access_token`.",
"data": null,
"error_type": "InputException"
}
Your subscription seems fine. Are you sure you are sending the authorization header properly? Can you enable debug logs of the Kite Connect library and paste the complete stack trace in a private message? We will check and get back to you.