getInstruments('NFO') not working

kashyapgodhani
I am trying to fetch instrument list using getInstruments('NFO') but not getting response. There is an error from your side. Fetching NSE data only.
Tagged:
  • sujith
    Can you paste the error here?
    The raw endpoint seems to be working fine.
  • kashyapgodhani
    kashyapgodhani edited January 2019
    Look at this code.

    $kite = new KiteConnect($api_key);
    $kite->setAccessToken($access_token);
    $data = $kite->getInstruments('NFO');
    print_r($data);

    ERROR:
    tradeguru.website is currently unable to handle this request.
    HTTP ERROR 500
  • Vivek
    @kashyapgodhani This could be because you are exhausting memory. Enable php log and you can find the actual error in your logs. You can check this stackoverflow thread - https://stackoverflow.com/questions/561066/fatal-error-allowed-memory-size-of-134217728-bytes-exhausted-codeigniter-xml
  • dhruva641
    dhruva641 edited April 2022
    Hi @Vivek & @sujith , i'm facing this error, but in python. how do i fix this?

    brokerHandle = KiteConnect(api_key=self.brokerAppDetails.appKey)

    getting accessToken successfully and all that.
    but when i try to fetch the instruments('NFO') , it errors out. Surprisingly this was working on monday and tuesday. start erroring out since wednesday.

    instrumentsListFnO = brokerHandle.instruments('NFO')

    logs-

    2022-04-07 13:38:11: Going to fetch instruments from server...
    2022-04-07 13:38:12: Exception while fetching instruments from server
    Traceback (most recent call last):
    File "/Users/me/Documents/fin/algotrading/algo-trade-python/src/instruments/Instruments.py", line 62, in fetchInstrumentsFromServer
    instrumentsListFnO = brokerHandle.instruments('NFO')
    File "/Users/me/opt/anaconda3/lib/python3.9/site-packages/kiteconnect/connect.py", line 556, in instruments
    return self._parse_instruments(self._get("market.instruments", url_args={"exchange": exchange}))
    File "/Users/me/opt/anaconda3/lib/python3.9/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 "/Users/me/opt/anaconda3/lib/python3.9/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')


    Thank you
  • SRIJAN
    Instruments api is working fine at my end.
  • dhruva641
    Thank you for replying @SRIJAN , any idea what i should probably look at to get it to work at my end?
  • SRIJAN
    SRIJAN edited April 2022
    Are you fetching instruments file multiple times without delay??
  • dhruva641
    thanks , now changed to fetching just once. will test it on monday.
  • SRIJAN
    SRIJAN edited April 2022
    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.