Getting 502 Bad Gateway in fetching NFO instruments

I am getting the following exception:

File "/Users/romitkumar/work/zerodha/src/instruments/", line 65, in fetchInstrumentsFromServer
instrumentsListFnO = kiteObj.instruments('NFO')
File "/Users/romitkumar/work/zerodha/.venv/lib/python3.9/site-packages/kiteconnect/", line 561, in instruments
return self._parse_instruments(self._get("market.instruments", url_args={"exchange": exchange}))
File "/Users/romitkumar/work/zerodha/.venv/lib/python3.9/site-packages/kiteconnect/", line 842, in _get
return self._request(route, "GET", url_args=url_args, params=params, is_json=is_json)
File "/Users/romitkumar/work/zerodha/.venv/lib/python3.9/site-packages/kiteconnect/", line 924, 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'\r\n502 Bad Gateway\r\n\r\n502 Bad Gateway\r\n\r\n\r\n'

when I call kiteObj.instruments('NFO'), surprisingly kiteObj.instruments('NSE') is working fine
    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.
Sign In or Register to comment.