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}]}â
Ketan
August 2, 2024, 6:25am
3
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?)
Ketan
August 2, 2024, 6:57am
6
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