# Facebook Ads Library Scraper (`datahamster/facebook-ads-library-scraper`) Actor

Facebook Ads Library scraper for Meta ads by keyword, advertiser Page or Ad Library link: ad id, Page, dates, status, platforms, text, link, CTA, images, videos, political spend and impressions. All filters, no login, no browser. Monitor mode returns only new ads.

- **URL**: https://apify.com/datahamster/facebook-ads-library-scraper.md
- **Developed by:** [Viktor Dubnytskiy](https://apify.com/datahamster) (community)
- **Categories:** Social media, Lead generation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.80 / 1,000 result items

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
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 Ads Library Scraper

Facebook Ads Library Scraper returns ads from the public Meta Ad Library by keyword, by advertiser Page or from any Ad Library search link, one row per ad with the ad id and link, the advertiser Page, start and end dates, active flag, platforms, ad text, headline, landing page link, call to action, image and video URLs, carousel cards and the number of ads that share the creative. Political and issue ads also carry the public spend and impressions ranges and the paid-for-by disclaimer. No Facebook account, cookies or API key needed.

**Try it:** the prefilled example returns 20 rows in about 33 seconds and costs about $0.02 (results plus platform usage). Results cost $1.00 per 1,000.

**Coverage:** every search is read page by page (10 ads per request) until your limit or the end of Facebook's results. Platform usage is paid by you and comes on top of the result price: the actor reads ads through Apify residential proxy, which cost about $0.04 per 1,000 ads in our measurement (1,000 ads, 10.3 MB of residential traffic, 512 MB memory). Facebook shows no spend or impressions for commercial ads, and EU reach figures live on each ad's detail panel, which this actor does not open.

### Why this one

- **Monitor mode with alerts for new ads.** Save a keyword or a competitor's Page as a task and schedule it: the first run records the ads it sees, every later run returns only ads that were not there before and can post a summary to your webhook or Telegram. The two leading Ad Library scrapers have no monitor mode in their input: every run returns all matching ads again.
- **Plain keywords and filters as input, no URL building.** Type `nike`, pick the country, active status, ad category (political, housing, employment, financial), media type, platforms, ad language, exact phrase and the date range in the form. The most used alternative accepts only Ad Library or Page URLs and has no fields for ad category, media type, platform or language. Pasting Ad Library links and Page links works here too, and a Page link is turned into its Ad Library id for you.
- **Political ads with public spend, impressions and reach ranges** plus the paid-for-by organisation, in their own columns.
- **No browser.** The actor talks to the Ad Library over plain HTTP, so 1,000 ads took 237 seconds on 512 MB in our test.
- **Price:** $1.00 per 1,000 ads plus platform usage (about $0.04 per 1,000, paid by you). apify/facebook-ads-scraper charges $5.80 per 1,000 on the free plan with usage included; curious_coder/facebook-ads-library-scraper charges $0.75 per 1,000 plus $0.00005 per run start with usage included, which is cheaper than this actor per ad.

### What you get

Real rows from the example dataset:

| pageName | startDate | publisherPlatforms | displayFormat | title | ctaText | collationCount |
|---|---|---|---|---|---|---|
| Nike | `2025-06-20` | facebook, instagram | DPA | Nike Air Monarch IV | Shop now | `None` |
| Nike | `2026-10-23` | facebook, instagram | DPA | Nike Air Monarch IV | Shop now | `None` |
| Nike | `2026-10-23` | facebook, instagram | DPA | Nike Air Monarch IV | Shop now | `None` |
| Whatnot | `2026-08-20` | facebook, instagram, messenger | DPA | Whatnot: Shop, Sell, Connect | Install now | `None` |

Full row: `id`, `url`, `adArchiveId`, `adLibraryUrl`, `pageId`, `pageName`, `pageUrl`, `pageProfilePictureUrl`, `pageCategories`, `advertiserMasked`, `pageLikeCount`, `isActive`, `startDate`, `endDate`, `startTimestamp`, `endTimestamp`, `publisherPlatforms`, `displayFormat`, `bodyText`, `title`, `linkUrl`, `linkDescription`, `caption`, `ctaText`, `ctaType`, `images`, `videos`, `cards`, `collationCount`, `collationId`, `categories`, `spend`, `impressions`, `reachEstimate`, `currency`, `paidForBy`, `disclaimerLabel`, `countryCode`, `targetedOrReachedCountries`, `totalActiveTimeSeconds`, `containsSensitiveContent`, `containsAiGeneratedMedia`, `source`, `query`, `scrapedAt`.

`collationCount` is Facebook's "N ads use this creative" count. Catalogue ads whose text is a template such as `{{product.name}}` get the text of their first card instead.

### Input

- **Search keywords**: words to look for in ads, such as `nike`. Use **Exact phrase** for phrase search.
- **Advertiser Pages**: Page links (`https://www.facebook.com/nike`), numeric Page ids, or Ad Library links with `view_all_page_id`.
- **Ad Library URLs**: paste a search from facebook.com/ads/library and its filters are used as they are.
- **Filters**: country (or ALL), active or inactive ads, ad category (political and issue, housing, employment, financial), media type, platforms, ad languages, the date range when ads were shown, and sort order.

### Monitor mode

Save the input as a task and set **Mode** to Monitor. Each keyword, Page or Ad Library link is watched separately, and monitor runs read Facebook's "Most recent" order.

- The first run of a search records the ads it reads (up to **Max ads per keyword or Page**) and pushes nothing; the run summary says `baseline`.
- Later runs return an ad (`changeType: "new"`) when its id was never seen by that search and it started no more than 2 days before the newest ad the search has seen. Ads appear in the Library within hours of their start, so a genuinely new ad passes; an unseen ad that started earlier (one that sat deeper than the previous read, since Facebook's "Most recent" order is grouped by month and not strictly newest first) is recorded silently, not sold as new. Each run reads up to **Max ads per keyword or Page** of ads it does not know yet, so an out-of-order page of older ads does not hide new ones after it.
- What can still come out as new without being new: an ad that started within about 2 days before the baseline but was not among the ads the baseline read. A higher **Max ads per keyword or Page** makes this rarer.
- A run with nothing new says `no_new_items` in the run summary and charges only the monitor check.
- Changing a search's keyword, filters, country or **Max ads per keyword or Page** starts a new baseline for it; adding a keyword gives that keyword its own baseline while the others keep reporting.
- A run that Facebook blocks pushes and charges nothing and keeps the previous state. If a run crashes, the monitor state stays locked until that run's timeout and later runs end as `overlapping_run`; wait or use a new `monitorStateId`.
- Add a webhook URL or a Telegram bot to get a summary of the new ads.

### Limits

- Facebook publishes spend, impressions and reach only for political and issue ads; for other ads these fields are empty.
- EU audience breakdowns and the per-ad detail panel are not read.
- Facebook returns 10 ads per request; a search with tens of thousands of ads takes about 4 minutes per 1,000 ads.
- Facebook rate-limits logged-out searches from datacenter IPs, so every search goes through residential proxy (its traffic is your platform usage). If Facebook still refuses after three fresh residential exits, the run stops that search and says so in the log.
- Ad text, links and media are returned as Facebook shows them; tracking macros in landing page links (such as `{{campaign.name}}`) are left as published.

### Privacy

Most advertisers in the Ad Library are business Pages, and the actor returns the Page and its ads as Facebook publishes them. Some ads are run by personal profiles (Facebook files them under the category "Profile" or "Personal blog"; 8 of 1,000 ads for "shoes" in our test): for those the ad is kept, but the advertiser's name, link, id and picture are left out and `advertiserMasked` is `true`. A paid-for-by disclaimer is written only when it matches an organisation pattern (Inc, LLC, PAC, Party, Committee, Foundation, "for Senate", "Friends of" and the like) and is not just a two or three word name. Personal profiles are not accepted as input.

### Pricing

$1.00 per 1,000 ads ($0.001 per ad; $0.0009 on Silver, $0.0008 on Gold and higher plans). Monitor mode: $0.005 per run plus $0.001 per new ad. Platform usage (mostly residential proxy traffic, about $0.04 per 1,000 ads) is billed by Apify to your account. If the actor works for you, a short review on the Store helps a lot.

### Related actors

- [Facebook Pages Search](https://apify.com/datahamster/facebook-pages-search) finds business Pages by keyword with their contacts; feed the Page links into this actor.
- [LinkedIn Ad Library Scraper](https://apify.com/datahamster/linkedin-ad-library-scraper) does the same for LinkedIn ads.
- [Google Ads Transparency](https://apify.com/datahamster/google-ads-transparency) lists an advertiser's Google ads.
- [Facebook Groups Search](https://apify.com/datahamster/facebook-groups-search) finds public groups by keyword.

### FAQ

**Do I need a Facebook account?** No.

**Why are spend and impressions empty?** Facebook publishes them only for political and issue ads.

**Facebook changed something and the run is empty?** The run summary (`RUN_SUMMARY` in the key-value store) says why: blocked, rate_limited or no_matches. Facebook rotates its internal query id from time to time; the actor reads the new one from Facebook's own scripts.

### Changelog

- 0.1: first release: keyword, Page and Ad Library link search with all Ad Library filters, plain-HTTP route without a browser, political spend and impressions, monitor mode for new ads.

# Actor input Schema

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

Keywords to search in the Ad Library, one per line, such as nike or running shoes. Facebook matches the ad text, title and advertiser name.

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

Facebook business Pages whose ads you want: a Page link such as https://www.facebook.com/nike, a numeric Page id, or an Ad Library link with view_all_page_id. One per line. Personal profiles and groups are not supported.

## `adLibraryUrls` (type: `array`):

Search links copied from facebook.com/ads/library in your browser. Their own filters (country, ad type, status, media, platforms, dates, sort) are used instead of the filters below.

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

Two-letter country code where the ads ran, such as US, GB or DE, or ALL for every country. Political and issue ads need a single country.

## `activeStatus` (type: `string`):

Which ads to return.

## `adType` (type: `string`):

Political and issue ads come with public spend, impressions and a paid-for-by disclaimer.

## `mediaType` (type: `string`):

Filter by the ad's media.

## `publisherPlatforms` (type: `array`):

Optional: only ads shown on these platforms, one per line: facebook, instagram, messenger, audience_network, threads.

## `contentLanguages` (type: `array`):

Optional: two-letter language codes of the ad text, such as en or de.

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

Match the keywords as an exact phrase instead of any order.

## `startDateFrom` (type: `string`):

Optional, YYYY-MM-DD: only ads shown on or after this date (Facebook's impression date filter).

## `startDateTo` (type: `string`):

Optional, YYYY-MM-DD: only ads shown on or before this date.

## `sortBy` (type: `string`):

Order in which Facebook returns the ads. Monitor mode always uses Most recent.

## `maxResultsPerSource` (type: `integer`):

Stop reading one keyword, Page or Ad Library link after this many ads.

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

Stop after this many ad rows in total (you are charged only for pushed rows). In monitor mode: new ads per run.

## `mode` (type: `string`):

scrape = full results; monitor = only new/changed items since the previous run of this task

## `monitorStateId` (type: `string`):

Optional state id when not running as a saved task (monitor mode)

## `webhookUrl` (type: `string`):

POST a change summary here in monitor mode

## `telegramBotToken` (type: `string`):

Optional: bot token for monitor-mode change summaries

## `telegramChatId` (type: `string`):

Optional: chat id that receives monitor-mode summaries

## Actor input object example

```json
{
  "searchQueries": [
    "nike"
  ],
  "country": "US",
  "activeStatus": "active",
  "adType": "all",
  "mediaType": "all",
  "exactPhrase": false,
  "sortBy": "impressions",
  "maxResultsPerSource": 20,
  "maxItems": 20,
  "mode": "scrape"
}
```

# Actor output Schema

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

All pushed rows (dataset, JSON)

## `resultsTable` (type: `string`):

Dataset in the Console viewer

## `runSummary` (type: `string`):

RUN_SUMMARY record

# 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": [
        "nike"
    ],
    "country": "US",
    "maxResultsPerSource": 20,
    "maxItems": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("datahamster/facebook-ads-library-scraper").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": ["nike"],
    "country": "US",
    "maxResultsPerSource": 20,
    "maxItems": 20,
}

# Run the Actor and wait for it to finish
run = client.actor("datahamster/facebook-ads-library-scraper").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": [
    "nike"
  ],
  "country": "US",
  "maxResultsPerSource": 20,
  "maxItems": 20
}' |
apify call datahamster/facebook-ads-library-scraper --silent --output-dataset

```

## MCP server setup

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

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/mvYZxXE6CD7xBLrKO/builds/Kva0nlcV6az8I5x6f/openapi.json
