Setup
Put them in your environment or
.env; Data APIs covers the other ways.
Notes
- Public data, not your own account: any ad in the library, subject to Meta’s coverage.
- Ads outside the EU are only returned when they concern social issues, elections or politics; commercial ads are searchable for the EU and UK.
- Keywords are not translated: write search_terms in the ads’ language.
- Error 190 is an invalid token, 613 a rate limit.
Endpoints
Search the Meta Ad Library
- Pass fields explicitly: the answer carries only the ids unless you name the fields you want.
- An empty data array on a later page means the results are exhausted.
- Spend and impressions are ranges, and only available for political and issue ads and for EU-served ads.