I am working on a Facebook comment manager and I just can’t manage to get only active ad creatives from Facebook API.
Is there a way to get all ad creatives filtered by their status?
I can’t afford to check all ads manually, because I plan to pull ads every few minutes and I would be hitting Facebook’s rate limit.
2
Answers
There are a number of endpoints that could help you do this, but would require you to make multiple API calls.
Step One: Get all Ads
Assuming you have managed to get the Ad Account ID from a previous API call, you will be able to get all Ads running against that account by making a GET request to the
/act_{ad_account_id}/ads?fields=name
endpoint.Step Two: Get Images with Active Status
Next you can call the
/{ad_id}/adcreatives?fields=name,image_hash,status
endpoint for each Ad, which will return the name of the creative, the image hash that was used, and the status of the creative.If you require the status of the actual Ad itself rather than the status of the creative, you will need to do another step in between Step One and Step Two, where you call
/{ad_id}?fields=name,status
on each Ad, then filterACTIVE
campaigns.EDIT:
You can use
/act_{ad_account_id}/adcreatives?fields=status,image_hash,title
to get all creatives and statuses associated with the account. This would reduce your API call rate although would mean you would need to sort the creative to match with the ads. Using the title field would give the title of the ad it was used in the ad. Facebook does not offer any other fields related to the ad itself.You can limit results to ads whose effective_status is ACTIVE.
Here is a sample request:
act_123/ads?filtering=[{“field”:”effective_status”,”operator”:”IN”,”value”:[“PAUSED”]}]
Ad fields
Insight Parameter