The Facebook Ad Library API, plus Google and LinkedIn ads
Search Facebook and Instagram ads by keyword or advertiser as JSON, then the Google and LinkedIn ad libraries, with Python, JavaScript and curl code.
· 7 min read
Your competitors publish their marketing plan every day. Every ad that runs on Facebook and Instagram is listed in the Meta Ad Library, every Google ad in the Google Ads Transparency Center, and every LinkedIn sponsored post in the LinkedIn Ad Library. The copy, the creative, the landing page, the start date: it is all public, because regulators asked for it.
The catch is reading it at scale. The Meta Ad Library website is built for browsing one advertiser at a time, and Meta's own Ad Library API asks for identity verification and an access token, and outside the EU and UK it mostly returns political and issue ads. If you want "every running shoe ad active in Germany this month" as a spreadsheet, you need something else.
This guide shows how to search all three ad libraries with plain HTTP calls that return JSON, with code in curl, Python and JavaScript.
Searching Facebook and Instagram ads
The Meta Ad Library API of ScrapeCrate starts with one search endpoint:
GET https://api.scrapecrate.com/v1/ads/searchGive it a keyword (q) or an advertiser page (page_id), and filter by country (a two-letter code, or ALL, the default), status (active, the default, inactive or all), media_type (image, video, meme, none or all), platforms, languages and dates.
curl "https://api.scrapecrate.com/v1/ads/search?q=running%20shoes&country=DE&status=active&media_type=video" \
-H "X-API-Key: YOUR_API_KEY"Each ad in data has these fields:
| Field | What it is |
|---|---|
id, url | The Ad Library ID and the link to the ad in the library |
page | The advertiser page, id and name |
status | active or inactive |
started_at, days_active | When it started and how long it has been running |
winning_score | A 0-100 score, longevity first (see below) |
platforms | Where it runs: facebook, instagram, messenger, audience_network |
format | The creative type |
body, title, link_url, cta | The ad copy, headline, landing page and call to action |
images | The creatives, each with type and url |
match=exact searches the phrase as written instead of any of its words, which matters for brand names made of common words. ad_type=political keeps only political and issue ads.
Finding the ads that work
The library does not show spend or conversions, but advertisers do not keep paying for ads that lose money. An ad that has been running for three months is almost always a winner. Two parameters use that:
sort=longevityputs the longest-running ads of the page first (impressionsandrelevanceare the other orders);min_days_active=30drops the ads younger than 30 days.
Every ad also carries winning_score, from 0 to 100: longevity weighs 70 points, the number of creative variants 15 and, when the library publishes it, the EU reach 15. A missing reach never lowers the score.
winners = client.ads.ads_search(q="protein powder", country="US", sort="longevity", min_days_active=60)
for ad in winners.data:
print(ad["winning_score"], ad["days_active"], ad["link_url"])Look at the landing pages of the top ten: you will see which offers, angles and page layouts the market has validated, before spending your own budget.
Everything one advertiser runs
To follow a specific competitor, find its page first, then list its ads:
curl "https://api.scrapecrate.com/v1/ads/pages/search?q=example%20shoes" -H "X-API-Key: YOUR_API_KEY"
curl "https://api.scrapecrate.com/v1/ads/pages/102030405060708/ads?status=all&sort=longevity" -H "X-API-Key: YOUR_API_KEY"The advertiser endpoint adds the page category, like_count, the linked instagram account and active_ads_estimate. One ad by ID (/v1/ads/{ad_id}) adds payers (who paid and who benefits) and, for ads shown in the EU, transparency with reach and age range.
Run the page ads call every week with status=all and store the IDs: a diff between two runs tells you which ads a competitor launched and which ones it stopped.
Google ads: the Transparency Center
The same API reads the Google Ads Transparency Center, which covers ads on Search, YouTube, Display and Shopping. Google identifies advertisers by an ID that starts with AR; find it by name, then search the ads by advertiser or directly by the domain the ads point to:
curl "https://api.scrapecrate.com/v1/ads/google/ads/search?domain=example.com®ion=US&format=image" \
-H "X-API-Key: YOUR_API_KEY"Each Google ad has advertiser, format (text, image or video), started_at and ended_at (first and last shown), images, videos, a preview_url that renders the ad, domain and variants_count. The single ad endpoint, /v1/ads/google/ads/{creative_id}?advertiser_id=..., adds the topic and the regions where it ran, each with dates and an impressions range when Google publishes one.
LinkedIn ads for B2B research
For B2B, LinkedIn is where the budgets go. Search the LinkedIn Ad Library by keyword (q) or by advertiser name, with country, date_range (last_30_days, current_month, current_year, last_year or all) and sort (newest or oldest):
curl "https://api.scrapecrate.com/v1/ads/linkedin/ads/search?q=crm&country=DE&date_range=last_30_days" \
-H "X-API-Key: YOUR_API_KEY"The detail of one LinkedIn ad holds the gem: for ads shown in the EU, the targeting the advertiser chose (locations, and the other criteria LinkedIn discloses), impressions and the share of impressions by country.
What it costs
Every ads endpoint, Meta, Google or LinkedIn, costs 5 credits per successful call, $0.005 at the list price, whatever the number of ads it returns. A full page of 30 Meta ads is the same price as a page of one. Errors are not billed, and the monthly 100 free credits cover 20 calls. Subscriptions lower the price per credit; see the pricing page.
A weekly watch of 20 competitors on Meta, one call each, costs 100 credits a week, about 40 cents a month.
Ideas for what to build
A swipe file. Search your category every Monday with
sort=longevity, save the creatives and copy of the top ads in a shared folder for your designers.Launch alerts. Diff the active ads of each competitor page between two days and post the new ones in Slack.
Offer and pricing research. Collect
link_urlof the long-running ads and fetch the landing pages as Markdown with the Web Page to Markdown API; an LLM can then extract the offers, prices and guarantees.Lead lists for agencies. Advertisers that run ads have budget. Combine advertiser pages with local businesses from Google Maps, as in our lead generation pipeline guide.
Search and social side by side. Compare what a brand says in its paid social ads with the queries it buys on Google, using the Google Search API guide for the organic and paid results.
Things to keep in mind
Ad libraries change what they show by country.
country=ALLis the widest search, but EU and UK ads carry more transparency data.min_days_activeandsort=longevitywork on the returned page, at the same price. For a full ranking, read a few pages and sort them yourself.Ads contain brand assets and copy owned by the advertiser. Research is fine; republishing them as your own is not. Our guide on whether web scraping is legal covers the details.
Ready to look at your market? Create a free account, copy your API key and run the first search above, or read every parameter in the ads API reference.
Frequently asked questions
Does Meta have an official Ad Library API?
Yes, but it needs a verified identity, a developer app and an access token, and outside the EU and UK it mainly covers political and issue ads. The API in this guide reads the public Ad Library, so commercial ads in every country come back too, with a single API key.
How many ads can I get per call?
Up to 30 Facebook and Instagram ads, 40 Google ads or 25 LinkedIn ads per call, one page of each source. Follow pagination.next_cursor for the next page; every page is a new call at 5 credits.
Can I find the ads that are working for a competitor?
The Ad Library does not publish spend or results, but longevity is a strong signal. Every Meta ad has days_active and a 0-100 winning_score; sort=longevity and min_days_active keep the ads an advertiser has been paying for the longest.
Can I download the images and videos of an ad?
The images list carries the creative URLs as the library serves them. Download what you need soon after the call, because the library's media links can expire.
What does it cost?
Every ads endpoint, Meta, Google or LinkedIn, costs 5 credits per successful call, so about half a cent at the list price. Failed calls are free and the first 100 credits of each month are on us.
Try it with free credits every month
One API key for every source in this guide. No card needed, and only successful calls are billed.