SmartApi.smartExceptions.DataException: Couldn't parse the JSON response received from the server: b'Access denied because of exceeding access rate'


  • Hi Team,

    Can you please check the error below, where the SmartConnect Python SDK is not able to handle the response from the server?

    Tue, 02-Jun 14:56:06 COFORGE    ------------------------------------------------------------------------------------------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/ec2-user/angelone/lib64/python3.11/site-packages/SmartApi/smartConnect.py", line 230, in _request
        data = json.loads(r.content.decode("utf8"))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib64/python3.11/json/__init__.py", line 346, in loads
        return _default_decoder.decode(s)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib64/python3.11/json/decoder.py", line 337, in decode
        obj, end = self.raw_decode(s, idx=_w(s, 0).end())
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib64/python3.11/json/decoder.py", line 355, in raw_decode
        raise JSONDecodeError("Expecting value", s, err.value) from None
    json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/home/ec2-user/angelone/top_gainers_losers.py", line 429, in <module>
        hist_data = smartApi.getCandleData({"exchange": "NFO","symboltoken": str(opt_token),"interval": "FIVE_MINUTE","fromdate":fromdate ,"todate": todate})
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/ec2-user/angelone/lib64/python3.11/site-packages/SmartApi/smartConnect.py", line 465, in getCandleData
        getCandleDataResponse=self._postRequest("api.candle.data",historicDataParams)
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/ec2-user/angelone/lib64/python3.11/site-packages/SmartApi/smartConnect.py", line 263, in _postRequest
        return self._request(route, "POST", params)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/ec2-user/angelone/lib64/python3.11/site-packages/SmartApi/smartConnect.py", line 233, in _request
        raise ex.DataException("Couldn't parse the JSON response received from the server: {content}".format(
    SmartApi.smartExceptions.DataException: Couldn't parse the JSON response received from the server: b'Access denied because of exceeding access rate'
    

  • @deeeepak Some more details

    (angelone) [ec2-user@ip-172-111-111-111 angelone]$ pip list installed
    Package            Version
    ------------------ ---------
    attrs              23.1.0
    autobahn           23.6.2
    Automat            22.10.0
    certifi            2023.5.7
    cffi               1.15.1
    charset-normalizer 3.1.0
    constantly         15.1.0
    contourpy          1.3.3
    cryptography       43.0.1
    cycler             0.12.1
    fonttools          4.61.1
    hyperlink          21.0.0
    idna               3.4
    incremental        22.10.0
    isodate            0.6.1
    jwt                1.4.0
    kiwisolver         1.4.9
    logzero            1.7.0
    matplotlib         3.10.8
    mplfinance         0.12.10b0
    numpy              2.4.0
    packaging          25.0
    pandas             2.3.3
    pandas-ta-classic  0.3.59
    pillow             12.1.0
    pip                25.3
    pycparser          2.21
    pycryptodome       3.23.0
    pyotp              2.8.0
    pyparsing          3.1.0
    python-dateutil    2.8.2
    pytz               2023.3
    rdflib             6.3.2
    rdflib-jsonld      0.6.2
    requests           2.31.0
    setuptools         80.9.0
    simplejson         3.19.1
    six                1.16.0
    smartapi-python    1.4.8
    Twisted            22.10.0
    txaio              23.1.1
    typing_extensions  4.6.3
    tzdata             2025.3
    urllib3            2.0.3
    websocket-client   1.8.0
    wheel              0.45.1
    zope.interface     6.0
    

  • @deeeepak Unfortunately, we cannot help you in the debugging / improvement of the code.
    Request you to take help from a professional developer for the same.


  • @admin, I am getting the error

    'Access denied because of exceeding access rate'
    

    when using smartApi.getCandleData function