# Facebook Ad Library Scraper (`scrapesmith/facebook-ad-library-scraper`) Actor

Scrape the Facebook Ad Library at scale. Extract ad text, images, videos, landing pages, spend ranges, impressions, advertiser info and more. Filter by keyword, advertiser, country, date range, media type. No login or Facebook account needed. Export to JSON, CSV, Excel.

- **URL**: https://apify.com/scrapesmith/facebook-ad-library-scraper.md
- **Developed by:** [Scrape Smith](https://apify.com/scrapesmith) (community)
- **Categories:** Lead generation, Social media, Developer tools
- **Stats:** 2 total users, 2 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.40 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use 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

## Facebook Ad Library Scraper

Scrape ads from the [Facebook Ad Library](https://www.facebook.com/ads/library/) at scale. Extract ad creatives, copy, landing pages, spend data, impressions, and advertiser info — no Facebook account or login required.

### What does Facebook Ad Library Scraper do?

This scraper extracts publicly available ad data from Meta's Ad Library. Use it for competitor analysis, market research, political ad monitoring, or building ad creative databases.

For each ad, you get:

- **Ad creative** — text, title, images, videos, carousel cards
- **Advertiser** — page name, page ID, profile picture, categories, like count
- **Performance** — spend range, impressions, reach (political/issue ads)
- **Metadata** — start/end date, active status, platforms (Facebook, Instagram), display format
- **Targeting** — targeted countries, ad category, content language
- **Links** — destination URL, CTA button, caption, byline
- **Transparency** — advertiser contact info, funding entity (political ads)

### How much does it cost to run?

The scraper uses minimal compute — 256 MB RAM is all it needs. A typical run scraping **1,000 ads costs about $0.03** on Apify platform usage. Add residential proxy cost if you enable it (~$0.03 more for 1,000 ads).

| Ads | Compute | Proxy | Total |
|-----|---------|-------|-------|
| 100 | ~$0.005 | ~$0.003 | ~$0.01 |
| 1,000 | ~$0.03 | ~$0.03 | ~$0.06 |
| 5,000 | ~$0.15 | ~$0.15 | ~$0.30 |

### Input

| Field | Description | Default |
|-------|-------------|---------|
| **Search queries** | Keywords to search for (e.g. "nike", "insurance") | Required* |
| **Advertiser page IDs** | Facebook page IDs for direct lookup | Required* |
| **Country** | ISO country code (US, GB, DE, etc.) | US |
| **Ad category** | All, political, housing, employment, or credit ads | All |
| **Status** | All, active only, or inactive only | All |
| **Media type** | All, images only, or videos only | All |
| **Languages** | Filter by language (en, es, fr, etc.) | All |
| **Started after** | Only ads started on or after this date (YYYY-MM-DD) | — |
| **Started before** | Only ads started on or before this date (YYYY-MM-DD) | — |
| **Max results per query** | How many ads to collect per query | 100 |
| **Proxy** | Residential proxy for large runs | Off |

\* Provide at least one search query or advertiser page ID.

#### Input example

```json
{
  "queries": ["nike", "adidas"],
  "country": "US",
  "activeStatus": "active",
  "maxAdsPerQuery": 200,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": ["RESIDENTIAL"]
  }
}
````

### Output

Each ad is stored as a JSON object with the following fields:

```json
{
  "ad_id": "1368903715293808",
  "ad_archive_id": "1368903715293808",
  "ad_url": "https://www.facebook.com/ads/library/?id=1368903715293808",
  "advertiser": {
    "page_id": "972343405957883",
    "page_name": "National Carry Association",
    "page_url": "https://www.facebook.com/972343405957883/",
    "page_profile_picture_url": "https://scontent...",
    "page_categories": ["Business"],
    "page_like_count": 904
  },
  "ad_text": "Check your eligibility under the new 2026 law...",
  "ad_title": "2026 Carry Changes",
  "ad_creative_urls": {
    "images": ["https://scontent..."],
    "videos": ["https://video..."]
  },
  "creative_cards": null,
  "cta": { "text": "Learn more", "type": "LEARN_MORE" },
  "link_url": "http://rushedpermit.com/...",
  "caption": "rushedpermit.com",
  "byline": "4936 Ventures LLC",
  "link_description": "Claim Your Certificate Online in Minutes",
  "display_format": "VIDEO",
  "start_date": "2026-05-20T07:00:00.000Z",
  "end_date": "2026-06-12T07:00:00.000Z",
  "is_active": true,
  "platforms": ["facebook", "instagram"],
  "currency": "USD",
  "spend_range": "$90K-$100K",
  "impressions_range": ">1M",
  "reach_range": ">1M",
  "categories": ["POLITICAL"],
  "fev_info": {
    "authorized_entity": "This information was provided to Meta.",
    "phone": "+16193500902",
    "email": "hello@4936ventures.com",
    "website": "https://4936ventures.com/",
    "address": "Dover, Delaware"
  },
  "source_query": "biden",
  "scrapedAt": "2026-06-13T05:17:43.000Z"
}
```

Results can be exported to JSON, CSV, Excel, or accessed via the Apify dataset API.

### Tips for best results

- **Use proxy for large runs.** Without proxy, Facebook may rate-limit after 100-200 ads. Residential proxy eliminates this.
- **Page IDs are faster than keywords.** If you know the advertiser's Facebook page ID, use `advertiserPageIds` — it's more reliable and skips the search step.
- **Political ads have richer data.** Spend ranges, impressions, reach estimates, and advertiser contact info are only available on political/issue ads.
- **Set a reasonable max.** Start with 100-200 ads per query to verify results, then scale up.

### How it works

The scraper accesses Facebook's public Ad Library the same way a browser does — no API key or login needed:

1. Visits the Ad Library search page with your query
2. Extracts initial results from the server-rendered HTML
3. Paginates using Facebook's internal GraphQL API
4. Normalizes each ad into a clean, consistent schema

The scraper automatically discovers Facebook's internal API identifiers from the page's JavaScript bundles, so it stays working even when Facebook rotates them.

# Actor input Schema

## `queries` (type: `array`):

Keywords to search for in the Facebook Ad Library (e.g. "nike", "insurance", "shopify"). Each query runs independently.

## `advertiserPageIds` (type: `array`):

Facebook page IDs to scrape all ads from directly (e.g. "15087023444" for Nike). Faster than keyword search when you know the advertiser.

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

Filter ads by the country they target.

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

Filter by regulated ad category. Political ads include spend, impressions, and advertiser contact info.

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

Filter by whether the ad is currently running.

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

Filter by creative format — images only or videos only.

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

Only return ads in these languages. Two-letter codes (en, es, fr, de, pt, ar). Leave empty for all.

## `startDateMin` (type: `string`):

Only ads that started on or after this date (YYYY-MM-DD).

## `startDateMax` (type: `string`):

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

## `maxAdsPerQuery` (type: `integer`):

How many ads to collect per search query or page ID.

## Actor input object example

```json
{
  "queries": [
    "nike"
  ],
  "country": "US",
  "adType": "all",
  "activeStatus": "all",
  "mediaType": "all",
  "maxAdsPerQuery": 100
}
```

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

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

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

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

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

```

## CLI example

```bash
echo '{
  "queries": [
    "nike"
  ]
}' |
apify call scrapesmith/facebook-ad-library-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=scrapesmith/facebook-ad-library-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Facebook Ad Library Scraper",
        "description": "Scrape the Facebook Ad Library at scale. Extract ad text, images, videos, landing pages, spend ranges, impressions, advertiser info and more. Filter by keyword, advertiser, country, date range, media type. No login or Facebook account needed. Export to JSON, CSV, Excel.",
        "version": "0.0",
        "x-build-id": "TfLwowXHYapbfIPU4"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/scrapesmith~facebook-ad-library-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-scrapesmith-facebook-ad-library-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/scrapesmith~facebook-ad-library-scraper/runs": {
            "post": {
                "operationId": "runs-sync-scrapesmith-facebook-ad-library-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/scrapesmith~facebook-ad-library-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-scrapesmith-facebook-ad-library-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "queries": {
                        "title": "Search queries",
                        "type": "array",
                        "description": "Keywords to search for in the Facebook Ad Library (e.g. \"nike\", \"insurance\", \"shopify\"). Each query runs independently.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "advertiserPageIds": {
                        "title": "Advertiser page IDs",
                        "type": "array",
                        "description": "Facebook page IDs to scrape all ads from directly (e.g. \"15087023444\" for Nike). Faster than keyword search when you know the advertiser.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "country": {
                        "title": "Country",
                        "enum": [
                            "ALL",
                            "AR",
                            "AU",
                            "AT",
                            "BD",
                            "BE",
                            "BR",
                            "CA",
                            "CL",
                            "CO",
                            "CZ",
                            "DK",
                            "EG",
                            "FI",
                            "FR",
                            "DE",
                            "GH",
                            "GR",
                            "HK",
                            "HU",
                            "IN",
                            "ID",
                            "IE",
                            "IL",
                            "IT",
                            "JP",
                            "KE",
                            "KR",
                            "MY",
                            "MX",
                            "MA",
                            "NL",
                            "NZ",
                            "NG",
                            "NO",
                            "PK",
                            "PH",
                            "PL",
                            "PT",
                            "RO",
                            "RU",
                            "SA",
                            "SG",
                            "ZA",
                            "ES",
                            "SE",
                            "CH",
                            "TW",
                            "TH",
                            "TR",
                            "AE",
                            "GB",
                            "US",
                            "UA",
                            "VN"
                        ],
                        "type": "string",
                        "description": "Filter ads by the country they target.",
                        "default": "US"
                    },
                    "adType": {
                        "title": "Ad category",
                        "enum": [
                            "all",
                            "political_and_issue_ads",
                            "housing_ads",
                            "employment_ads",
                            "credit_ads"
                        ],
                        "type": "string",
                        "description": "Filter by regulated ad category. Political ads include spend, impressions, and advertiser contact info.",
                        "default": "all"
                    },
                    "activeStatus": {
                        "title": "Status",
                        "enum": [
                            "all",
                            "active",
                            "inactive"
                        ],
                        "type": "string",
                        "description": "Filter by whether the ad is currently running.",
                        "default": "all"
                    },
                    "mediaType": {
                        "title": "Media type",
                        "enum": [
                            "all",
                            "image_and_meme",
                            "video"
                        ],
                        "type": "string",
                        "description": "Filter by creative format — images only or videos only.",
                        "default": "all"
                    },
                    "contentLanguages": {
                        "title": "Languages",
                        "type": "array",
                        "description": "Only return ads in these languages. Two-letter codes (en, es, fr, de, pt, ar). Leave empty for all.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "startDateMin": {
                        "title": "Started after",
                        "type": "string",
                        "description": "Only ads that started on or after this date (YYYY-MM-DD)."
                    },
                    "startDateMax": {
                        "title": "Started before",
                        "type": "string",
                        "description": "Only ads that started on or before this date (YYYY-MM-DD)."
                    },
                    "maxAdsPerQuery": {
                        "title": "Max results per query",
                        "minimum": 1,
                        "maximum": 10000,
                        "type": "integer",
                        "description": "How many ads to collect per search query or page ID.",
                        "default": 100
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
