Ads API rate limits

rate-limits

#1

Hi,

the information on rate limits for the Ads API is a bit ambiugous.

In this part of the documentation it is said that you should check these headers: X-Rate-Limit-Limit, X-Rate-Limit-Remaining and X-Rate-Limit-Reset in case you are getting rate limited.

On the other hand the Ads API best practices page states that you should check the x-cost-rate-limit-reset header on 429 and the retry-after header on 503.

Could someone please clarify if this is just an inconsistency in the docs or if the documentation is correct and we should indeed check for all of those.

Thanks

Roman


#2

One more question - is the value returned in the headers a unix epoch timestamp or is it an interval (i.e. the duration to wait in seconds)?


#3

Thanks for the questions, @romanrostar. Here is an example of the response headers you’d see:

-> "HTTP/1.1 200 OK\r\n"
-> "connection: close\r\n"
-> "content-disposition: attachment; filename=json.json\r\n"
-> "content-encoding: gzip\r\n"
-> "content-type: application/json;charset=utf-8\r\n"
-> "date: Fri, 09 Jun 2017 19:59:01 GMT\r\n"
-> "server: tsa_a\r\n"
-> "set-cookie: guest_id=v1%3A149703834187327455; Domain=.twitter.com; Path=/; Expires=Sun, 09-Jun-2019 19:59:01 UTC\r\n"
-> "strict-transport-security: max-age=631138519\r\n"
-> "transfer-encoding: chunked\r\n"
-> "x-access-level: read-write\r\n"
-> "x-api-version: 1.0\r\n"
-> "x-connection-hash: 047009b4a13884f60cb10c62e770e641\r\n"
-> "x-content-type-options: nosniff\r\n"
-> "x-frame-options: SAMEORIGIN\r\n"
-> "x-rate-limit-limit: 2000\r\n"
-> "x-rate-limit-remaining: 1999\r\n"
-> "x-rate-limit-reset: 1497039241\r\n"
-> "x-response-time: 26\r\n"
-> "x-runtime: 0.017035\r\n"
-> "x-transaction: 00357c490031945f\r\n"
-> "x-xss-protection: 1; mode=block\r\n"
-> "\r\n"
-> "116\r\n"

The values of interest are: x-rate-limit-limit, x-rate-limit-remaining, and x-rate-limit-reset. The x-rate-limit-reset value is the epoch time.

We’ll update the documentation for consistency. Thanks for pointing that out!


#4

@romanrostar: Thanks again for flagging this. We’ve removed reference to x-cost-rate-limit-reset in this page. If you spot any other inconsistencies, please do let us know.