# Meta Ad Library scraper (Facebook/Instagram) (`data_dino/facebook-ads-scraper`) Actor

Collect structured Facebook and Instagram ad records from the Meta Ad Library — advertisers, spend, impressions, targeting, platforms, and ad text/creative — one dataset item per ad.

- **URL**: https://apify.com/data_dino/facebook-ads-scraper.md
- **Developed by:** [Data Dino](https://apify.com/data_dino) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.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/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)

Collects structured Facebook and Instagram ad records from the **Meta Ad Library** — the public archive of ads running on Meta platforms. One dataset item per ad.

### What you get

For each ad, the scraper captures:

- **Identity** – `ad_archive_id`, ad URL, advertiser page id and name.
- **Delivery** – active status, start/end dates, spend, impressions, reach estimate, publisher platforms, targeted/reached countries.
- **Creative** – ad format, title, body text, caption, link URL, call-to-action, images, videos, and multi-card blocks.
- **Classification** – ad type, categories, archive types, sensitive/digital-media flags.

### How to use

Just hit **Run** — the defaults give you a quick sample of Nike ads (keyword `nike`, US, up to 20 results) in under a minute.

To customize:

1. Choose a search: a **keyword** (default `nike`), an advertiser **Page ID**, or an advertiser **Page name** (auto-resolved).
2. Set the **country** code (default `US`).
3. Optionally filter by active status, ad type, media type, platforms, or a delivery date window.
4. Set a **max results** cap (default 20) to keep runs quick; raise it for a fuller pull.
5. Run. Results appear in the dataset as one item per ad.

### Options

| Field | What it does |
| --- | --- |
| Keyword / Page ID / Page name | How to find the ads (choose one). |
| Country | Two-letter Ad Library country. |
| Active status | `ACTIVE`, `ALL`, or `INACTIVE`. |
| Ad type | Restrict to political/issue, housing, employment, credit, or all. |
| Media type | Filter by creative format (image, video, meme, etc.). |
| Max results | Stop after N ads (0 = unlimited). |
| Include details | Fetch each ad's full transparency block (slower). |
| Compact fields | Emit only core feed fields for smaller records. |
| Request delay | Minimum time between requests (keep ≥ 300 ms). |
| Proxy | Optional proxy URL for network routing. |

### Notes

- The scraper uses the same access path as the Meta Ad Library website and needs no login.
- It paces requests automatically and retries transient failures; you can supply a proxy for network routing.
- Output is one JSON item per ad in the default dataset, viewable and downloadable from the Output tab.

# Actor input Schema

## `query` (type: `string`):

Search ads by keyword (ignored when a Page ID or Page name is set). Default "nike" lets you run instantly.

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

Advertiser page ID — collects every ad published by that page. Takes priority over keyword.

## `pageName` (type: `string`):

Advertiser name, resolved to a page ID automatically. Example: Nike.

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

Two-letter Ad Library country code (ISO 3166-1 alpha-2).

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

Which ad delivery states to include.

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

Restrict to a category of ads (e.g. political/issue ads).

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

Filter by the ad's creative format.

## `searchType` (type: `string`):

Keyword matching mode for the query.

## `maxResults` (type: `integer`):

Stop after this many ads. Default 20 keeps the default run quick; raise it for a fuller pull. 0 = unlimited (use with care).

## `maxPages` (type: `integer`):

Stop after this many result pages (10 ad groups each). 0 = unlimited.

## `includeDetails` (type: `boolean`):

Also fetch each ad's full transparency/detail block (slower).

## `compact` (type: `boolean`):

Emit only the core feed fields (smaller records).

## `excludeEmptyFields` (type: `boolean`):

Drop fields with no value from each record.

## `minDelayMs` (type: `integer`):

Delay between requests. Keep at or above 300 ms.

## `startDate` (type: `object`):

Optional delivery window as JSON: {"min":"YYYY-MM-DD","max":"YYYY-MM-DD"}. Leave empty for all dates.

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

Restrict to platforms, e.g. FACEBOOK, INSTAGRAM, AUDIENCE_NETWORK. Empty = all.

## `proxy` (type: `string`):

Optional HTTP/HTTPS proxy URL, e.g. http://user:pass@host:port. Leave empty for a direct connection.

## Actor input object example

```json
{
  "query": "nike",
  "country": "US",
  "activeStatus": "ACTIVE",
  "adType": "ALL",
  "mediaType": "ALL",
  "searchType": "KEYWORD_UNORDERED",
  "maxResults": 20,
  "maxPages": 0,
  "includeDetails": false,
  "compact": false,
  "excludeEmptyFields": false,
  "minDelayMs": 300,
  "publisherPlatforms": []
}
```

# Actor output Schema

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

All scraped ad records, one item per row. Key fields: ad_archive_id, ad_url, page_id, page_name, is_active, start_date, end_date, spend, impressions, publisher_platforms, targeted_or_reached_countries, display_format, title, body, caption, link_url, cta_text, images, videos, cards, fetched_at.

# 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 = {
    "query": "nike"
};

// Run the Actor and wait for it to finish
const run = await client.actor("data_dino/facebook-ads-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 = { "query": "nike" }

# Run the Actor and wait for it to finish
run = client.actor("data_dino/facebook-ads-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 '{
  "query": "nike"
}' |
apify call data_dino/facebook-ads-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,data_dino/facebook-ads-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/oKr1VhTqLFYDJBIoZ/builds/R9h2eBY7mdGsS3ArP/openapi.json
