Meta's official Meta Ad Library API returns a commercial ad only if it reached the UK or the EU, and only for the past year (Meta's Ad Library API page). Every other ad it returns is about social issues, elections or politics. Before the first call you also confirm your identity at Facebook.com/ID, which Meta says can take a few days.
The official API is one Graph API edge, ads_archive, and developers also search for it as the Facebook Ad Library API. Below is what that edge returns and refuses. After that comes the way to get every ad of a brand or a keyword as JSON through the virev.ai Meta Ads endpoints, at $0.0025 a call. Each step has a real captured response and code you can paste.
What Meta's Ad Library API returns and refuses
Meta documents two groups of ads. Ads about social issues, elections or politics come back from any country for the past 7 years, with spend and impression ranges. Ads of any type come back only when they were delivered to the UK or the EU in the past year. The ads_archive reference states the rule on its required ad_reached_countries parameter: ads that did not reach any location in the EU return only if they are about social issues, elections or politics.
| What you need | Meta Ad Library API (ads_archive) | virev.ai /v1/meta_ads |
|---|---|---|
| Access | Identity and location check at Facebook.com/ID, a Meta for Developers account, an app and an access token | One API key in an Authorization: Bearer header |
| A US brand's commercial ads | Not returned unless the ad also reached the UK or EU | Returned; country takes a two-letter code or ALL, and omitted is US |
| Political and issue ads | Every country except EU countries since Oct 6, 2025, for 7 years, with spend, impressions and audience ranges | Spend and impression ranges stay with Meta's API; our ads carry neither |
| Keyword search | search_terms, up to 100 characters | query, up to 500 characters |
| Ads of one advertiser | search_page_ids, up to 10 Page ids per call | One page_id per call; one job walks every result page of it |
| Creative files | ad_snapshot_url renders one ad; Meta says you cannot download a batch of archived ads | Image and video URLs in media |
| Price | Free | $0.0025 a call; a failed read is not charged |
Spend, impressions, demographic_distribution and bylines exist only for POLITICAL_AND_ISSUE_ADS in the ArchivedAd field reference. eu_total_reach and beneficiary_payers exist only for ads delivered to the EU, and target_ages only for ads delivered to the UK and the EU, plus political ads in Brazil. A commercial ad outside those markets has none of them, because the API never returns it.
To get access, Meta's page lists three steps:
- Confirm your identity and location at Facebook.com/ID, the same check Meta uses for people who run political ads.
- Create a Meta for Developers account and accept the Platform Policy.
- Create an app under My Apps, then call
https://graph.facebook.com/<version>/ads_archivewith its access token.
EU political ads left the API in October 2025
Meta's release notes for Oct 6, 2025 say that ad_type=POLITICAL_AND_ISSUE_ADS together with ad_reached_countries set to an EU country will no longer be available. Code that read EU political ads before that date has to change, because Meta no longer serves that query.
The Ad Library website itself shows every active ad across Meta's apps, as the Transparency Center puts it. The official API is narrower than the website. The virev.ai endpoints read that public website as a signed-out guest, so they return the commercial ads the API leaves out.
The Meta Ads endpoints and their prices
Four endpoints read the Ad Library when you call them, and six read the ads we have already stored. Every price below is per call unless the row says otherwise, and the full reference sits on the Meta Ads API hub.
| Endpoint | Reference page | Returns | Price |
|---|---|---|---|
GET /v1/meta_ads/search_companies | Advertiser search API | Pages the Ad Library suggests for a name, with each page id | $0.0025 |
GET /v1/meta_ads/company_ads | Advertiser ads API | Ads one Page runs or ran, up to 30 a page | $0.0025 a call or a job page |
GET /v1/meta_ads/search_ads | Ad search API | Ads whose copy matches a keyword, across every advertiser | $0.0025 a call or a job page |
GET /v1/meta_ads/ad | Ad details API | One ad by its Ad Library id | $0.0025 |
GET /v1/meta_ads/stored/advertisers | Advertiser directory API | Tracked advertisers by name prefix | $0.0010 |
POST /v1/meta_ads/stored/advertisers/lookup | Watchlist API | Many tracked advertisers with their new ad counts | $0.0002 per advertiser returned |
GET /v1/meta_ads/stored/advertiser | Stored advertiser API | One advertiser's profile and ad counts | $0.0002 |
GET /v1/meta_ads/stored/advertiser/ads | Stored advertiser ads API | One advertiser's stored ads, up to 100 a page | $0.0005 |
POST /v1/meta_ads/stored/search | Stored ad search API | Tracked ads filtered by CTA, domain, platform and days active, up to 200 a page | $0.0010 |
GET /v1/meta_ads/stored/insights | Advertiser insights API | Format, CTA and platform split and the longest-running ads | $0.0010 |
Find a brand's ads in two calls
The Ad Library files every ad under a Facebook Page, so you first turn a brand name into a page id. GET /v1/meta_ads/search_companies returns the Pages the Ad Library suggests for a name, as Account objects with the page id in id and the category, Page likes and URL under extra. For Nike, the first answer is page id 15087023444 with 39,494,361 Page likes.
curl -G "https://api.virev.ai/v1/meta_ads/search_companies" \
-H "Authorization: Bearer $VIREV_API_KEY" \
--data-urlencode "query=Nike"Pass that id to GET /v1/meta_ads/company_ads. With max_pages=1 the call answers one page right away with HTTP 200. country=ALL asks for ads delivered anywhere, status takes ALL, ACTIVE or INACTIVE, and media_type narrows the ads to IMAGE, VIDEO, MEME, IMAGE_AND_MEME or NONE.
curl -G "https://api.virev.ai/v1/meta_ads/company_ads" \
-H "Authorization: Bearer $VIREV_API_KEY" \
-d "page_id=15087023444" \
-d "country=ALL" \
-d "max_pages=1"This is the answer api.virev.ai returned for that page id on 2026-10-27, trimmed to one ad and two images, with the CDN query strings cut:
{
"data": {
"items": [
{
"id": "161966936869658",
"taken_at": "2023-08-15T07:00:00+00:00",
"kind": "carousel",
"product_type": "DPA",
"caption": "Entra a Nike.com y encuentra actualizaciones semanales de producto con envío gratis.",
"likes": null,
"comments": null,
"views": null,
"owner": {
"id": "15087023444",
"username": "nike",
"full_name": "Nike",
"extra": {
"category": "Sportswear",
"likes": 39494361,
"url": "https://www.facebook.com/nike"
}
},
"media": [
{
"kind": "image",
"url": "https://scontent-poa1-1.xx.fbcdn.net/v/t39.35426-6/367963819_652036496870561_3033983014718682847_n.jpg"
},
{
"kind": "image",
"url": "https://scontent-poa1-1.xx.fbcdn.net/v/t39.35426-6/367742785_847403300215960_2275630920962394846_n.jpg"
}
],
"extra": {
"url": "https://www.facebook.com/ads/library/?id=161966936869658",
"is_active": false,
"end_date": "2026-03-30T07:00:00+00:00",
"link_caption": "nike.com/mx",
"cta_type": "SHOP_NOW",
"cta_text": "Shop now",
"publisher_platforms": [
"facebook",
"instagram",
"audience_network",
"messenger"
],
"countries": []
}
}
],
"pages": [
{
"cursor": null,
"fetched_at": "2026-10-27T22:38:37.872549+00:00",
"count": 10
}
],
"next_cursor": "eyJjdXJzb3IiOiJBUUhUWFJf...",
"has_more": true,
"stop_reason": "pages"
},
"meta": {
"source": "live",
"fetched_at": "2026-10-27T22:38:37.872549+00:00",
"cost": "$0.0025",
"request_id": "req_96ae9fb8754f7663f05887e4cf68e4d7"
}
}| Field | What it is | Value in the sample |
|---|---|---|
id | The Ad Library id of the ad; pass it to /v1/meta_ads/ad as ad_archive_id | "161966936869658" |
taken_at | When the ad started running, in UTC | "2023-08-15T07:00:00+00:00" |
kind | The post shape: image, video or carousel | "carousel" |
product_type | The Ad Library's display format, such as DPA for a dynamic product ad | "DPA" |
caption | The ad copy | "Entra a Nike.com y encuentra actualizaciones semanales de producto con envío gratis." |
owner.id | The advertiser's Facebook page id | "15087023444" |
owner.extra.likes | Page likes of the advertiser | 39494361 |
media[].url | Each image or video file of the ad | https://scontent-poa1-1.xx.fbcdn.net/... |
extra.url | The ad on the Ad Library website | "https://www.facebook.com/ads/library/?id=161966936869658" |
extra.is_active | Whether the ad is still running | false |
extra.end_date | When the ad stopped; for a running ad, the date of the read | "2026-03-30T07:00:00+00:00" |
extra.link_caption | The link text shown under the ad | "nike.com/mx" |
extra.cta_type | The call-to-action button | "SHOP_NOW" |
extra.publisher_platforms | The Meta apps the ad ran on | ["facebook", "instagram", "audience_network", "messenger"] |
extra.countries | Countries the Ad Library lists for the ad; empty when it lists none | [] |
Each ad is a Post. The ad copy is caption, the start date is taken_at, and the advertiser is owner. The Ad Library facts sit under extra: the library URL, is_active, end_date, the CTA, the link and publisher_platforms. likes, comments and views are always null, because the Ad Library shows no engagement for ads. This ad ran from 2023-08-15 to 2026-03-30 on four Meta placements, so Nike kept it running for about two years and seven months.
Walk every page with a job
Leave out max_pages=1 and the same call starts a durable job and answers HTTP 202 with a batch_id, a status_url and a results_url. max_pages=-1 walks until the Ad Library has no more pages; with neither value set the job stops after 10 pages. The job bills $0.0025 for each page it walked when it completes, and polls and result downloads cost nothing. A failed job is never charged. The script below walks Nike's ads, prints the first five and writes every ad to a CSV file.
import csv
import os
import time
import requests
BASE = "https://api.virev.ai"
HEADERS = {"Authorization": f"Bearer {os.environ['VIREV_API_KEY']}"}
# 1. Start a job that walks Nike's ads until the Ad Library has no more pages.
job = requests.get(
f"{BASE}/v1/meta_ads/company_ads",
params={"page_id": "15087023444", "country": "ALL", "status": "ALL", "max_pages": -1},
headers=HEADERS,
).json()["data"]
# 2. Poll the job. Polls cost nothing.
while job["status"] in ("queued", "running"):
time.sleep(5)
job = requests.get(BASE + job["status_url"], headers=HEADERS).json()["data"]
if job["status"] != "ready":
raise RuntimeError(f"job {job['batch_id']} ended {job['status']}: {job['error']}")
# 3. Download the results; each response is at most 3 MiB.
ads, cursor = [], None
while True:
params = {"cursor": cursor} if cursor else {}
page = requests.get(BASE + job["results_url"], params=params, headers=HEADERS).json()["data"]
for result in page["results"]:
ads.extend(result["items"])
if page["complete"]:
break
cursor = page["next_cursor"]
print(len(ads), "ads for", job["cost"])
for ad in ads[:5]:
print((ad["taken_at"] or "")[:10], ad["extra"]["cta_type"], ad["extra"]["is_active"], (ad["caption"] or "")[:60])
# 4. Write one CSV row per ad.
with open("nike_meta_ads.csv", "w", newline="", encoding="utf-8") as f:
writer = csv.DictWriter(
f, fieldnames=["id", "taken_at", "end_date", "is_active", "cta_type", "link_caption", "caption"]
)
writer.writeheader()
for ad in ads:
extra = ad["extra"]
writer.writerow({
"id": ad["id"],
"taken_at": ad["taken_at"],
"end_date": extra.get("end_date"),
"is_active": extra.get("is_active"),
"cta_type": extra.get("cta_type"),
"link_caption": extra.get("link_caption"),
"caption": ad["caption"],
})Paging with max_pages=1 works too: send each answer's next_cursor back as cursor while has_more is true. Each of those calls bills $0.0025, so a brand with 10 pages costs $0.0250 that way, the same as one job. Keep an Idempotency-Key header on the submit if your client retries, and a lost 202 comes back for the same key instead of a second job.
Errors and limits
Meta's ads_archive answers error 613 when calls pass its rate limit (ads_archive reference). The /v1/meta_ads endpoints answer these HTTP codes, and only a 200 or a completed job is billed:
| Status | When | Billed |
|---|---|---|
400 | An unknown, repeated or invalid parameter, refused before any read | No |
401 | A missing, malformed or revoked API key | No |
402 | Your balance is too low for the request | No |
404 | The advertiser or ad does not exist, or cached=cache_only found nothing saved | No |
429 | Your organization passed 100 requests a minute, or started a sixth job while 5 are queued, running or waiting for payment; wait for Retry-After | No |
502 or 504 | The Ad Library read failed or timed out | No |
503 | The source is paused, our proxy provider is down, or billing could not be confirmed; retry after Retry-After | No |
Search ads by keyword across advertisers
GET /v1/meta_ads/search_ads runs the Ad Library keyword search over ad copy across every advertiser. It takes the same country, status and media_type filters and the same job and cursor fields as company_ads. Meta's API gives you this search only for UK, EU and political ads; this call covers the US default market and any country code you pass.
curl -G "https://api.virev.ai/v1/meta_ads/search_ads" \
-H "Authorization: Bearer $VIREV_API_KEY" \
--data-urlencode "query=running shoes" \
-d "country=US" \
-d "status=ACTIVE" \
-d "media_type=VIDEO" \
-d "max_pages=1"When a search hands you an ad id, GET /v1/meta_ads/ad?ad_archive_id= reads that one ad again from its advertiser's library page. Use it to check whether an ad is still running before you report on it. An id the Ad Library no longer answers is a 404, and a 404 is not billed.
Keep an ad history with the stored endpoints
The stored endpoints read the ads our crawler has already saved and never start a crawl. You can query a brand's ad history by CTA, link domain and run length without a new Ad Library read. Find a tracked advertiser by name with GET /v1/meta_ads/stored/advertisers?query=nike. Then page through its saved ads with GET /v1/meta_ads/stored/advertiser/ads, up to 100 a page at $0.0005 a page.
import os
import requests
BASE = "https://api.virev.ai"
HEADERS = {"Authorization": f"Bearer {os.environ['VIREV_API_KEY']}"}
# Every stored Nike ad, running ads first, 100 per page at $0.0005 a page.
ads, cursor = [], None
while True:
params = {"page_id": "15087023444", "limit": 100}
if cursor:
params["cursor"] = cursor
data = requests.get(f"{BASE}/v1/meta_ads/stored/advertiser/ads", params=params, headers=HEADERS).json()["data"]
ads.extend(data["items"])
if not data["has_more"]:
break
cursor = data["next_cursor"]
print(len(ads), "stored ads")POST /v1/meta_ads/stored/search filters the stored ads by ctaType, linkDomain, platform, mediaType, minDaysActive and startedAfter, and sorts them by daysActive to put the ads a brand kept longest first. GET /v1/meta_ads/stored/advertiser returns one Page's ad counts for $0.0002, and GET /v1/meta_ads/stored/insights returns its format, CTA and platform split for $0.0010. For a watchlist, POST /v1/meta_ads/stored/advertisers/lookup takes many page ids and returns each one's newAdCount since the time you last checked. The competitor ad research guide builds a weekly tracking loop from these calls.
What 50 competitors cost a month
Say you track 50 brands and pull each one's ads every week. Finding the 50 page ids once costs 50 x $0.0025 = $0.1250. One company_ads job per brand per week bills $0.0025 for each page of up to 30 ads, so 50 brands with 300 ads each cost 50 x 10 x $0.0025 = $1.2500 a week, or $5.0000 for four weeks. Adding a weekly stored/insights read for each brand costs 50 x $0.0010 = $0.0500 a week more. /stored/insights answers only for advertisers we track, and an untracked page id is a 404 that is not billed.
Facebook Ads Library scraper or API
A Facebook Ads Library scraper that you run yourself loads the Ad Library website in a browser, scrolls each result list and parses the rendered page. You keep a browser fleet and a parser that has to follow every change Meta makes to that page. The /v1/meta_ads endpoints do that read for you and return the same Post and Account shapes as the Instagram endpoints. Unknown or repeated query parameters answer 400 before any read or charge, so a typo costs nothing.
Pull a brand's Meta ads in one call
One API key, $0.0025 a page of a brand's ads, and the stored history from $0.0002 a call.
Get your API key →