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 needMeta Ad Library API (ads_archive)virev.ai /v1/meta_ads
AccessIdentity and location check at Facebook.com/ID, a Meta for Developers account, an app and an access tokenOne API key in an Authorization: Bearer header
A US brand's commercial adsNot returned unless the ad also reached the UK or EUReturned; country takes a two-letter code or ALL, and omitted is US
Political and issue adsEvery country except EU countries since Oct 6, 2025, for 7 years, with spend, impressions and audience rangesSpend and impression ranges stay with Meta's API; our ads carry neither
Keyword searchsearch_terms, up to 100 charactersquery, up to 500 characters
Ads of one advertisersearch_page_ids, up to 10 Page ids per callOne page_id per call; one job walks every result page of it
Creative filesad_snapshot_url renders one ad; Meta says you cannot download a batch of archived adsImage and video URLs in media
PriceFree$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:

  1. Confirm your identity and location at Facebook.com/ID, the same check Meta uses for people who run political ads.
  2. Create a Meta for Developers account and accept the Platform Policy.
  3. Create an app under My Apps, then call https://graph.facebook.com/<version>/ads_archive with 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.

EndpointReference pageReturnsPrice
GET /v1/meta_ads/search_companiesAdvertiser search APIPages the Ad Library suggests for a name, with each page id$0.0025
GET /v1/meta_ads/company_adsAdvertiser ads APIAds one Page runs or ran, up to 30 a page$0.0025 a call or a job page
GET /v1/meta_ads/search_adsAd search APIAds whose copy matches a keyword, across every advertiser$0.0025 a call or a job page
GET /v1/meta_ads/adAd details APIOne ad by its Ad Library id$0.0025
GET /v1/meta_ads/stored/advertisersAdvertiser directory APITracked advertisers by name prefix$0.0010
POST /v1/meta_ads/stored/advertisers/lookupWatchlist APIMany tracked advertisers with their new ad counts$0.0002 per advertiser returned
GET /v1/meta_ads/stored/advertiserStored advertiser APIOne advertiser's profile and ad counts$0.0002
GET /v1/meta_ads/stored/advertiser/adsStored advertiser ads APIOne advertiser's stored ads, up to 100 a page$0.0005
POST /v1/meta_ads/stored/searchStored ad search APITracked ads filtered by CTA, domain, platform and days active, up to 200 a page$0.0010
GET /v1/meta_ads/stored/insightsAdvertiser insights APIFormat, 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.

find-page-id.sh
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.

one-page.sh
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:

response.json
{
  "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"
  }
}
FieldWhat it isValue in the sample
idThe Ad Library id of the ad; pass it to /v1/meta_ads/ad as ad_archive_id"161966936869658"
taken_atWhen the ad started running, in UTC"2023-08-15T07:00:00+00:00"
kindThe post shape: image, video or carousel"carousel"
product_typeThe Ad Library's display format, such as DPA for a dynamic product ad"DPA"
captionThe ad copy"Entra a Nike.com y encuentra actualizaciones semanales de producto con envío gratis."
owner.idThe advertiser's Facebook page id"15087023444"
owner.extra.likesPage likes of the advertiser39494361
media[].urlEach image or video file of the adhttps://scontent-poa1-1.xx.fbcdn.net/...
extra.urlThe ad on the Ad Library website"https://www.facebook.com/ads/library/?id=161966936869658"
extra.is_activeWhether the ad is still runningfalse
extra.end_dateWhen the ad stopped; for a running ad, the date of the read"2026-03-30T07:00:00+00:00"
extra.link_captionThe link text shown under the ad"nike.com/mx"
extra.cta_typeThe call-to-action button"SHOP_NOW"
extra.publisher_platformsThe Meta apps the ad ran on["facebook", "instagram", "audience_network", "messenger"]
extra.countriesCountries 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.

all_ads.py
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:

StatusWhenBilled
400An unknown, repeated or invalid parameter, refused before any readNo
401A missing, malformed or revoked API keyNo
402Your balance is too low for the requestNo
404The advertiser or ad does not exist, or cached=cache_only found nothing savedNo
429Your organization passed 100 requests a minute, or started a sixth job while 5 are queued, running or waiting for payment; wait for Retry-AfterNo
502 or 504The Ad Library read failed or timed outNo
503The source is paused, our proxy provider is down, or billing could not be confirmed; retry after Retry-AfterNo

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.

keyword-search.sh
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.

stored_ads.py
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 →