Reputation: 136
I have the following query:
[object media ID]/insights/?metric=reach&since2019-12-02&until=2019-12-22
It has been returning lifetime values (filter by date does not work). Then I added "period=day
" to add all values, but the response is:
(#100) The following periods (day) are incompatible with the metric (reach)
How i could get a metric’s total value in a range dates?
thank you
Upvotes: 1
Views: 3661
Reputation: 11
Can you try this:
[instagram-id] /insights/?metric=reach&since=1575244800&until=1576972800
2019-12-02 = 1575244800
2019-12-22 = 1576972800
This is a unix timestamp conversion
I try with the graph api v8.0 for FB post and work!
Upvotes: 1
Reputation: 126
The Instagram Graph API Media (Object) Insights endpoint doesn't support all the fancy filters of the User Insights endpoint.
So I'd ask, are you doing this on an instagram media object or on a user object? My guess is that you're doing it on a media object which is why you'd get that error. I ran these calls on both media and user objects to get to the bottom of this.
If you're doing a user object, you can only max out at 28 days of range. So if you use your date range, you'd request like this:
[instagram-id] /insights/?metric=reach&period=days_28&since2019-12-02&until=2019-12-22
Since your data range is under 28 days, you will get the Reach of all this instagram user's content in that range.
sample:
{
"data": [
{
"name": "reach",
"period": "days_28",
"values": [
{
"value": 620,
"end_time": "2019-12-20T08:00:00+0000"
},
{
"value": 623,
"end_time": "2019-12-21T08:00:00+0000"
}
],
"title": "Reach",
"description": "Total number of times the Business Account's media objects have been uniquely viewed",
"id": "17841400804152929/insights/reach/days_28"
}
],
"paging": {
....
}
}
Impressions and Reach have the same period options for user objects; day, week, 28_day.
So to use period, since and until, you can only perform on a User object and not media.
User Insights (with filters) --> https://developers.facebook.com/docs/instagram-api/reference/user/insights#insights-2
Media Insights (lifetime only) --> https://developers.facebook.com/docs/instagram-api/reference/media/insights#insights-2
For a side reference, if you were to do this call on facebook, for a post for instance, you'd use the metric post_impressions_unique which is 'reach' on FB. FB has way more filters.
https://developers.facebook.com/docs/graph-api/reference/v5.0/insights
Upvotes: 2