How to get Meta Ad Library data with an API
The Meta Ad Library is Meta’s public archive of ads on Facebook, Instagram and its other apps. This guide covers Meta’s own API, the research jobs people use ad data for and what to compare.
By PrimaryAPIReviewed
What teams use ad library data for
Most ad research falls into a few jobs.
- Competitor tracking: every ad a rival brand runs, with start dates and the platforms it appears on.
- Creative research: the hooks, headlines, calls to action and formats that keep running.
- Market scans: who advertises on a keyword in a given country.
- Script research: transcripts of video ads, to compare openings and offers.
What Meta’s Ad Library API covers
Meta’s official API covers political and issue ads worldwide and ads of every type delivered to the UK or the EU. You confirm your identity, create a developer app and query it with a role on that app.
Read the dated details in the official API section before you plan a project on it, especially if you study commercial ads outside the UK and the EU.
Search by keyword, then by advertiser
Start with a keyword search to see who advertises on a topic in a country. Then pick an advertiser and list its ads by page id or by name.
If you only have a brand name, the advertiser search returns its page id, category, verification and linked Instagram account.
What to ask an ad data API
Put these questions to each option before you commit.
- Which countries and ad types does it return?
- Can I search by keyword and also list one advertiser’s ads?
- Does it return every card, image and video of an ad, and the landing page?
- Can it turn video ads into text?
- What does one search page or one ad lookup cost?
Pulling ad data with PrimaryAPI
Create an account, copy your API key and POST a keyword and a country to the ads search API, or an advertiser’s name to the library lookup. Each ad API’s page lists its input, its output fields and an example.
The same key searches TikTok’s ad library, and you only pay when data comes back.