Jan Matuszewski
Jan Matuszewski

Reputation: 148

Facebook Graph API - IG User Insights - Get audience_* metrics

I am trying to get audience_city, audience_country, audience_gender_age, audience_locale metrics from FB graph API IG user insights endpoint: https://developers.facebook.com/docs/instagram-api/reference/ig-user/insights

The request I am making:

curl --location --request GET 'https://graph.facebook.com/v10.0/17841411377776842/insights?access_token=...&metric=audience_city&period=lifetime&since=1614639600&until=1614812400'

and the error returned:

{
    "error": {
        "message": "(#100) (audience_city) metric supports querying data only till yesterday",
        "type": "OAuthException",
        "code": 100,
        "fbtrace_id": "APrDtw-8BzaJSbu4F9Q-RA5"
    }
}

The since and until timestamps are set to accordingly 2, 4 March 2021 - so definitely I am not querying "too fresh" data.

The same request for another metric like online_followers is working like a charm.

Has anyone met a similar issue and been able to overpass it?

Upvotes: 1

Views: 1129

Answers (1)

Dimitris
Dimitris

Reputation: 38

Maybe you have figured it out by now, but in case someone lands in here, let's help them:

Quoting the docs: https://developers.facebook.com/docs/instagram-api/reference/ig-user/insights#metrics-and-periods

Metrics that support lifetime periods will have results returned in an array of 24 hour periods, with periods ending on UTC−07:00. audience_* metrics do not support since and until range parameters

So basically when using metrics with the prefix audience_ you do not need to specify the since/until parameters. The error message is a bit disorienting.


Update:
The API documentation has been updated since the question was posted and includes the audience_* specification. I did not check that, my bad.
Thank you @Jan for the update and letting me know!

Upvotes: 2

Related Questions