2
votes

I am using the Facebook Marketing API and making a call to get the adsets belonging to an adaccount (https://developers.facebook.com/docs/marketing-api/reference/ad-account/adsets/). My issue is that for one of my ad accounts, there are to many adsets available and as such the call is either taking long or has to many pages. Is there a way that i can possiblly add on date filtering to the request so that it will filter out all those adsets outside of the specified dates?

This is the request i am making with a dummy act id:

act_12345678?fields=account_id,name,currency,business{id},adsets{id,name,campaign{id,name,start_time,stop_time,spend_cap,status,insights.date_preset(lifetime){spend}},start_time,end_time,adset_schedule,billing_event,lifetime_budget,budget_remaining,daily_budget,lifetime_imps,status,configured_status,optimization_goal,is_autobid,insights.date_preset(lifetime).as(lifetime_insights){spend}, insights.time_range({'since':'1990-01-01', 'until':'2018-04-26'}).as(insights_to_date){spend}}
1

1 Answers

9
votes

It appears that the "filtering" parameter works in this case.

For example, if you want to return all adsets that had a start time greater than 12/31/2017 and less than 01/31/2018, you can try the following. Note that I had to first convert the start and end dates to a UNIX timestamp:

act_12345678/adsets?filtering=[{'field':'adset.start_time','operator':'GREATER_THAN','value':'1514678400'}, {'field':'adset.start_time','operator':'LESS_THAN','value':'1517356800'}]

You can add the "filtering" parameter to your request URL, and it should then filter both on the dates and the fields you specified.

To convert the dates to UNIX time stamp I used the following link: https://www.unixtimestamp.com/index.php