# Facebook Ad Library API: Meta Ads Scraper (`firsthand/facebook-ad-library-api`) Actor

Facebook Ad Library API without a token: export Facebook and Instagram ads from the Meta Ad Library by keyword, advertiser page or Ad Library URL. Ad text, headline, CTA, links, image and video URLs, dates, platforms. Large searches split automatically, every ad charged once.

- **URL**: https://apify.com/firsthand/facebook-ad-library-api.md
- **Developed by:** [Firsthand](https://apify.com/firsthand) (community)
- **Categories:** Marketing, Social media
- **Features:** Limited permissions
- **Stats:** 3 total users, 0 monthly users, 91.7% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.30 / 1,000 ads

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Facebook Ad Library API: Meta Ads Scraper

Export Facebook and Instagram ads from the Meta Ad Library by keyword, by advertiser page or by an Ad Library search link. You get the ad text, headline, call to action, landing page, image and video URLs, start and end dates and platforms for every ad, as JSON, CSV or Excel.

There is no access token, no Facebook login and no developer app. The official Meta Ad Library API needs all three, and outside the EU it returns only political and issue ads. This Actor reads the public Ad Library pages that anyone can open in a browser, so it returns commercial ads in every country.

### What you get

One row per ad:

- `adArchiveId`, `adLibraryUrl`: the Library ID and a link to the ad in the Ad Library
- `pageId`, `pageName`, `pageUrl`, `pageLikeCount`, `pageCategories`: the advertiser
- `isActive`, `startDate`, `endDate`: when the ad ran; for an active ad `endDate` is the last day the Library has seen it
- `publisherPlatforms`: FACEBOOK, INSTAGRAM, THREADS, AUDIENCE_NETWORK, WHATSAPP, MESSENGER
- `displayFormat`: IMAGE, VIDEO, CAROUSEL, DCO, DPA and other formats as the Library names them
- `bodyText`, `title`, `linkDescription`, `caption`: the ad copy
- `linkUrl`, `ctaText`, `ctaType`: the landing page and the button
- `imageUrls`, `videoUrls`, `videoPreviewImageUrls`: links to the creatives
- `cards`: every card of a carousel or catalog ad with its own text, link, image and video
- `collationId`, `collationCount`: ads the Library groups as versions of one ad
- `impressionsText`, `spend`, `currency`, `reachEstimate`, `targetedOrReachedCountries`: filled only where Meta publishes them, mostly for political and issue ads and ads shown in the EU
- `searchInput`, `searchUrl`, `scrapedAt`: which of your searches found the ad
- `snapshot`: the full ad record as the Library returns it, for fields not listed above

How often fields are filled, measured on 2,303 active US ads for "hiking boots" (November 2026): ad text 100%, link 99%, call to action 99%, headline 95%, image URLs 51%, video URLs 49%, carousel cards 21%, impressions text 38%. Spend and reach were empty for all of them: Meta does not publish them for commercial ads in the US.

### Facebook Ads Library scraper: how to use it

1. Fill in at least one of:
   - **Search terms**: a brand, product or niche, one per line (`hiking boots`, `nike`). Each line is a separate search.
   - **Facebook pages**: an advertiser's page URL (`https://www.facebook.com/nike`), a page ID (`15087023444`) or an Ad Library link with `view_all_page_id`. You get all ads of that page.
   - **Ad Library URLs**: open [facebook.com/ads/library](https://www.facebook.com/ads/library/), set the filters you want, run the search and paste the link from the address bar.
2. Set **Country**, **Ad status** and the other filters for search terms and pages. A pasted Ad Library link keeps its own filters.
3. Set **Max ads per search**, or leave it empty to get every ad the Library returns.
4. Run the Actor and download the results.

Each ad appears once per run even when several of your searches find it, and you pay for it once.

### Meta Ad Library search by page

A brand often has several Facebook pages, and the ads run from only one of them. The global HelloFresh page (`facebook.com/hellofresh`) had no ads in any country in November 2026, while US ads ran from `facebook.com/HelloFreshUS`. If a page returns no ads, open the brand's ads in the Ad Library and copy the page from there: the run summary (`SUMMARY.perTarget`) says `no ads` for that page, which is a real zero and not an error: the Actor checks it in two sessions before saying so.

Ads made with creators (partnership ads) are listed under the advertiser's page, with the creator's name in `pageName`.

### Large searches

The Ad Library lists ads 10 at a time, and the further down the list, the slower and more expensive each next part gets. When a search has more than 1,500 ads and you asked for more than that, the Actor splits it by media type (images, videos, no media) and inactive ads also by date ranges, reads each part separately and removes duplicates before saving. This is automatic.

Active ads cannot be split by dates: the Library's date filter means "shown in this period", and an ad running since last year is shown in every period. So one media type of an active search is read up to about 10,000 ads; a bigger part (for example all active Nike image ads in the US, about 18,000) stops there and the run summary marks the search as not complete. Narrow such a search by country, language or platform with an Ad Library URL.

The Library's own counter ("~21,600 results") is an estimate, and for inactive ads it stops at "50,000+". The media type parts together cover 99-99.9% of the counter. In a test the Actor read 97% of the counter for "hiking boots" (2,303 of 2,369 active US ads) to the end of every part. What was read and why each search stopped is in the `SUMMARY` record of the run's key-value store: `complete`, `stopReason`, the number per search and per part.

### Download Facebook ad library videos and images

`imageUrls`, `videoUrls` and `cards` hold direct links to the creative files on Facebook's servers. Download them soon after the run: the links carry a signature that expires in a few days (about four days in a November 2026 test). The Actor does not download the files itself.

### Example output

```json
{
  "adArchiveId": "2045879599391945",
  "adLibraryUrl": "https://www.facebook.com/ads/library/?id=2045879599391945",
  "pageId": "112727500143177",
  "pageName": "Whatnot",
  "pageUrl": "https://www.facebook.com/RealWhatnot/",
  "pageLikeCount": 310210,
  "pageCategories": ["Shopping"],
  "isActive": true,
  "startDate": "2026-08-20T07:00:00Z",
  "endDate": "2026-11-08T08:00:00Z",
  "publisherPlatforms": ["FACEBOOK", "INSTAGRAM", "MESSENGER"],
  "displayFormat": "DPA",
  "bodyText": "Titleist, Callaway, and TaylorMade clubs and apparel starting at $1 ⚡️ Live on Whatnot!",
  "title": "Whatnot: Shop, Sell, Connect",
  "linkUrl": "http://play.google.com/store/apps/details?id=com.whatnot_mobile",
  "caption": "play.google.com",
  "ctaText": "Install now",
  "ctaType": "INSTALL_MOBILE_APP",
  "imageUrls": ["https://scontent-phl2-1.xx.fbcdn.net/v/t39.35426-6/..."],
  "videoUrls": ["https://video-phl2-1.xx.fbcdn.net/o1/v/t2/f2/m366/..."],
  "cards": [{"title": "Whatnot", "body": "...", "linkUrl": "https://www.whatnot.com/listing/...", "ctaText": "Install Now", "imageUrl": "https://scontent-phl2-1.xx.fbcdn.net/...", "videoUrl": null}],
  "searchInput": "hiking boots",
  "scrapedAt": "2026-11-08T12:08:15Z"
}
```

### Pricing

$0.45 per 1,000 ads on the Free and Bronze plans, less on higher plans:

| Apify plan | Per ad | Per 1,000 ads |
|---|---|---|
| Free, Bronze | $0.00045 | $0.45 |
| Silver | $0.0004 | $0.40 |
| Gold, Platinum, Diamond | $0.0003 | $0.30 |

Plus $0.002 per run. Duplicates are removed before you are charged, so an ad found by two of your searches costs once. Proxy and compute are included.

Set a spending limit on the run and the Actor stops before going over it.

### Facebook Ad Library API without an access token

Call the Actor from your code instead of the official API:

```python
from apify_client import ApifyClient

client = ApifyClient("<YOUR_API_TOKEN>")
run = client.actor("firsthand/facebook-ad-library-api").call(run_input={
    "searchQueries": ["hiking boots"],
    "country": "US",
    "adStatus": "active",
    "maxAdsPerTarget": 500,
})
items = client.dataset(run.default_dataset_id).list_items().items
for ad in items:
    print(ad["pageName"], ad["startDate"], ad["linkUrl"])
```

Field names from other Ad Library Actors work here too: `urls`, `startUrls` with `{"url": ...}`, `searchTerms`, `keywords`, `pageIds`, `resultsLimit`, `limitPerSource`, `maxItems`, `countryCode`, `activeStatus`, `mediaType`, `onlyAdsNewerThan`.

### Filters

| Input | Values | Notes |
|---|---|---|
| `country` | Two-letter code or `ALL` | Empty means US |
| `adStatus` | `active`, `inactive`, `all` | Empty means active |
| `adMediaType` | `all`, `image_and_meme`, `image`, `meme`, `video`, `none` | |
| `dateFrom`, `dateTo` | `YYYY-MM-DD`, or `30 days` | The Library filters by the days an ad was shown, not by its start date: an ad running since last year is in every range up to today |
| `sortOrder` | `relevance`, `impressions` | `impressions` puts the most-seen ads first |
| `exactPhrase` | true or false | Match the whole phrase instead of all words |

For filters not listed here (platform, language, ad category), set them in the Ad Library and paste the link into **Ad Library URLs**.

### Good to know

- **What is public.** The Ad Library shows ads that ran on Meta in the last years. Ad text, creatives, dates and the advertiser page are published for all ads; spend, impressions and reach mostly only for political and issue ads and for ads shown in the EU.
- **Single ad links** (`/ads/library/?id=...`) are not accepted as input; use a search link or the page.
- **The counter is an estimate.** A search can return a little fewer ads than the Ad Library counter shows, see `SUMMARY`.
- **Use of the data.** The Ad Library is published by Meta for transparency. Ads contain advertiser names and sometimes people's names and faces. You are responsible for how you use the data, including GDPR where it applies and Meta's terms. Nothing here is legal advice.
- **Not affiliated with Meta.** Facebook, Instagram and Meta are trademarks of Meta Platforms, Inc.
- **Problems.** Open an issue on the Issues tab with the input of the run and what you expected.

# Actor input Schema

## `searchQueries` (type: `array`):

Keywords to search in the Meta Ad Library, one per line, for example a brand, product or niche. Each term is a separate search.

## `pageUrls` (type: `array`):

Advertisers to scrape all ads of: a Facebook page URL (https://www.facebook.com/nike), a numeric page ID (15087023444) or an Ad Library link with view_all_page_id.

## `startUrls` (type: `array`):

Search links copied from facebook.com/ads/library with your filters already set (country, status, media type, platforms, language, dates, sort). The link's own filters are used as they are; the filter fields below apply only to search terms and pages.

## `country` (type: `string`):

Two-letter country code where the ads ran (US, GB, DE, FR, BR, ...) or ALL. Empty means US.

## `adStatus` (type: `string`):

Active ads only, inactive (stopped) ads only, or all. Empty means active.

## `adMediaType` (type: `string`):

Only ads with this kind of creative. Empty means all.

## `dateFrom` (type: `string`):

Only ads that were shown on or after this date (YYYY-MM-DD, or relative like 30 days). This is the Ad Library date filter: an ad still running since last year counts as shown in every date range up to today.

## `dateTo` (type: `string`):

Only ads that were shown on or before this date (YYYY-MM-DD).

## `sortOrder` (type: `string`):

Order of the Ad Library results. Empty means the library's default order (relevance).

## `exactPhrase` (type: `boolean`):

Match the search term as an exact phrase instead of all words in any order.

## `maxAdsPerTarget` (type: `integer`):

Stop each search term, page or URL after this many unique ads. Empty means all ads the library returns. Large searches are split automatically into smaller parts, which keeps them fast; you pay per unique ad either way.

## `maxItems` (type: `integer`):

Stop the whole run after this many unique ads across all searches. Empty means no total limit.

## Actor input object example

```json
{
  "searchQueries": [
    "hiking boots"
  ],
  "country": "US",
  "maxAdsPerTarget": 100
}
```

# Actor output Schema

## `results` (type: `string`):

No description

## `summary` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "searchQueries": [
        "hiking boots"
    ],
    "country": "US",
    "maxAdsPerTarget": 100
};

// Run the Actor and wait for it to finish
const run = await client.actor("firsthand/facebook-ad-library-api").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "searchQueries": ["hiking boots"],
    "country": "US",
    "maxAdsPerTarget": 100,
}

# Run the Actor and wait for it to finish
run = client.actor("firsthand/facebook-ad-library-api").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "searchQueries": [
    "hiking boots"
  ],
  "country": "US",
  "maxAdsPerTarget": 100
}' |
apify call firsthand/facebook-ad-library-api --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,firsthand/facebook-ad-library-api"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/jqETByQRJIN6AZWpI/builds/sAeG6JkUTLCtmmJXF/openapi.json
