# Meta Ad Library Scraper — Resume, Media & $0-on-Block (`domestic_buffalograss/meta-ad-library-reliable`) Actor

Search the Meta Ad Library by keyword and country. Returns ad copy, landing URL, CTA type, days running, placement mix, the country each ad was found in, and creative image/video URLs. Never charged for blocked runs.

- **URL**: https://apify.com/domestic_buffalograss/meta-ad-library-reliable.md
- **Developed by:** [Sumitsubo](https://apify.com/domestic_buffalograss) (community)
- **Categories:** Social media
- **Security:** Limited permissions
- **Stats:** 3 total users, 2 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.80 / 1,000 ad scraped (1 result)s

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

## Meta Ad Library Scraper — Facebook & Instagram Ads, Resume & $0-on-Block

### Introduction

Search the [Meta Ad Library](https://www.facebook.com/ads/library/) by **brand or keyword and country** and get the matching Facebook, Instagram and Messenger ads as clean, flat rows: ad copy, landing URL, call to action, start date, **how many days it has been running**, and the creative's image and video URLs.

It is built for the jobs where other Ad Library scrapers get frustrating — large pulls that crash half way, and runs that bill you even though Meta blocked them:

- a killed or timed-out run **continues where it stopped** instead of starting over,
- every failure is **written to the dataset**, never silently dropped,
- a blocked or rate-limited request is **not billed**.

> This is an independent tool. It is **not affiliated with, endorsed by, or sponsored by Meta**.
> Meta, Facebook and Instagram are trademarks of Meta Platforms, Inc., used here only to say which
> public service this Actor reads.

![The dataset Overview for a Nike search: advertiser, country, ad ID, start date, days running, active flag, collation count and landing URL](https://api.apify.com/v2/key-value-stores/sO2jMOEhhYOvxrbaH/records/1-dataset-overview.png)

*A 20-ad search for `Nike` in the US. The keyword matches Nike's own page and also other advertisers whose ads mention Nike — in this run JD Sports, Foot Locker, Depop, Whatnot, Walmart and others — which is why the advertiser name is on every row.*

### What you get for every ad

| Field | Example |
|---|---|
| `page_name` / `page_id` | `Nordstrom Rack` / `89516513179` — the advertiser's Facebook page |
| `ad_archive_id` | `925321173274919` — the Ad Library ID of the ad |
| `country` | `US` — the country library the ad was found in (the Ad Library is per-country) |
| `ad_delivery_start` / `ad_delivery_stop` | `2026-08-03` / `null` (still running) |
| `duration_days` | `53` — how long the ad has been running — a common signal of which ads are working |
| `is_active` | `true` |
| `publisher_platforms` | `["FACEBOOK", "INSTAGRAM", "MESSENGER"]` |
| `ad_creative_bodies` | the ad's text: body, headline and caption (and each carousel card's body and headline), duplicates removed |
| `collation_count` | `2` — passed through as the Ad Library reports it |
| `landing_url` / `cta_type` | where the ad sends people, and the button (`SHOP_NOW`, `LEARN_MORE`, …) |
| `image_urls` / `video_urls` | **all** creative URLs found, full resolution. For reference only — never downloaded, never billed |
| `media` | the creative files that are **downloaded to key-value storage** in `snapshot_with_media` mode; `stored_key` tells you where each one was saved |
| `_meta` | when and from which URL the row was collected, plus the Actor and schema version |

Export to JSON, CSV or Excel, or read it from the API.

> **One note on spreadsheets.** Page names and ad copy are written by the advertiser, not by us, and a
> value starting with `=`, `+`, `-` or `@` is treated as a formula by Excel and Sheets. If you open
> exports directly, import them as text rather than double-clicking the file.

### Why this scraper

- **Resume.** A killed or timed-out run continues exactly where it stopped — no re-fetching, no double charges. That is what makes a 5,000+ ad pull across several advertisers practical: it doesn't have to finish in one sitting.
- **No silent loss.** Every work unit is checkpointed. A failure is written to the dataset as an `{_error, _reason}` record so you can see what is missing — never just dropped.
- **Not billed when blocked.** A blocked or rate-limited request is detected and not billed. You pay for ads actually delivered.
- **Real media files.** Optionally download the creative videos and images into key-value storage, not just links, so you keep your own copy.
- **Hard cost ceilings.** `maxItems` and `maxBudgetUsd` are enforced across resumes, so a large pull never runs past the number you set.
- **A stable schema.** Flat, null-safe `snake_case` with `duration_days` and `_meta` on every row, so it drops straight into a pipeline.

### Pricing

Pay per event — no subscription, no charge for data you didn't ask for.

| Event | Price |
|---|---|
| `actor-start` | $0.01 per run |
| `ad-scraped` | $0.001 per ad |
| `media-downloaded` | $0.01 per file (only in `snapshot_with_media`) |

`actor-start` is charged once per run, when the first search completes — whether or not it finds any ads. A run in which every request is blocked or rate-limited costs **nothing**, the start included. You are never charged per blocked request, or for ads beyond `maxItems` / `maxBudgetUsd`.

Apify Store discounts lower the per-ad price on higher plans: $0.0009 at the Silver discount tier, $0.0008 at Gold and above.

#### Typical cost

| What you're doing | Typical cost |
|---|---|
| Trying it out — 200 ads from one keyword | about **$0.21** |
| A full competitive pull — 5,000 ads across several advertisers/countries | about **$5.01** |
| With media downloads (`snapshot_with_media`) | add $0.01 per file archived |

### Use cases

- **Competitor ad research** — see every ad a brand and its resellers are running, with start dates and days running as a signal of what's working.
- **Creative swipe files** — pull ad copy and creatives, and archive the files into your own storage.
- **Market mapping** — search a category keyword across several countries and see who is advertising where.
- **Agency reporting** — schedule a run and send the results to Sheets, Slack or a webhook with Apify integrations.
- **AI agents** — connect through the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp) and let your agent look up live ads.

### Tutorial

1. Open the **Input** tab and enter a brand or keyword in **Search terms** — or keep the prefilled `Nike`.
2. Set **Countries** (two-letter codes; the default is `US`). Each country is searched separately.
3. Set **Max ads** to what you want to pay for at most. For a first try, 20–200 is plenty.
4. Choose **Mode**: `Snapshot` for ad data only, or `Snapshot + download media files` to also keep the creatives.
5. Click **Start**, then open the **Output** tab, or read the dataset from the API.

To keep an eye on a competitor, save the input as a [task](https://docs.apify.com/platform/actors/running/tasks) and put it on a [schedule](https://docs.apify.com/platform/schedules).

### Input reference

| Field | Meaning |
|---|---|
| `advertisers` | **Required.** Keywords to search the Ad Library for. This is a **keyword search, not an exact advertiser filter** — `Nike` also returns retailers and resellers whose ads mention Nike. Page IDs are not supported |
| `countries` | ISO country codes. The Ad Library is per-country; default `US` |
| `mode` | `snapshot` (ads only) or `snapshot_with_media` (also download creative files) |
| `maxItems` | Hard cap on billable ads — you are never charged beyond this, across resumes included |
| `maxBudgetUsd` | Optional hard USD ceiling; the run stops before exceeding it. `0` charges nothing |

This Actor uses Apify's **residential proxy**, which Meta's Ad Library requires. You don't need to configure it; if your account can't use residential proxy, the run stops at the start with a clear message instead of failing half way.

### Input and output examples

#### Input example

```json
{
  "advertisers": ["Nike"],
  "countries": ["US"],
  "mode": "snapshot",
  "maxItems": 20
}
```

#### Output example

A real row from the run in the screenshot above (media URLs shortened):

```json
{
  "ad_archive_id": "925321173274919",
  "country": "US",
  "page_id": "89516513179",
  "page_name": "Nordstrom Rack",
  "ad_delivery_start": "2026-08-03",
  "ad_delivery_stop": null,
  "duration_days": 53,
  "is_active": true,
  "collation_count": 2,
  "publisher_platforms": ["FACEBOOK", "INSTAGRAM", "MESSENGER"],
  "ad_creative_bodies": [
    "Buy online and pick up in store for free! Get up to 70% off Nike, Vince, Madewell, adidas and more.",
    "Fast & Free Pickup",
    "Nordstromrack.com"
  ],
  "media": [{ "kind": "video", "url": "https://video-den2-1.xx.fbcdn.net/…", "stored_key": null }],
  "image_urls": [],
  "video_urls": ["https://video-den2-1.xx.fbcdn.net/…"],
  "landing_url": "https://fb.com/canvas_doc/1072291375736811",
  "cta_type": "LEARN_MORE",
  "_meta": {
    "_scraped_at": "2026-09-25T00:00:00Z",
    "_source_url": "https://www.facebook.com/ads/library/?active_status=all&ad_type=all&country=US&q=Nike",
    "_actor_version": "<actor build version>",
    "_schema_version": "1.2.0"
  }
}
```

`stored_key` is `null` in `snapshot` mode. In `snapshot_with_media` it is filled once the file is saved, so every file you are charged for can be found in the run's key-value store. Downloads are limited to Meta's `fbcdn.net` hosts and capped per ad.

A blocked or failed unit appears as:

```json
{ "_error": true, "_reason": "blocked", "_source_url": "…", "_work_unit": "…" }
```

### FAQ and support

**Can I get spend, impressions, reach or targeting?**
No. Meta does not publish spend, impressions, reach, CTR, ROAS or targeting for commercial ads — only for political/issue ads, or EU reach under the DSA. This Actor does not invent those numbers, and no scraper can get them for commercial ads.

**Why does searching `Nike` return other advertisers?**
The Ad Library search is a keyword search. It returns every ad that matches the word, including retailers and resellers. Filter on `page_name` or `page_id` if you only want one advertiser's own ads. Searching by page ID is not supported.

**My run was stopped or timed out. Do I lose what it collected?**
No. What was collected stays in the dataset, and progress is checkpointed. [Resurrect](https://docs.apify.com/platform/actors/running/runs-and-builds) the run from the Console — it restarts with the same storage and continues where it stopped, without charging again for the run start or for ads already delivered.

**How do I stop a large run from costing more than I planned?**
Set `maxItems`, `maxBudgetUsd`, or both. Both are enforced across resumes.

**Does it log in to Facebook?**
No. It reads the public, logged-out Ad Library only.

**Something doesn't work.**
Open an issue on the **Issues** tab with the run ID, and I'll look at it.

**Found this useful?** A rating on this page helps other people evaluating it decide faster —
it takes a few seconds and means a lot for a small, actively maintained Actor.

# Actor input Schema

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

What to do. 'snapshot' fetches ads once. 'snapshot_with_media' also downloads creative files.

## `advertisers` (type: `array`):

Keywords to search the Meta Ad Library for. This is a keyword search, not an exact advertiser filter: "Nike" also returns retailers and resellers whose ads mention Nike. Page IDs are not supported.

## `countries` (type: `array`):

Two-letter country codes. Ad Library is per-country.

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

Hard cap on billable ads. You are never charged for more than this many ads across the whole run (including resumes).

## `maxBudgetUsd` (type: `number`):

Optional hard USD ceiling (supports decimals, e.g. 0.5). The run stops before exceeding it, and the ceiling persists across resumes. Leave empty for no cap; 0 means charge nothing.

## Actor input object example

```json
{
  "mode": "snapshot",
  "advertisers": [
    "Nike",
    "Coca-Cola"
  ],
  "countries": [
    "US"
  ],
  "maxItems": 500
}
```

# Actor output Schema

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

Every ad this run collected, one row per ad. Never charged for blocked/failed work units.

## `archivedMedia` (type: `string`):

Creative videos/images downloaded to the key-value store. Present only when mode is snapshot_with_media.

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

What the run did: how many ads were fetched, blocked/empty units, and whether billing was active and matched the code's expected prices.

# 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 = {
    "mode": "snapshot",
    "advertisers": [
        "Nike"
    ],
    "countries": [
        "US"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("domestic_buffalograss/meta-ad-library-reliable").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 = {
    "mode": "snapshot",
    "advertisers": ["Nike"],
    "countries": ["US"],
}

# Run the Actor and wait for it to finish
run = client.actor("domestic_buffalograss/meta-ad-library-reliable").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 '{
  "mode": "snapshot",
  "advertisers": [
    "Nike"
  ],
  "countries": [
    "US"
  ]
}' |
apify call domestic_buffalograss/meta-ad-library-reliable --silent --output-dataset

```

## MCP server setup

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

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/zctkgGIZAeea7zBV4/builds/l42zxij5gP71JCXlw/openapi.json
