hsitorical data endpoint gives the error TokenException: Incorrect `api_key` or `access_token`.

iampawansingh
I have paid subscription to kite connect + historical data. The api_key and access_token, which I have works in getting the instruments data, but when calling historical data, it gives the error as `TokenException: Incorrect `api_key` or `access_token`.` Exact call is given below:

from kiteconnect import KiteConnect
kite = KiteConnect(ZERODHA_API_KEY)
kite.set_access_token(access_token)
data = kite.historical_data(3001089, "2025-10-01 11:00:00", "2025-10-01 13:05:00", "5minute")

went through the SDK code line by line, data which is being sent does not give any error, so seems like some issue with end point auhentication. A quick resolution will help here
  • salim_chisty
    You can refer to the login flow here. You may refer to the similar discussion here.

    If the issue persists, you run pykiteconnect in debug mode and paste the complete stack trace here? You can initialise kiteconnect with the debug flag true. Make sure to remove app and client-specific tokens.
  • iampawansingh
    thanks this has been resolved by generating a new access_token
This discussion has been closed.