Reputation: 4323
I know I can retrieve data from the API between two specified dates like so:
https://graph.facebook.com/v2.5/act_xxxxxx/insights?level=ad&fields=ad_name,adset_name,campaign_name,spend,unique_clicks,clicks,impressions,cost_per_unique_click,cpm,ctr&sort=spend_descending&time_range[since]=2016-04-01&time_range[until]=2016-04-16
Is there a way to retrieve the data from the API using relative dates from today? Such as this psuedocode:
https://graph.facebook.com/v2.5/act_xxxxxx/insights?level=ad&fields=ad_name,adset_name,campaign_name,spend,unique_clicks,clicks,impressions,cost_per_unique_click,cpm,ctr&sort=spend_descending&time_range[since]=15 DAYS AGO&time_range[until]=7 DAYS AGO
Upvotes: 0
Views: 88
Reputation: 3337
Yes and no.
We do support a list of date presets
And they are defined in:
https://developers.facebook.com/docs/marketing-api/reference/ad-account/insights/
Or you can check our php SDK: https://github.com/facebook/facebook-php-ads-sdk/blob/613d89fbe0424d017a5156658b4e324fbfb5be68/src/FacebookAds/Object/Values/AdsInsightsDatePresetValues.php
In curl you will just use date_preset parameter instead of since
Upvotes: 1