11-25-2019 06:50 AM
If the defined rate limit is exceeded, Dashboard API will reply with the 429 (rate limit exceeded) error code. This response will also return a Retry-After header indicating how long the client should wait before making a follow-up request.
response = requests.request("GET", url, headers=headers)
if response.status_code == 200:
# Success logic
elif response.status_code == 429:
time.sleep(int(response.headers["Retry-After"]))
else:
# Handle other response codesSource:
https://documenter.getpostman.com/view/7928889/SVmsVg6K?version=latest
Another thing you should consider is using action batches. That'll help to optimize your workflow, thus lowering the amount of calls needed. Check this blog post for all info on that:
https://meraki.cisco.com/blog/2019/06/action-batches-a-recipe-for-success/
11-25-2019 06:55 AM
11-25-2019 12:47 PM
Wait - you've managed to get a Python script to make more than 5 requests a second? I find that Python is so slow that this is usually difficult to achieve - especially if you are doing some processing of the returned data.
I saw quite a good library somewhere (I think it was node.js where this is a real issue because of its speed) that actually used a queue. The library submitted your requests to a queue and then a seperate process de-queued the requests at a rate of 5 per second and then called you back with the return value.
Very nice.
And then someone else in your company starts running a script eating into your 5 API calls per second and you are screwed again.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide