<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to access Retry-After header in API response in Network Platform API</title>
    <link>https://community.cisco.com/t5/network-platform-api/how-to-access-retry-after-header-in-api-response/m-p/5425572#M4276</link>
    <description>Thanks for this !&lt;BR /&gt;&lt;BR /&gt;I usually default to having a 1 sec or 2 sec timer since I'm not really in a rush, but still want it to be efficient.</description>
    <pubDate>Mon, 25 Nov 2019 14:55:01 GMT</pubDate>
    <dc:creator>Nolan H.</dc:creator>
    <dc:date>2019-11-25T14:55:01Z</dc:date>
    <item>
      <title>How to access Retry-After header in API response</title>
      <link>https://community.cisco.com/t5/network-platform-api/how-to-access-retry-after-header-in-api-response/m-p/5425571#M4275</link>
      <description>&lt;H2&gt;&lt;EM&gt;Rate Limit&lt;/EM&gt;&lt;/H2&gt;&lt;UL&gt;&lt;LI&gt;&lt;EM&gt;The Dashboard API is limited to &lt;STRONG&gt;5 requests per second&lt;/STRONG&gt;, per organization.&lt;/EM&gt;&lt;/LI&gt;&lt;LI&gt;&lt;EM&gt;A burst of 5 additional calls are allowed in the first second, so a maximum of 15 calls in the first 2 seconds.&lt;/EM&gt;&lt;/LI&gt;&lt;LI&gt;&lt;EM&gt;The rate limiting technique is based off of the &lt;A href="https://en.wikipedia.org/wiki/Token_bucket" target="_blank" rel="noopener nofollow noreferrer"&gt;token bucket model&lt;/A&gt;.&lt;/EM&gt;&lt;/LI&gt;&lt;LI&gt;&lt;EM&gt;An error with a 429 status code will be returned when the rate limit has been exceeded.&lt;/EM&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;H3&gt;&lt;EM&gt;RATE LIMIT ERRORS&lt;/EM&gt;&lt;/H3&gt;&lt;P&gt;&lt;EM&gt;​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 &lt;FONT color="#FF0000"&gt;Retry-After header&lt;/FONT&gt; indicating how long the client should wait before making a follow-up request.&lt;/EM&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;EM&gt;The &lt;FONT color="#FF0000"&gt;&lt;U&gt;&lt;STRONG&gt;Retry-After key contains&lt;/STRONG&gt;&lt;/U&gt;&lt;/FONT&gt; the number of seconds the client should delay. A simple example which minimizes rate limit errors:​&lt;/EM&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;PRE&gt;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&lt;/PRE&gt;&lt;UL&gt;&lt;LI&gt;&lt;EM&gt;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.&lt;/EM&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Source:&lt;/P&gt;&lt;P&gt;&lt;A href="https://documenter.getpostman.com/view/7928889/SVmsVg6K?version=latest" target="_blank" rel="noopener nofollow noreferrer"&gt;https://documenter.getpostman.com/view/7928889/SVmsVg6K?version=latest&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Another thing you should consider is using&lt;SPAN&gt; &lt;/SPAN&gt;&lt;STRONG&gt;action batches&lt;/STRONG&gt;. That'll help to optimize your workflow, thus lowering the amount of calls needed. Check this blog post for all info on that:&lt;/P&gt;&lt;P&gt;&lt;A href="https://meraki.cisco.com/blog/2019/06/action-batches-a-recipe-for-success/" target="_blank" rel="noopener nofollow noreferrer"&gt;https://meraki.cisco.com/blog/2019/06/action-batches-a-recipe-for-success/&lt;/A&gt;&lt;/P&gt;&lt;DIV class="view-original-post-link"&gt;&lt;P&gt;&lt;A href="https://community.meraki.com/t5/Developers-APIs/my-API-Limit-exceed-and-key-is-not-working/m-p/64042#M2087" target="_blank"&gt;View solution in original post&lt;/A&gt;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 25 Nov 2019 14:50:40 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/how-to-access-retry-after-header-in-api-response/m-p/5425571#M4275</guid>
      <dc:creator>farrukhaziz</dc:creator>
      <dc:date>2019-11-25T14:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to access Retry-After header in API response</title>
      <link>https://community.cisco.com/t5/network-platform-api/how-to-access-retry-after-header-in-api-response/m-p/5425572#M4276</link>
      <description>Thanks for this !&lt;BR /&gt;&lt;BR /&gt;I usually default to having a 1 sec or 2 sec timer since I'm not really in a rush, but still want it to be efficient.</description>
      <pubDate>Mon, 25 Nov 2019 14:55:01 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/how-to-access-retry-after-header-in-api-response/m-p/5425572#M4276</guid>
      <dc:creator>Nolan H.</dc:creator>
      <dc:date>2019-11-25T14:55:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to access Retry-After header in API response</title>
      <link>https://community.cisco.com/t5/network-platform-api/how-to-access-retry-after-header-in-api-response/m-p/5425573#M4277</link>
      <description>&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;Very nice.&lt;/P&gt;&lt;P&gt;And then someone else in your company starts running a script eating into your 5 API calls per second and you are screwed again.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2019 20:47:23 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/how-to-access-retry-after-header-in-api-response/m-p/5425573#M4277</guid>
      <dc:creator>Philip D'Ath</dc:creator>
      <dc:date>2019-11-25T20:47:23Z</dc:date>
    </item>
  </channel>
</rss>

