Use time range in Ad Insights of Facebook Marketing API

David picture David · Feb 15, 2016 · Viewed 11.1k times · Source

I'm trying to obtain impressions of my ads between two dates

I'm using Graph API Explorer with this path:

act_0123456789/ads?fields=insights{ad_id,ad_name,impressions}

I want to use 'time_range' attribute that we can find it in Marketing API reference but I don't know the syntax. Anyone can help me?

Answer

Al Ducent picture Al Ducent · Feb 16, 2016

I can't comment on the approach you're using as I have not used it myself. However, here is an alternative approach which I have used with success:

https://graph.facebook.com/v2.5/act_xyz/insights?level=<yourLevel>&fields=ad_id,ad_name,impressions&time_range[since]=2016-02-15&time_range[until]=2016-02-16&limit=25

where <yourLevel> can be one of: ad, adset, campaign

Also note that I am using straight up http requests in java which is why I show you the request itself. Hopefully you can extrapolate to your own solution.