data = kite.historical_data(data_from, data_to, 3535361, "day", True, False)
The error returned is kiteconnect.exceptions.InputException: invalid token
I subscribed for the historical data AFTER subscribing to the API
I had already created request & access tokens for the day before subscribing to the Historical API
I have tried logging out and logging back in but this does not change it.
I suspect that the access tokens for the day which are saved in Zerodha's database might have some permissions associated to it at the time of saving them. So logging out and logging back is not useful as the access token is not changing.
I am losing a day of subscription as I cannot proceed.
I have updated it to kite = KiteConnect(api_key, access_token, None, True)
I am still getting the below error Traceback (most recent call last): File "/var/www/html/Python/zerodha/src/import_history.py", line 162, in import_history() File "/var/www/html/Python/zerodha/src/import_history.py", line 84, in import_history kite.historical_data(data_from, data_to, 3535361, "day", True, False) File "/var/www/html/Python/zerodha/venv/lib/python3.9/site-packages/kiteconnect/connect.py", line 621, in historical_data data = self._get("market.historical", File "/var/www/html/Python/zerodha/venv/lib/python3.9/site-packages/kiteconnect/connect.py", line 836, in _get return self._request(route, "GET", url_args=url_args, params=params, is_json=is_json) File "/var/www/html/Python/zerodha/venv/lib/python3.9/site-packages/kiteconnect/connect.py", line 912, in _request raise exp(data["message"], code=r.status_code) kiteconnect.exceptions.InputException: invalid token
It looks like you are not send a valid instrument token. You can check out the pykiteconnect documentation, it looks like your order of params is wrong.
Make sure to remove app and client specific tokens.
run pykiteconnect in debug mode
Can you share the script line or an example or a link to someone else having the issue which has some code sample.
I commented out
data = kite.historical_data(data_from, data_to, 3535361, "day", True, False)
and added
stock = kite.quote('NSE:POWERGRID')
It is working fine with this one line replacement.
Going back to the historical line throws the exception
kiteconnect.exceptions.InputException: invalid token
kite = KiteConnect(api_key, access_token, None, True)
I am still getting the below error
Traceback (most recent call last):
File "/var/www/html/Python/zerodha/src/import_history.py", line 162, in
import_history()
File "/var/www/html/Python/zerodha/src/import_history.py", line 84, in import_history
kite.historical_data(data_from, data_to, 3535361, "day", True, False)
File "/var/www/html/Python/zerodha/venv/lib/python3.9/site-packages/kiteconnect/connect.py", line 621, in historical_data
data = self._get("market.historical",
File "/var/www/html/Python/zerodha/venv/lib/python3.9/site-packages/kiteconnect/connect.py", line 836, in _get
return self._request(route, "GET", url_args=url_args, params=params, is_json=is_json)
File "/var/www/html/Python/zerodha/venv/lib/python3.9/site-packages/kiteconnect/connect.py", line 912, in _request
raise exp(data["message"], code=r.status_code)
kiteconnect.exceptions.InputException: invalid token
You can check out the pykiteconnect documentation, it looks like your order of params is wrong.
It would be helpful to have known this earlier.