InputException: invalid token error when fetching historical data

algoumesh
algoumesh edited September 3 in Python client
first I generated session token by using login and then generated access token using:
data = kite.generate_session("xttyxxxxxxxxxxxxxxxxxx", api_secret=key_secret[1])
kite.set_access_token(data["access_token"])

I am able to fetch many details, like kite.instruments("NSE") etc. but API is failing with error "InputException: invalid token" when I try to get historical data using
kite.historical_data("TCS",from_date,dt.date.today(),"5minute")

same code was working fine, issue occurring since last night.
  • Sree
    @algoumesh
    Could you log in to your developer account and confirm whether the Historical API is active.
  • algoumesh
    yes, its active.

    Historical API
    Expires: 26 Oct 2024
    active
  • rakeshr
    kite.historical_data("TCS",from_date,dt.date.today(),"5minute")
    You are assigning wrong token, instead of "TCS"(trading symbol) it should be instrument token. Go through the documentation here.
  • algoumesh
    tried other symbols also,
    like

    new_data = kite.historical_data("SBIN",from_date,dt.date.today(),"15minute")

    still same issue.
  • sujith
    You can read the documentation as mentioned above by @rakeshr
  • algoumesh
    I was running in loop, so could not find it early. issue was only with TATAMTRDVR stocks. removed it from loop and working fine.
This discussion has been closed.