# Facebook Ads Scraper (`alizarin_refrigerator-owner/facebook-ads-scraper`) Actor

Scrape the public Facebook Ad Library to find competitor ads by page ID or search term.

Features:
-Scrape ads by Facebook Page ID
-Search ads by keyword
-Filter by country and status
-Extract ad creatives, text, and targeting info

- **URL**: https://apify.com/alizarin\_refrigerator-owner/facebook-ads-scraper.md
- **Developed by:** [The Howlers](https://apify.com/alizarin_refrigerator-owner) (community)
- **Categories:** Social media, Lead generation, Developer tools
- **Stats:** 16 total users, 1 monthly users, 90.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.01 / 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?

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

## Facebook Ad Library Scraper - Competitor Ad Intelligence

Discover competitor Facebook ads by scraping Meta's Ad Library. Find active and inactive ads, see creatives, and analyze messaging. No per-campaign fees.

***

### Quick Start

#### Run with real data

```json
{
  "countryCode": "US",
  "maxItems": 50,
  "adActiveStatus": "ALL",
  "webhookPlatform": "custom"
}
```

***

### Input Parameters

| Parameter | Type | Default | Required | Description |
|-----------|------|---------|----------|-------------|
| `pageIds` | array | - | No | List of Facebook Page IDs to scrape ads from |
| `searchTerm` | string | - | No | Search term to find ads (alternative to pageIds) |
| `countryCode` | string | `"US"` | No | Country to filter ads (ISO 2-letter code) |
| `maxItems` | integer | `50` | No | Maximum number of ads to scrape per page |
| `adActiveStatus` | string | `"ALL"` | No | Filter by ad status |
| `webhookUrl` | string | - | No | URL to POST results when scraping completes (Zapier, Make, n8n, custom endpoint) |
| `webhookPlatform` | string | `"custom"` | No | Platform type for webhook formatting |
| `webhookHeaders` | object | - | No | Custom HTTP headers to send with webhook (JSON object) |

***

### Pricing

This actor uses **pay-per-event** billing:

| Event | Description | Price |
|-------|-------------|-------|
| Ad Scraped | Each Facebook ad scraped from Ad Library | $0.04 |

***

### Troubleshooting

#### "API error 429" or "Rate limit"

Too many requests. Wait a minute and try again, or reduce the number of items per run.

#### No results or empty dataset

Check the run log for error messages. Common causes:

- Invalid input format (check the examples above)
- The target data doesn't exist or is too small to track

#### How do I test without an API key?

Run the actor with the default sample input, or set demoMode to true, and it returns labeled sample ad data showing the exact live output format. Every sample item carries demo: true and a \_notice field, and sample runs charge no task events. Provide page IDs or a search term to run a real scrape.

***

**Built by John Rippy | [Actor Arsenal](https://actorarsenal.com)**

# Actor input Schema

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

List of Facebook Page IDs to scrape ads from

## `searchTerm` (type: `string`):

Search term to find ads (alternative to pageIds)

## `countryCode` (type: `string`):

Country to filter ads (ISO 2-letter code)

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

Maximum number of ads to scrape per page

## `adActiveStatus` (type: `string`):

Filter by ad status

## `demoMode` (type: `boolean`):

Run with sample data to test without real scraping. Returns realistic sample output instantly. Set to false and provide pageIds or searchTerm for real scraping.

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

URL to POST results when scraping completes (Zapier, Make, n8n, custom endpoint)

## `webhookPlatform` (type: `string`):

Platform type for webhook formatting

## `webhookHeaders` (type: `object`):

Custom HTTP headers to send with webhook (JSON object)

## Actor input object example

```json
{
  "countryCode": "US",
  "maxItems": 50,
  "adActiveStatus": "ALL",
  "demoMode": true,
  "webhookPlatform": "custom"
}
```

# Actor output Schema

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

Structured data from Facebook Ad Library containing ad creative, targeting info, and delivery dates

# 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 = {
    "demoMode": true
};

// Run the Actor and wait for it to finish
const run = await client.actor("alizarin_refrigerator-owner/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 = { "demoMode": True }

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

```

## MCP server setup

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