# Meta Ads Library Scraper (Optimized for Devs) (`hoang_minh_quan/meta-ads-library-scraper`) Actor

Fast batch scrape of public Meta Ad Library ads by page ID or keyword. Clean JSON for developers — no personal user PII.

- **URL**: https://apify.com/hoang\_minh\_quan/meta-ads-library-scraper.md
- **Developed by:** [Hoang Minh Quan](https://apify.com/hoang_minh_quan) (community)
- **Categories:** E-commerce
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $6.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Meta Ads Library Intelligence API — Detect NEW, CHANGED & STOPPED Competitor Creatives Automatically

**Stop screenshotting Ad Library. Get structured ad intelligence with snapshot diffs and real-time alerts.**

***

### The problem

Competitor research on Meta’s Ad Library is a time sink:

- Analysts waste **hours clicking page IDs** and copying creatives into spreadsheets.
- Raw scrapers dump **thousands of ads with no context** — you still don’t know what *changed* since yesterday.
- Winning ads go dark overnight; new hooks launch Monday morning — and your team finds out **days late**.
- Manual monitoring doesn’t scale across **10–50 competitor pages** and multiple markets.

If your agency or growth team still “checks Ad Library when we remember,” you’re flying blind between audits.

***

### The solution

This Actor turns the **public Meta Ad Library** into a **monitoring intelligence layer**:

1. **Scrape** — Batch extract ads by Facebook Page ID and/or keyword, country, and media type.
2. **Snapshot** — Persist a durable fingerprint of each creative in Apify Key-Value Store.
3. **Delta** — On every scheduled run, tag ads as **NEW**, **CHANGED**, **STOPPED**, or still **active** — plus **winners** (ads that stay live long enough to matter).
4. **Alert** — Push material changes to **Webhook** (Slack / Discord / Zapier) or **Telegram** so humans only wake up when something moves.

You don’t buy “more rows.” You buy **signal**: what competitors launched, edited, or killed — without staring at the Library UI.

> Public advertiser creatives & page metadata only. **No end-user / viewer PII.**

***

### Key features

- **Batch competitor watchlists** — `pageIds[]` and `keywords[]` in one run
- **Creative fingerprinting** — hash of body, title, CTA, link & format to detect copy/creative edits
- **NEW / CHANGED / STOPPED detection** — vs prior snapshot (baseline on first run)
- **Winner flags** — active ads live ≥ N days (`winnerMinDays`, default 14)
- **Webhook + Telegram alerts** — only on material changes (configurable)
- **Residential proxy + retries** — built for Meta’s bot defenses
- **Developer-ready JSON** — flat dataset rows + `OUTPUT` summary for pipelines
- **Concurrency control** — scrape 1–3 targets in parallel safely

***

### Quick start (Try for free)

1. Open the Actor in [Apify Console](https://console.apify.com/actors/bbbGzgvRefrBxyeht).
2. Prefill uses a demo Page ID — click **Start** with residential proxy on.
3. First run = **baseline** (snapshot saved). Second run (or Schedule daily) = **deltas + alerts**.

```json
{
  "pageIds": ["559929417490965"],
  "country": "US",
  "maxAdsPerTarget": 50,
  "enableMonitor": true,
  "winnerMinDays": 14,
  "useApifyProxy": true,
  "proxyCountry": "US",
  "webhookUrl": "https://hooks.slack.com/services/YOUR/WEBHOOK",
  "notifyOnlyOnChanges": true
}
```

**Pro tip:** Create a **daily Schedule**. Wire `webhookUrl` or Telegram once. Then stop opening Ad Library by hand.

***

### Input reference

| Field | Type | Default | Description |
|---|---|---|---|
| `pageIds` | `string[]` | `[]` | Facebook Page IDs to monitor (preferred for brand tracking) |
| `keywords` | `string[]` | `[]` | Ad Library keyword searches (category / discovery) |
| `pageId` / `keyword` | `string` | — | Legacy single-value aliases |
| `country` | `string` | `"US"` | Ad Library country (ISO, e.g. `US`, `GB`, `VN`) |
| `activeStatus` | `string` | `"active"` | `active` | `inactive` | `all` |
| `mediaType` | `string` | `"all"` | `all` | `image` | `video` | `meme` | `none` |
| `maxAdsPerTarget` | `integer` | `50` | Cap per page/keyword (1–200) |
| `scrollRounds` | `integer` | `8` | Scroll / load-more depth (1–30) |
| `maxAttempts` | `integer` | `3` | Retries with fresh residential session |
| `concurrency` | `integer` | `1` | Parallel targets (1–3) |
| `useApifyProxy` | `boolean` | `true` | **Strongly recommended** — Meta blocks most datacenter IPs |
| `proxyCountry` | `string` | `"US"` | Residential exit country |
| `failOnTargetError` | `boolean` | `false` | Fail whole run if one target fails |
| `enableMonitor` | `boolean` | `true` | Snapshot diff → NEW / CHANGED / STOPPED / winners |
| `snapshotStoreName` | `string` | `"meta-ads-intel-snap-v1"` | Named KVS for durable snapshots |
| `winnerMinDays` | `integer` | `14` | Min longevity days to flag `isWinner` |
| `webhookUrl` | `string` | — | POST JSON alerts (Slack / Discord / Zapier) |
| `telegramBotToken` | `string` | — | Telegram bot token (secret) |
| `telegramChatId` | `string` | — | Telegram chat / channel ID |
| `notifyOnlyOnChanges` | `boolean` | `true` | Skip alerts on quiet runs |
| `dryRunNotify` | `boolean` | `false` | Log alert payload without sending |

***

### Output

#### Dataset row (per ad)

```json
{
  "adArchiveId": "123456789012345",
  "pageId": "559929417490965",
  "pageName": "Demo Brand",
  "isActive": true,
  "startDate": "2026-01-10T00:00:00.000Z",
  "longevityDays": 42,
  "title": "Summer Sale — 50% Off",
  "bodyText": "Shop the drop before it’s gone.",
  "ctaText": "Shop Now",
  "ctaType": "SHOP_NOW",
  "linkUrl": "https://example.com/sale",
  "displayFormat": "VIDEO",
  "mediaUrls": ["https://cdn.example/creative.mp4"],
  "platforms": ["FACEBOOK", "INSTAGRAM"],
  "libraryUrl": "https://www.facebook.com/ads/library/?id=123456789012345&country=US",
  "fingerprint": "v1.a1b2c3d4e5f67890",
  "changeType": "new",
  "changedFields": [],
  "firstSeenAt": "2026-08-06T15:00:00.000Z",
  "lastSeenAt": "2026-08-06T15:00:00.000Z",
  "isWinner": true,
  "country": "US",
  "scrapedAt": "2026-08-06T15:00:00.000Z"
}
```

**`changeType` values:** `baseline` · `new` · `changed` · `active` · `stopped`

#### `OUTPUT` key-value summary

```json
{
  "total": 48,
  "new": 3,
  "changed": 1,
  "stopped": 2,
  "winners": 11,
  "isBaseline": false,
  "totalAds": 48,
  "country": "US",
  "alerts": [
    {
      "type": "NEW",
      "adArchiveId": "123456789012345",
      "pageName": "Demo Brand",
      "title": "Summer Sale — 50% Off",
      "libraryUrl": "https://www.facebook.com/ads/library/?id=123456789012345&country=US"
    }
  ],
  "notifyResult": { "sent": true, "results": { "webhook": { "ok": true, "status": 200 } } },
  "scrapedAt": "2026-08-06T15:00:00.000Z"
}
```

***

### Use cases

#### 1. Performance creative agency (retainer)

Watch 20 client competitors daily. When a rival launches a new hook or kills a long-running winner, Slack pings the strategist **before the weekly deck**. Sell it as “competitive creative radar” — not “we scrape Facebook.”

#### 2. DTC / e-com brand growth team

Track category keywords (`serum`, `protein powder`, brand names) plus direct rival Page IDs. Use **winners** (14+ day longevity) as a shortlist for swipe-file research and angle testing — without drowning in one-day tests.

#### 3. Ad intelligence SaaS / internal tools

Ingest the dataset + `OUTPUT` into your warehouse or product. Fingerprints and change types become first-class events for dashboards, CRM tasks, or AI creative brief pipelines.

***

### How monitoring works

```
Run 1  →  scrape ads  →  save snapshot  →  changeType = baseline  (no alerts)
Run 2+ →  scrape ads  →  diff vs snapshot  →  NEW / CHANGED / STOPPED  →  webhook / Telegram
         →  write next snapshot
```

Schedule **daily** (or every 6–12 hours for hot categories). Keep `notifyOnlyOnChanges: true` so quiet days stay silent.

***

### Compliance & ethics

- Sources **public** Meta Ad Library data only.
- Does **not** collect end-user, viewer, or private account PII.
- You are responsible for lawful use under your jurisdiction and Meta’s terms for the Library.

***

### Call to action

**Try it free on Apify** → run the prefill Page ID once, then Schedule a second run tomorrow morning.

Want always-on competitor radar? Add your `webhookUrl` or Telegram credentials and set a **daily schedule**. Your team gets deltas — not dumps.

**Actor:** [Meta Ads Library Scraper + Change Intelligence](https://console.apify.com/actors/bbbGzgvRefrBxyeht)\
**ID:** `bbbGzgvRefrBxyeht`

# Actor input Schema

## `pageIds` (type: `array`):

Batch of Meta/Facebook Page IDs to scrape (e.g. 559929417490965). Preferred for brand monitoring.

## `keywords` (type: `array`):

Keyword searches in Ad Library (unordered). Useful for category / competitor discovery.

## `pageId` (type: `string`):

Optional single page ID (same as adding one entry to pageIds).

## `keyword` (type: `string`):

Optional single keyword (same as adding one entry to keywords).

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

ISO country code for Ad Library results (US, VN, GB, …).

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

Filter: active | inactive | all

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

Filter: all | image | video | meme | none

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

Cap ads returned for each pageId/keyword (1–200).

## `scrollRounds` (type: `integer`):

How many scroll + load-more rounds per target.

## `maxAttempts` (type: `integer`):

Retries with a fresh residential proxy session.

## `concurrency` (type: `integer`):

How many pageId/keyword targets to scrape in parallel (1–3). Higher = faster but more proxy usage.

## `useApifyProxy` (type: `boolean`):

Strongly recommended. Meta blocks most datacenter IPs.

## `proxyCountry` (type: `string`):

Residential proxy exit country (ISO 2-letter). Prefer US for Ad Library.

## `failOnTargetError` (type: `boolean`):

If false (default), failed targets are logged and other targets continue.

## `enableMonitor` (type: `boolean`):

Compare this run to the previous KVS snapshot and tag ads as new / changed / stopped / winners.

## `snapshotStoreName` (type: `string`):

Named KVS for durable ad snapshots across scheduled runs.

## `winnerMinDays` (type: `integer`):

Active ads running at least this many days are flagged isWinner.

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

POST JSON alerts when material changes are detected.

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

Optional Telegram BotFather token for change alerts.

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

Chat / channel ID that receives Telegram alerts.

## `notifyOnlyOnChanges` (type: `boolean`):

Skip webhook/Telegram on quiet runs (no NEW/CHANGED/STOPPED).

## `dryRunNotify` (type: `boolean`):

Log alert payload without sending webhook/Telegram.

## Actor input object example

```json
{
  "pageIds": [
    "559929417490965"
  ],
  "keywords": [],
  "country": "US",
  "activeStatus": "active",
  "mediaType": "all",
  "maxAdsPerTarget": 50,
  "scrollRounds": 8,
  "maxAttempts": 3,
  "concurrency": 1,
  "useApifyProxy": true,
  "proxyCountry": "US",
  "failOnTargetError": false,
  "enableMonitor": true,
  "snapshotStoreName": "meta-ads-intel-snap-v1",
  "winnerMinDays": 14,
  "notifyOnlyOnChanges": true,
  "dryRunNotify": false
}
```

# Actor output Schema

## `ads` (type: `string`):

Dataset of Meta Ad Library creatives + change types

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

OUTPUT JSON summary in the default key-value store

# 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 = {
    "pageIds": [
        "559929417490965"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("hoang_minh_quan/meta-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 = { "pageIds": ["559929417490965"] }

# Run the Actor and wait for it to finish
run = client.actor("hoang_minh_quan/meta-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 '{
  "pageIds": [
    "559929417490965"
  ]
}' |
apify call hoang_minh_quan/meta-ads-library-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,hoang_minh_quan/meta-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/bbbGzgvRefrBxyeht/builds/c4qT3daDKv8fj14zS/openapi.json
