v1 Stats API not returning x-request-cost

rate-limits
analytics

#1

The new v1 Stats API is not returning the x-request-cost header in the response making it difficult to calculate the cost of our queries.

Sample request below with tracing enabled:

# twurl -t -H ads-api.twitter.com '/1/stats/accounts/5lwgvc?metric_groups=ENGAGEMENT,BILLING,MOBILE_CONVERSION&placement=ALL_ON_TWITTER&granularity=HOUR&start_time=2016-04-01T00:00:00-07:00Z&end_time=2016-04-02T00:00:00-
07:00Z&entity=PROMOTED_TWEET&entity_ids=OX2CP'
opening connection to ads-api.twitter.com...
opened
<- "GET /1/stats/accounts/5lwgvc?metric_groups=ENGAGEMENT%2CBILLING%2CMOBILE_CONVERSION&placement=ALL_ON_TWITTER&granularity=HOUR&start_time=2016-04-01T00%3A00%3A00-07%3A00Z&end_time=2016-04-02T00%3A00%3A00-07%3A00Z&entity=PROMOTED_TWEET&
entity_ids=OX2CP HTTP/1.1\r\nAccept: */*\r\nUser-Agent: OAuth gem v0.5.1\r\nContent-Type: application/x-www-form-urlencoded\r\nAuthorization: OAuth oauth_consumer_key=\"cT75LPPYR4CGqQBiFO2vNkymG\", oauth_nonce=\"83BSutUNY0GpAw5dWqjc04I6vj
Os7Jlyk3NF97xHRBg\", oauth_signature=\"lGVnQifT7%2BwYHkUsBbXwck9N77g%3D\", oauth_signature_method=\"HMAC-SHA1\", oauth_timestamp=\"1459747362\", oauth_token=\"339117672-TI1rfxzoiQdrOHfrPqzbE0FCWkOCcePr9mDDJ4qX\", oauth_version=\"1.0\"\r\n
Connection: close\r\nHost: ads-api.twitter.com\r\nContent-Length: 0\r\n\r\n"
<- "" 
-> "HTTP/1.1 200 OK\r\n"
-> "connection: close\r\n"
-> "content-disposition: attachment; filename=json.json\r\n"
-> "content-length: 3134\r\n"
-> "content-type: application/json;charset=utf-8\r\n"
-> "date: Mon, 04 Apr 2016 05:22:42 GMT\r\n"
-> "server: tsa_b\r\n"
-> "set-cookie: guest_id=v1%3A145974736204010767; Domain=.twitter.com; Path=/; Expires=Wed, 04-Apr-2018 05:22:42 UTC\r\n"
-> "strict-transport-security: max-age=631138519\r\n"
-> "x-access-level: read-write\r\n"
-> "x-api-version: 1.0\r\n"
-> "x-connection-hash: f297e8864c74b4c1f26f9cd0d7649aa9\r\n"
-> "x-content-type-options: nosniff\r\n"
-> "x-frame-options: SAMEORIGIN\r\n"
-> "x-rate-limit-limit: 100\r\n"
-> "x-rate-limit-remaining: 99\r\n"
-> "x-rate-limit-reset: 1459748262\r\n"
-> "x-response-time: 635\r\n"
-> "x-runtime: 0.625065\r\n"
-> "x-transaction: 14497cefc466f785\r\n"
-> "x-xss-protection: 1; mode=block\r\n"
-> "\r\n"

#2

Hi @kai,

If you take a look here:

Migration Guide v0 - v1

You could see:

Rate Limiting
With the introduction of separate asynchronous and asynchronous analytics endpoints, we are deprecating cost-based rate limiting in favor of a straightforward query-based rate limiting model similar to our non-analytics endpoints for both v1 analytics endpoints. The asynchronous analytics endpoint will have a per-advertiser limit on the total number of concurrent asynchronous stats queries. For more details on the rate limits for each endpoint, see the Rate Limiting section of the Analytics Overview.

Regards


#3

Ok, thanks for the clarification Hector!


#4

@kai: please don’t forget to mark Hector’s answer as the solution. Thank you!


#5

Marked as resolved, thanks.


#6