Access denied because of exceeding access rate even when not used


  • I run a cron daily on aws lambda at 9am to generate the tokens. Both trade and data tokens. However, am seeing the data token fails to get generated now even when I have not had any prior api access in that hour.

    Please check the log below and help me out.

    {
      "errorMessage": "Couldn't parse the JSON response received from the server: b'Access denied because of exceeding access rate'",
      "errorType": "DataException",
      "requestId": "ca916b99-dcf7-4e99-b698-f304882a59c9",
      "stackTrace": [
        "  File \"/var/task/lambda_function.py\", line 82, in lambda_handler\n    generate_and_save_tokens(configs)\n",
        "  File \"/var/task/lambda_function.py\", line 73, in generate_and_save_tokens\n    generate_and_save_data_tokens_angel(config)\n",
        "  File \"/var/task/lambda_function.py\", line 53, in generate_and_save_data_tokens_angel\n    data = smartApi.generateSession(config['username'], config['pwd'], totp)\n",
        "  File \"/opt/python/lib/python3.10/site-packages/SmartApi/smartConnect.py\", line 252, in generateSession\n    loginResultObject=self._postRequest(\"api.login\",params)\n",
        "  File \"/opt/python/lib/python3.10/site-packages/SmartApi/smartConnect.py\", line 244, in _postRequest\n    return self._request(route, \"POST\", params)\n",
        "  File \"/opt/python/lib/python3.10/site-packages/SmartApi/smartConnect.py\", line 214, in _request\n    raise ex.DataException(\"Couldn't parse the JSON response received from the server: {content}\".format(\n"
      ]
    }