Vanishing entity_ids in /stats/accounts/:account_id endpoint

api

#1

Hello,

I’m having problems with obtaining results from /stats/accounts/:account_id endpoint ( https://dev.twitter.com/ads/reference/1/get/stats/accounts/%3Aaccount_id )

Even though I’m submitting a list of entity_ids that I want to fetch results for, in the response nothing is returned and… request’s entity_ids argument is set to null.

REQUEST:

GET 'https://ads-api.twitter.com/1/stats/accounts/18ce53...?placement=ALL_ON_TWITTER&metric_groups=ENGAGEMENT&start_time=2016-08-03T07%3A00%3A00Z&entity=ACCOUNT&end_time=2016-08-08T07%3A00%3A00Z&granularity=TOTAL&entity_ids=18ce54...'

18ce53... - is the account that I have oauth access to.
18ce54... - is the account for which I want to pull stats. 18ce53... has full admin access to analytics of 18ce54...

RESPONSE:

{
    "data_type": "stats",
    "time_series_length": 1,
    "data": [{
        "id": "18ce53...",
        "id_data": [{
            "segment": null,
            "metrics": {
                "impressions": null,
                "follows": null,
                "retweets": null,
                "likes": null,
                "engagements": null,
                "replies": null
            }
        }]
    }],
    "request": {
        "params": {
            "start_time": "2016-08-03T07:00:00Z",
            "segmentation_type": null,
            "entity_ids": null,
            "end_time": "2016-08-08T07:00:00Z",
            "country": null,
            "placement": "ALL_ON_TWITTER",
            "granularity": "TOTAL",
            "entity": "ACCOUNT",
            "platform": null,
            "metric_groups": ["ENGAGEMENT"]
        }
    }
}

What’s the likely cause for "entity_ids": null, in the response ?
Is there anything wrong I’m doing with calling the endpoint (no errors obtained from Advertiser API) ?


#2

Hi, @grechut. Thanks for the question!

Your request looks good to me; this is the correct way to call the endpoint for entity=ACCOUNT. Entity IDs do not exist at the account level, which is why we return null.


#3

Thanks Juan for the response!

And is the stats endpoint working properly for entity ACCOUNT ?

Unfortunately, all the time still I’m getting only null values in response for stats I’m requesting.

Even in your SDK https://github.com/twitterdev/twitter-python-ads-sdk/blob/master/twitter_ads/account.py , I do not see stats method implemented for the account. Other entities (like LineItem) have all_stats method.


#4

@grechut Not all metrics are available on all entity levels. On the account level, only engagement metrics are available. See the top table in our Metrics and Segmentation page for details on exactly which metric groups are available on which level.

The recommended best practice is to fetch stats on the lowest entity level they need, since you are able to get more finely grained and relevant metrics, and you are always able to roll up to higher entity levels if you need higher level data without the need to extra requests.


#5

Thanks for the good tip. Getting stats on lowest entity level works :wink: