This is a new post because I was asked to post here from (Accounts endpoint throws SERVICE UNAVAILABLE (503) - #13 by AlightAnalytics) because we’re dealing with a synchronous request.

Here are some account IDs with failed calls:

  • 1la15r
  • efgzy
  • 9z3j2

These failures on our end seem to be linked to synchronous statistics endpoints

Here is an example request and response:

< GET /7/stats/accounts/1la15r?entity=CAMPAIGN&start_time=2020-11-18T08%3A00%3A00%2B00%3A00&end_time=2020-11-19T08%3A00%3A00%2B00%3A00&granularity=HOUR&metric_groups=ENGAGEMENT%2CBILLING%2CVIDEO%2CMEDIA%2CWEB_CONVERSION&placement=ALL_ON_TWITTER&entity_ids=elkd%2Celkq%2Celku%2Celkx%2C1ywxe%2C1z4ho%2C216vd%2C216wk%2C26vvm%2Cbokz4%2Cbokz5%2Cbokz6%2Cbokz7%2Cbokz8%2Cbpyhq%2Cbpyhr%2Cbpyhs%2Cbpyht%2Cbpyhu%2Cbpyhv HTTP/1.1
< Host: ads-api.twitter.com
< User-Agent: Twython v3.7.0
< Accept-Encoding: gzip, deflate
< Accept: */*
< Connection: keep-alive
< Cookie: guest_id=v1%3A160622906282895574; personalization_id="v1_1Gb7lFrrFXZ+jp24ypYkZw=="

> HTTP/1.1 503 Service Temporarily Unavailable
> cache-control: no-cache, no-store, max-age=0
> content-disposition: attachment; filename=json.json
> content-encoding: gzip
> content-length: 156
> content-type: application/json;charset=utf-8
> date: Tue, 24 Nov 2020 14:49:12 GMT
> retry-after: 2020-11-24T14:49:12Z
> server: tsa_b
> strict-transport-security: max-age=631138519
> x-access-level: read
> x-api-version: 7.0
> x-api-warn: Warning: You're using a deprecated version of this API. Upgrade your API: https://developer.twitter.com/en/docs/ads/general/overview/versions.
> x-connection-hash: 421326d2337f2699f491cd079009b2c6
> x-content-type-options: nosniff
> x-current-api-version: 8.0
> x-frame-options: SAMEORIGIN
> x-rate-limit-limit: 250
> x-rate-limit-remaining: 238
> x-rate-limit-reset: 1606229632
> x-response-time: 4599
> x-runtime: 4.584417
> x-transaction: 0047dca300fdf964
> x-xss-protection: 0
> 
{"errors":[{"code":"SERVICE_UNAVAILABLE","message":"Service unavailable due to request timeout; please try the request again later"}],"request":{"params":{}}}

Hey @AlightAnalytics ,

Thank you for reporting the issue. Our teams are actively investigating the root cause and working to resolve the issue. In the meantime, please follow this thread for further updates.

Thanks!

The response from this previous thread below still applies. In some cases, the synchronous analytics endpoint cannot calculate and return values within a set threshold. This is expected behavior.

I was able to complete the request above for 1la15r by removing some of the entities from the query.

Recommendations:

  1. Recommended Switch analytics requests to use the Asynchronous Analytics endpoints. The request from the original post succeeds using this method
  2. Modify the query to reduce the complexity. In this case, reducing the number of entities requested (say to 4) will succeed.
  3. Use the Active Entities API endpoint to identify the minimal set of Entities that should be fetched.

We can investigate further if you notice that both asynchronous and synchronous API requests fail for a specific account/entity.

  1. We cannot use the Asynchronous endpoint with our client because they don’t want the data segmented.
  2. The data is too large for the rate-limits so that one day’s worth of data, requesting four at a time, is taking many hours to complete.

The query from above using the Asynchronous endpoint should result in the same data:

twurl_ads -X POST "/7/stats/jobs/accounts/1la15r?entity=CAMPAIGN&start_time=2020-11-18T08%3A00%3A00%2B00%3A00&end_time=2020-11-19T08%3A00%3A00%2B00%3A00&granularity=HOUR&metric_groups=ENGAGEMENT%2CBILLING%2CVIDEO%2CMEDIA%2CWEB_CONVERSION&placement=ALL_ON_TWITTER&entity_ids=elkd%2Celkq%2Celku%2Celkx%2C1ywxe%2C1z4ho%2C216vd%2C216wk%2C26vvm%2Cbokz4%2Cbokz5%2Cbokz6%2Cbokz7%2Cbokz8%2Cbpyhq%2Cbpyhr%2Cbpyhs%2Cbpyht%2Cbpyhu%2Cbpyhv"

Could you describe what data or format exists that is different?

The data is too large for the rate-limits so that one day’s worth of data is taking many hours to complete.

The Active Entities endpoint (used to identify which entities and timeframes) used with the Asynchronous API endpoint should provide your platform to optimize which data to fetch. Please use the Asynchronous API for this use case.

requesting four at a time

Making multiple concurrent requests to the Synchronous Analytics API may contribute to 503s. Could you describe at a high level how your application is fetching data for partners?