The Facebook Ad Library API: what it covers, who gets in, and what to use for the rest
Meta publishes an official Ad Library API, and most people who find it expect a programmatic version of the website: every ad of every advertiser. It is not that. This page lays out what the API returns, what the access process looks like, the errors that fill the forums, and the practical alternative when you need commercial ads or creatives.
What the API is for
The Ad Library API was built for transparency researchers and journalists. It covers ads about social issues, elections or politics in the countries where Meta enforces that category, and, since the EU's Digital Services Act, ads delivered in the European Union. For those ads it returns the text fields, the page, dates, platforms, and, for political ads, spend and impression ranges with demographic and regional splits.
What it does not do
- Commercial ads outside the EU. A US retailer's ads are not in the API at all. Searching by that page ID returns an empty list, which is the most common "bug" reported about it.
- Creatives. No image or video URLs, no carousel cards, no call-to-action button, no landing link. You get a link to a rendered snapshot page and the text.
- Keyword search the way the website does it. Exact-phrase search and the media, platform and status filters of the website map only partly to the API's parameters.
- Volume. Access is rate limited per token, and long paginations get cut off; the forum threads about "rate limit exceeded" and "cursor expired" go back years.
How access works
| Step | What it involves |
|---|---|
| Confirm your identity | A government ID and a location check on your personal Facebook account. Business accounts do not qualify by themselves. |
| Create a developer app | The standard Meta for Developers flow; the API needs no app review, but the token is your own and expires. |
Query /ads_archive | Parameters for countries, ad type, search terms or page IDs, and the fields you want. Paginate with cursors. |
It takes a few days when the ID check goes smoothly. When it does not, there is no support channel to speak of.
The alternative: read the public library
Everything the API withholds is on the public Ad Library page: commercial ads, the creatives, the button, the landing link, the running dates, the platforms, and the EU reach breakdown. The Facebook Ads Library Scraper reads those pages and returns one JSON record per ad with the same field names the official Apify scraper uses, so it behaves like the API you were looking for:
- Every advertiser, every country. A keyword, an advertiser page ID, or the library URL from your browser.
- Creatives included. Image and video URLs, carousel cards, call to action, landing page.
- EU transparency included. Total reach and the split by country, age and gender, plus payer and beneficiary, with the ad details option.
- No ID check, no token expiry, no app. An Apify account and an API token.
Calling it from code
curl -X POST "https://api.apify.com/v2/acts/alfalfa~facebook-ads-library-scraper/runs?token=$APIFY_TOKEN" \
-H 'Content-Type: application/json' \
-d '{"pageIds":["15087023444"],"country":"US","activeStatus":"active","maxAds":200,"scrapeAdDetails":true}'
Poll the run or register a webhook, then read the dataset as JSON or CSV. For small jobs the synchronous endpoint run-sync-get-dataset-items returns the records in the same call; for thousands of ads use the asynchronous one, the synchronous endpoints time out after a few minutes.
When the official API is still the right choice
Academic research on political advertising, where you need Meta's own spend and impression estimates with their demographic splits and a citation to the official source. For that category the API's data is richer than the page, and it is the version reviewers expect.
Questions people ask
Is reading the library pages allowed?
The library is public by design and shows the same ads signed in or not. Reading public pages as a signed-out visitor is what a US court protected in Meta v. Bright Data. The creatives remain the advertisers' copyright.
Can I get a specific ad by its ID?
Yes. Paste the library URL with ?id=; the record comes back with the same fields.
What does it cost?
$0.50 per 1,000 ads, platform usage and proxies included, no start fee. Discounts on paid Apify plans apply automatically.
Open the Facebook Ads Library Scraper Read: exporting the Ad Library