It looks like you're new here. If you want to get involved, click one of these buttons!
import pandas as pd
...
kiteObj = KiteConnect(api_key=api_key)
...
df = pd.DataFrame(kiteObj.instruments("NFO"))
...
127.0.0.1 - - [16/Apr/2022 18:04:28] "GET /instruments HTTP/1.1" 200 209 0.015625
Exception in thread Thread-2:
Traceback (most recent call last):
File "C:\Users\Knight\AppData\Local\Programs\Python\Python38-32\lib\threading.py", line 932, in _bootstrap_inner
self.run()
File "C:\Users\Knight\AppData\Local\Programs\Python\Python38-32\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "E:\Users\Knight\Downloads\new-projects\helloworld\app.py", line 430, in instrument_updater
df = pd.DataFrame(kiteObj.instruments("NFO"))
File "E:\Users\Knight\Downloads\new-projects\helloworldvenv\lib\site-packages\kiteconnect\connect.py", line 556, in instruments
return self._parse_instruments(self._get("market.instruments", url_args={"exchange": exchange}))
File "E:\Users\Knight\Downloads\new-projects\helloworldvenv\lib\site-packages\kiteconnect\connect.py", line 837, in _get
return self._request(route, "GET", url_args=url_args, params=params, is_json=is_json)
File "E:\Users\Knight\Downloads\new-projects\helloworldvenv\lib\site-packages\kiteconnect\connect.py", line 919, in _request
raise ex.DataException("Unknown Content-Type ({content_type}) with response: ({content})".format(
kiteconnect.exceptions.DataException: Unknown Content-Type (text/html) with response: (b'<html>\r\n<head><title>502 Bad Gateway</title></head>\r\n<body>\r\n<center><h1>502 Bad Gateway</h1></center>\r\n</body>\r\n</html>\r\n')
127.0.0.1 - - [16/Apr/2022 18:04:30] "POST /update-api-credentials HTTP/1.1" 200 162 0.015666
Instruments dump is a very large file. The instruments api shouldn't be polled continuously.
It only updates once in the morning every trading day.
So ,you can just fetch it once/day and store in your database for that trading day.
But this error came when i was debugging something locally, I did fetch this file multiple times during debugging, can that cause 502?