Reputation: 150
Im trying to get the ads of an account like this:
https://graph.facebook.com/v7.0/act_id?fields=account_id,name,ads{id,name,insights{spend}}
However there are thousands of ads, so I would like to filter them by spend
(only get the ads that have spend > 0). So I tried this:
https://graph.facebook.com/v7.0/act_id?fields=account_id,name,ads{id,name,insights{spend}}&filtering=[{field: "ads.insights.spend",operator:"GREATER_THAN", value:'0'}]
BUT doesn't seem to work. So I also tried this:
https://graph.facebook.com/v7.0/act_id/ads?fields=id,name,insights{spend}&filtering=[{field: "insights.spend",operator:"GREATER_THAN", value:'0'}
BUT I get this error:
(#100) Filtering field 'insights.spend' with operation 'greater_than' is not supported"
So is there a way to accomplish this?
Im also using the javascript sdk so if theres a way to do it with that please share!
Upvotes: 3
Views: 1210
Reputation: 150
Ok I finally figure out how to do this, hope this helps somebody:
act_ID/ads?fields=fields=id,name,insights{spend}&filtering=[{'field':'spend','operator':'GREATER_THAN','value':'0'}]
but that is not really useful without some filtering: you should filter the insights & the ads like this
act_ID/ads?fields=fields=id,name,insights.time_range({'since':'YYYY-MM-DD','until':'YYYY-MM-DD'}){spend}&filtering=[{'field':'spend','operator':'GREATER_THAN','value':'0'}]&time_range={'since':'YYYY-MM-DD','until':'YYYY-MM-DD'}
Upvotes: 4