Meta Ad Library API: Programmatic Competitor Research Guide
Meta Ad Library API: what it is and how to use it
TL;DR: The Meta Ad Library API (
graph.facebook.com/v27.0/ads_archiveas of Nov 2026) lets you query Meta’s public ad database programmatically instead of through the web UI. It’s free, requires a Meta developer app, an access token and a one-time identity/location confirmation, and returns structured JSON. Coverage is set by regulation: ads delivered to the EU (Digital Services Act) and, per Meta’s API page, the UK, plus social-issue, electoral and political ads worldwide. Commercial ads that never reached the EU or UK are not returned, so a US-only competitor is invisible to the API. By default it returns only active ads: setad_active_status=ALLto see stopped ones too. Covers the API basics, a working Python example, practical use cases, and the real-world limitations you’ll hit.
If you’d rather hand off the creative work that follows the research, Primores produces promo video and product visuals for every placement: content production.
The Ad Library web UI is fine for ad-hoc browsing. For anything repeatable — monitoring 50 competitors weekly, pulling historical ad inventories, feeding an AI creative reverse-engineering workflow with structured data — you’ll hit the web UI’s limits fast. The API is the answer.
What the API actually returns
Each ad in the API response comes as a structured record with fields like:
id— the unique Ad Library IDad_creative_bodies— the ad’s text copy (as an array; multiple versions on carousel ads)ad_creative_link_titles— headlinesad_creative_link_descriptions— descriptionsad_delivery_start_time/ad_delivery_stop_time— ISO timestampspublisher_platforms—["facebook", "instagram", "messenger", "audience_network"]page_id/page_name— the advertiserad_snapshot_url— URL to the rendered ad- For political/issue ads only:
impressions,spend,demographic_distribution,delivery_by_region - For ads delivered to the EU only (DSA fields):
eu_total_reach,age_country_gender_reach_breakdown,target_ages,target_gender,target_locations,beneficiary_payers
For commercial ads you won’t get impressions or spend. For EU-delivered commercial ads you do get EU reach and the advertiser’s age, gender and location targeting, but not interest or custom-audience targeting. What you always get is structured metadata plus the snapshot URL for the creative.
What you need to access it
Four things:
- Identity and location confirmation. Before your first call, complete Meta’s ID confirmation (the same process advertisers use to run political ads: government ID plus country of residence, at facebook.com/ID). Approval can take a few days.
- A Meta developer account. Free, sign up at developers.facebook.com.
- An App. Create one in the developer dashboard. Use case: “Ad Library research” or “Other.”
- An access token. A long-lived user access token works for research. Whether a system user (business) token can call
ads_archiveis unconfirmed: no Meta page says so, and Supermetrics says business accounts can’t be used to call the Ad Library API. Test it before you build on it.
Permissions are unresolved. Meta’s ads_archive reference names no permission and says nothing about App Review. Several guides, Apidog’s among them, tell you to make sure the token has ads_read; none of them cites Meta. In practice the identity confirmation is the gate we can confirm; if a call is refused for permissions, add ads_read to the token. Meta’s reference is explicit about coverage: ads that did not reach any EU location are returned only if they are about social issues, elections or politics. Meta’s field reference describes the targeting and reach fields as covering “the UK & EU”, and Meta’s API page (read 17 Nov 2026) says it covers “Ads of any type that were delivered to the United Kingdom (UK) or European Union during the past year”. For a US-only commercial advertiser the API returns nothing, and you are back to the web UI (which shows their active ads).
Two dated caveats on political ads: Meta stopped delivering political, electoral and social-issue ads in the EU on October 6, 2025 (in response to the EU’s TTPA regulation), so EU results in that category are an archive that ends on that date. And the 7-year archive is now shrinking: the library launched in 2018, so the oldest political ads are being deleted on a rolling basis (US from May 2025, the UK from late November, the EU from April 2026, Brazil in early 2027, per Who Targets Me). Seven years is a ceiling, not a guaranteed depth.
Hands-on: your first API request
The base endpoint:
https://graph.facebook.com/v27.0/ads_archivev27.0 is the version Meta’s ads_archive reference shows (Nov 2026; released 4 November according to the changelog read in a browser on 17 Nov, though the scripted versions page still lists v26.0 as the newest). v25.0 is supported until July 29, 2028. Core query parameters:
access_token— your tokensearch_termsORsearch_page_ids— what to search for (search_page_idstakes up to 10 page IDs per call)ad_active_status—ACTIVE(the default),INACTIVEorALL. Leave it out and you only get ads that are running nowad_reached_countries— required; a country list (e.g.["DE", "FR"]) orALL. For commercial research, use EU countries: a US-only query withad_type=ALLreturns only political/issue adsad_type—ALL,POLITICAL_AND_ISSUE_ADS,HOUSING_ADS,EMPLOYMENT_ADS, orFINANCIAL_PRODUCTS_AND_SERVICES_ADS(which replaced the old credit category)
A minimal curl example:
curl "https://graph.facebook.com/v27.0/ads_archive?\access_token=YOUR_TOKEN&\search_terms=protein+powder&\ad_reached_countries=%5B%22DE%22%5D&\ad_type=ALL&\ad_active_status=ALL&\fields=id,ad_creative_bodies,page_name,ad_delivery_start_time,ad_snapshot_url"The response is JSON:
{ "data": [ { "id": "1234567890", "ad_creative_bodies": ["Tired of bland protein shakes?..."], "page_name": "Example Brand", "ad_delivery_start_time": "2025-11-15T00:00:00+0000", "ad_snapshot_url": "https://www.facebook.com/ads/archive/render_ad/?id=..." } ], "paging": { "cursors": {"before": "...", "after": "..."}, "next": "https://graph.facebook.com/v27.0/ads_archive?..." }}Pagination follows Meta’s standard cursor-based pattern — use the paging.next URL to get the next page. Meta’s API page FAQ (read 17 Nov 2026) puts the maximum at 5,000 ads per results page; ask for less and page through.
A working Python example
A simple script that queries the API, handles pagination, and saves results to JSON:
#!/usr/bin/env python3"""Pull Meta Ad Library ads for a keyword + country, save to JSON."""
import jsonimport sysimport timeimport urllib.parseimport urllib.request
ACCESS_TOKEN = "YOUR_TOKEN_HERE"ENDPOINT = "https://graph.facebook.com/v27.0/ads_archive"
FIELDS = [ "id", "ad_creative_bodies", "ad_creative_link_titles", "ad_creative_link_descriptions", "page_id", "page_name", "ad_delivery_start_time", "ad_delivery_stop_time", "publisher_platforms", "ad_snapshot_url",]
def query_ads(search_terms: str, country: str = "DE", limit: int = 100) -> list[dict]: """Query the Ad Library and return all matching ads (paginated).""" params = { "access_token": ACCESS_TOKEN, "search_terms": search_terms, "ad_reached_countries": f'["{country}"]', "ad_type": "ALL", "ad_active_status": "ALL", # default is ACTIVE: without this, stopped ads are dropped "fields": ",".join(FIELDS), "limit": limit, } url = f"{ENDPOINT}?{urllib.parse.urlencode(params)}" all_ads = []
while url: with urllib.request.urlopen(url, timeout=15) as resp: data = json.loads(resp.read().decode("utf-8")) ads = data.get("data", []) all_ads.extend(ads) print(f"fetched {len(ads)} ads (total: {len(all_ads)})", file=sys.stderr) url = data.get("paging", {}).get("next") time.sleep(0.3) # polite rate-limiting
return all_ads
if __name__ == "__main__": search, country = sys.argv[1], sys.argv[2] if len(sys.argv) > 2 else "DE" ads = query_ads(search, country) out_file = f"ads_{search.replace(' ', '_')}_{country}.json" with open(out_file, "w", encoding="utf-8") as f: json.dump(ads, f, indent=2, ensure_ascii=False) print(f"wrote {len(ads)} ads → {out_file}")Usage:
python mal_api.py "protein powder" DEpython mal_api.py "Apple" FRThis is the pattern Primores’ internal monitoring uses. For production use, wrap it in a rate-limiting layer (Meta enforces request limits) and add retry logic for transient errors.
Searching by page instead of keyword
Advertiser-name search is more reliable than keyword search for competitor monitoring. Use search_page_ids instead of search_terms:
params = { "access_token": ACCESS_TOKEN, "search_page_ids": "12345678,90123456", # comma-separated, up to 10 page IDs per call "ad_reached_countries": '["DE"]', # an EU country, or commercial ads won't return "ad_type": "ALL", "ad_active_status": "ALL", "fields": ",".join(FIELDS),}You get page IDs from the web UI’s URL when viewing a specific brand’s ads (view_all_page_id=...), or programmatically via Meta’s Graph API Page search (requires additional permissions).
Practical use cases
Weekly competitor monitoring. Run the script once a week for your tracked competitors. Diff the result against last week’s output to surface new ads. Primores has this wired to a Claude Code skill that additionally runs reverse-engineering on any new ad.
Category-wide intelligence. Keyword search on category terms (“meal delivery,” “skincare”). Cluster results by advertiser, sort by ad count, identify emerging brands spending meaningful creative effort.
Longevity filtering. After pulling a batch, filter client-side to ads with ad_delivery_start_time older than 30 days and still active — those are high-probability winners worth deeper analysis. EU-delivered ads stay queryable for one year after they last ran, so with ad_active_status=ALL you can also see which concepts were switched off.
Creative stock for LLM workflows. Feed the ad_creative_bodies and ad_snapshot_url into a multimodal LLM for structured creative analysis at scale.
Rate limits and best practices
Meta enforces Graph API rate limits per app and per user. Published limits are intentionally vague — Meta uses “a sliding window based on usage” rather than hard numbers. In practice:
- A single process making sequential requests with a ~0.3s delay between them rarely hits limits.
- Parallelizing too aggressively (10+ concurrent requests) will get you throttled or temporarily blocked.
- Very large queries (pulling thousands of ads) should include exponential-backoff retry logic.
For monitoring 50 competitors weekly, total API volume is in the low thousands of requests per week — well within comfortable limits.
Limitations you’ll hit
- No impressions or spend for commercial ads (API limitation mirrors the web UI).
- Thin targeting data — EU-delivered ads expose age, gender and location targeting and EU reach; nothing exposes interest, lookalike or custom-audience targeting, and non-EU commercial ads expose nothing.
- Image/video assets via snapshot URL, not direct download. You’ll still need to fetch the snapshot URL separately to get the creative asset itself, which is the same pattern as the web-UI download workflow.
- API version deprecation. Meta ships new Graph API versions roughly twice a year and each is supported for about two years (v20.0, used in earlier versions of this page, expired Sep 24, 2026). Check the version in your scripts at least yearly.
- Coverage is EU/UK-or-political only. Commercial ads that never reached the EU (or, per Meta’s API page, the UK) are not returned. Monitor other advertisers through the web UI or a third-party tool.
- Active ads only, unless you ask.
ad_active_statusdefaults toACTIVE.
Key takeaways
- Endpoint:
graph.facebook.com/v27.0/ads_archive(as of Nov 2026; versions live about two years). Setad_active_status=ALL, or you only get running ads. - Free access, requires identity confirmation, a Meta developer app and an access token.
- Structured JSON responses with pagination — easy to pipeline into workflows.
- Coverage: EU- and (per Meta’s API page) UK-delivered ads, kept one year after last delivery, plus political/issue ads worldwide (up to 7 years, now deleting on a rolling basis; EU political archive ends Oct 6, 2025).
- No coverage: commercial ads that never reached the EU or UK.
- Practical pattern: weekly pull per competitor, diff against history, trigger analysis on new ads.
Related
- seo/ai-creative-reverse-engineering-complete-methodology — the capstone methodology this sourcing layer feeds: where API-pulled competitor ads enter the reverse-engineering workflow.
- competitor-analysis/ad-transparency-surfaces — the cross-platform siblings of this API: TikTok’s Commercial Content API, LinkedIn’s EU disclosures, Microsoft’s no-signup API, and the DSA layer that shapes them all.
- questions/how-to-access-meta-ad-library — the manual web-UI equivalent of this API.
- questions/how-to-search-meta-ad-library — search methods the API mirrors as query params.
- questions/how-far-back-meta-ad-library — historical depth, web UI and API alike.
- questions/how-to-download-meta-ad-library-video — fetching the creative assets the API only points to.
- How to use the Meta Ad Library API — Blog: the step-by-step version of this page.
- How do you research competitors with Claude? — Blog: what to do after you’ve found the ads. Six steps with real outputs, from reverse-engineering an ad to checking who AI answers cite, and what each step can’t tell you.
Sources
- Meta Ad Library API documentation — official landing page: coverage wording (“Ads of any type that were delivered to the United Kingdom (UK) or European Union during the past year”) and the 5,000-per-page FAQ, read in a browser 17 Nov 2026 (scripted fetches get 403).
- Meta Graph API Explorer — interactive query tool.
- Meta for Developers — Ad Library API reference (
ads_archive) — validad_typevalues incl.FINANCIAL_PRODUCTS_AND_SERVICES_ADS;ad_reached_countriesrequired; “ads that did not reach any location in the EU will only return if they are about social issues, elections or politics”;ad_active_status“Defaults toACTIVE”;search_page_ids“up to ten IDs”; page header shows v27.0; no permission named (re-read 17 Nov 2026). - Meta for Developers — Archived Ad fields — targeting and reach fields described as covering “the UK & EU”;
total_reach_by_locationsupports “EU, BR, and UK” (read 17 Nov 2026). - Meta for Developers — Graph API versions — v26.0 released Jul 29, 2026; v25.0 expires Jul 29, 2028; v20.0 expired Sep 24, 2026. On 17 Nov 2026 the scripted page still listed v26.0 as newest; v27.0’s 4 Nov release date is from a browser read the same day.
- Radlibrary NEWS (Meta’s research R client) — EU-only DSA fields (
eu_total_reach,target_ages,target_gender,target_locations,beneficiary_payers,age_country_gender_reach_breakdown). - Apidog — How to use the Facebook (Meta) Ad Library API — says to “Ensure the token has necessary permissions (e.g.
ads_read” and that identity verification is “sometimes” required; says nothing about App Review (re-read 17 Nov 2026; an earlier version of this page wrongly cited it for “no App Review”). Secondary source. - Supermetrics — Meta Ad Library connection guide — “business accounts can’t be used to call the Ad Library API”; identity confirmation tied to a personal account (from the 17 Nov research notes, not re-read). Integration vendor.
- Who Targets Me — the Meta Ad Library stops growing — rolling deletion of political ads after seven years: US from May 2025, UK from late November, EU from April 2026, Brazil early 2027 (read 17 Nov 2026).
- Meta Newsroom — Ending political, electoral and social issue advertising in the EU (Jul 2025) — no political/issue ads delivered in the EU from Oct 6, 2025 (TTPA).