my API Limit exceed and key is not working

SOLVED
Farrukh
Getting noticed

my API Limit exceed and key is not working

i can see the Organisations. but other API calls are not working. 

because of API calls i have done. with 2000 networks in an organisation.

How i can check that my API access limit is exceeded. 

1 ACCEPTED SOLUTION

Here's a quote from the docs that'll help:

Rate Limit

  • The Dashboard API is limited to 5 requests per second, per organization.
  • A burst of 5 additional calls are allowed in the first second, so a maximum of 15 calls in the first 2 seconds.
  • The rate limiting technique is based off of the token bucket model.
  • An error with a 429 status code will be returned when the rate limit has been exceeded.

RATE LIMIT ERRORS

​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.

  • The Retry-After key contains the number of seconds the client should delay. A simple example which minimizes rate limit errors:​

 

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 codes

 

  • Expect to backoff for 1 - 2 seconds if the limit has been exceeded. You may have to wait potentially longer if a large number of requests were made within this timeframe.

 

Source:

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/

View solution in original post

6 REPLIES 6
BrechtSchamp
Kind of a big deal

You should get an error with response code 429 instead of the normal 200 response code.

 

Your error is likely related to your access rights. The account linked to the API key you're using, what kind of access rights does it have to the networks you're trying to manage via API?

Farrukh
Getting noticed

Ok Thanks it is working now. What measures i can take to prevent to exceed API limit.

Here's a quote from the docs that'll help:

Rate Limit

  • The Dashboard API is limited to 5 requests per second, per organization.
  • A burst of 5 additional calls are allowed in the first second, so a maximum of 15 calls in the first 2 seconds.
  • The rate limiting technique is based off of the token bucket model.
  • An error with a 429 status code will be returned when the rate limit has been exceeded.

RATE LIMIT ERRORS

​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.

  • The Retry-After key contains the number of seconds the client should delay. A simple example which minimizes rate limit errors:​

 

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 codes

 

  • Expect to backoff for 1 - 2 seconds if the limit has been exceeded. You may have to wait potentially longer if a large number of requests were made within this timeframe.

 

Source:

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/

PhilipDAth
Kind of a big deal
Kind of a big deal

>Ok Thanks it is working now. What measures i can take to prevent to exceed API limit.

 

Put a small delay between the API calls.  A 200ms delay guarantees no problems.  However as code is often busy processing other things, you can often use a smaller delay like 100ms.

Farrukh
Getting noticed

how i can access Retry-After header

Well if you're using requests you can do it using, just as it says in the example I posted earlier:

response.headers["Retry-After"]

 

Get notified when there are additional replies to this discussion.