Kite Historical API Token Exception: Invalid API Credentials

darkknight
I am getting this error repeatedly today and it is happening very arbitrarily. This is becoming very painful, as there is no saying when it start working again. Can you please look into this at the earliest?
  • sujith
    Hi,
    We were doing some maintenance work during this weekend. Hence sessions might have got cleared. Let me know if you face it tomorrow.
  • darkknight
    Hi @sujith , I am again trying today, this is again happening. i mean when can i be sure that you're not running maintenance?? i have seen a lot of threads with the same reason being given. can you please check again if things are fine at your end??
  • sujith
    Hi,
    This might have happened because you logged into Pi or NEST or if you log out of Kite.

    If you haven't logged in then can you let us know, when you logged in and please add some more information like is it happening only for historical data api or others also?
    Any pattern you saw?
  • darkknight
    Hi @sujith

    This is not the case. I am again trying now, I am getting the same error. This does not happen for websocket, but only for Historical. I have not tried any of the other apis so far.

    Also, this behaviour is not consistent. The same python script ran successfully about 2 out of 50 attempts spread over 2 hours last night.

    Today, I have tried again about 10 times, and no luck so far.

    Last weekend, this same API was more consistent - got response about 40-50% of the time. This weekend, things seem to have deteriorated.
  • darkknight
    @sujith if it might help you debug, the script ran twice now, after about 30 attempts. but again fails on the third attempt with the same error.
  • sujith
    Can you paste your code?
  • sohel
    @sujith : I'm seeing this as well when using pykiteconnect. I can fetch instruments and get quotes, but I see an error when trying to fetch historical data. Note that I'm correctly logged into Kite, and haven't logged in elsewhere (Pi or NEST). Example:


    $$$ kite.quote(‘NSE’, ‘DLF’)
    {‘last_price’: 253.55, ‘volume’: 4591948, ‘sell_quantity’: 1250961, ‘open_interest’: 0.0, ‘last_quantity’: 47, ‘change’: 0.3, ‘ohlc’: {‘high’: 256.4, ‘close’: 253.25, ‘open’: 253.85, ‘low’: 251.6}, ‘last_time’: ‘2017-12-27 13:42:07’, ‘change_percent’: 0.11, ‘depth’: {‘sell’: [{‘price’: 253.65, ‘orders’: 1, ‘quantity’: 855}, {‘price’: 253.7, ‘orders’: 1, ‘quantity’: 10}, {‘price’: 253.75, ‘orders’: 1, ‘quantity’: 245}, {‘price’: 253.8, ‘orders’: 9, ‘quantity’: 6383}, {‘price’: 253.85, ‘orders’: 9, ‘quantity’: 7091}], ‘buy’: [{‘price’: 253.55, ‘orders’: 7, ‘quantity’: 405}, {‘price’: 253.5, ‘orders’: 8, ‘quantity’: 2623}, {‘price’: 253.45, ‘orders’: 11, ‘quantity’: 6766}, {‘price’: 253.4, ‘orders’: 9, ‘quantity’: 8999}, {‘price’: 253.35, ‘orders’: 8, ‘quantity’: 4869}]}, ‘buy_quantity’: 625890}
    $$$ kite.historical(‘53706503’, ‘2017-12-26’, ‘2017-12-27’, ‘minute’)
    Traceback (most recent call last):
    File “<stdin>“, line 1, in <module>
    File “/usr/local/lib/python3.6/site-packages/kiteconnect/__init__.py”, line 538, in historical
    “continuous”: 1 if continuous else 0})
    File “/usr/local/lib/python3.6/site-packages/kiteconnect/__init__.py”, line 593, in _get
    return self._request(route, “GET”, params)
    File “/usr/local/lib/python3.6/site-packages/kiteconnect/__init__.py”, line 684, in _request
    raise(exp(data[“message”], code=r.status_code))
    kiteconnect.exceptions.TokenException: Invalid API credentials


    Please advise.
  • razcads
    if you haven't subscribed to historical api (separate paid subscription) then you will see this error. Atleast that's what i saw in my case. You cant use this method without paying for it.
  • sohel
    @razcads : That was it, thanks.
This discussion has been closed.