Get LTP not working for over 10 minutes

I am trying to fetch LTP in my code every, it was working till 10:27 AM today, after that it has stopped working and status is not success

limit = get_ltp(call_list_token, access_token_API)

def get_ltp(instrument_token, access_token):

url = 'https://api.upstox.com/v2/market-quote/ltp?instrument_key=' + instrument_token 
#print(url)
headers = {
    'Accept': 'application/json',
    'Authorization': access_token
}

response = requests.get(url, headers=headers)
response = response.json()

return response

@Ketan @Pradeep_Jaiswar

@Ketan @Pradeep_Jaiswar

the server keeps returning the following error, using both the API I defined above as well as the marketQuoteApi->ltp

{‘status’: ‘error’, ‘errors’: [{‘errorCode’: ‘UDAPI10005’, ‘message’: ‘Too Many Request Sent’, ‘propertyPath’: None, ‘invalidValue’: None, ‘error_code’: ‘UDAPI10005’, ‘property_path’: None, ‘invalid_value’: None}]}
#####################
Exception when calling MarketQuoteApi->ltp: (429)
Reason: Too Many Requests
HTTP response headers: HTTPHeaderDict({‘Date’: ‘Fri, 02 Aug 2024 06:10:00 GMT’, ‘Content-Type’: ‘application/json’, ‘Transfer-Encoding’: ‘chunked’, ‘Connection’: ‘keep-alive’, ‘vary’: ‘Origin, Access-Control-Request-Method, Access-Control-Request-Headers’, ‘message’: ‘request failed’, ‘requestid’: ‘2bb96975-eec9-4a2a-b0cf-0a5282799238’, ‘x-content-type-options’: ‘nosniff’, ‘x-xss-protection’: ‘1; mode=block’, ‘Cache-Control’: ‘no-cache, no-store, max-age=0, must-revalidate’, ‘pragma’: ‘no-cache’, ‘expires’: ‘0’, ‘strict-transport-security’: ‘max-age=0; includeSubDomains’, ‘x-frame-options’: ‘DENY’, ‘CF-Cache-Status’: ‘DYNAMIC’, ‘Set-Cookie’: ‘__cf_bm=HA_yKJMpfVYQM93qJqVsACcdMeqUiSSPAy_6gLwIHV0-1722579000-1.0.1.1-KPx6oL3M9FAJZzxsJqyT2xDRM_ndhZMyXC4RkoGdhZygeJqRSPG4GxfdITwx60jM; path=/; expires=Fri, 02-Aug-24 06:40:00 GMT; domain=.upstox.com; HttpOnly; Secure; SameSite=None, _cfuvid=P8xyWz3yUmgzeYVAZ7S2ofl9hHxFJTJKloMypF_tuYk-1722579000474-0.0.1.1-604800000; path=/; domain=.upstox.com; HttpOnly; Secure; SameSite=None’, ‘Server’: ‘cloudflare’, ‘CF-RAY’: ‘8acbe700aa453c01-BLR’, ‘alt-svc’: ‘h3=“:443”; ma=86400’})
HTTP response body: b’{“status”:“error”,“errors”:[{“errorCode”:“UDAPI10005”,“message”:“Too Many Request Sent”,“propertyPath”:null,“invalidValue”:null,“error_code”:“UDAPI10005”,“property_path”:null,“invalid_value”:null}]}’

The error message Too Many Requests Sent indicates that you have exceeded the rate limit for this API. For more details, please refer to the rate limits specified in the API Documentation Rate Limiting.

1 Like

@Ketan I checked the rate limits, its 25 times in a second, that’s not being breached,

I am accessing the get_ltp every 5 seconds, in this 5th second I fetch LTP for 6 access tokens, the fetch of these 6 access tokens could be within a second

then why is it failing? its way under the rate limit

@Ketan

is it because of the 30 minute limit? 6 access per 5 seconds, is 72 access per minute, this is ok as I see (less than allowed 250)

for 30 minutes total access is 72*30 = 2160 (allowed limit is 1000?)

Yes, the permitted limit for 30 minutes is 1000 requests, which is why you encountered a rate limit. To avoid rate limiting, you might consider subscribing to WebSockets.

For more information, please refer to the Market Data Feed WebSocket.

1 Like