# Facebook Ads Library Scraper (`scrapewonder/facebook-ads-library-scraper`) Actor

Scrape ads from the Meta (Facebook & Instagram) Ad Library by keyword or Ad Library URL. Ad copy, images, videos, landing pages, run dates and advertiser data. No login needed.

- **URL**: https://apify.com/scrapewonder/facebook-ads-library-scraper.md
- **Developed by:** [Wonderland Data](https://apify.com/scrapewonder) (community)
- **Categories:** Social media, Marketing, Lead generation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$1.00 / 1,000 ad scrapeds

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

## Facebook Ads Library Scraper

Scrape ads from the **Meta Ad Library** (Facebook, Instagram, Messenger, Audience Network, Threads) by keyword, brand or advertiser page. No Facebook account, no login, no cookies.

Use it for **competitor ad research**, creative inspiration, monitoring a brand's campaigns, or building swipe files of winning ads, in any country.

### What you get for each ad

| Field | Example |
|---|---|
| `adLibraryUrl` | Direct link to the ad in the Ad Library |
| `pageName`, `pageUrl`, `pageLikeCount`, `pageCategories` | Advertiser details |
| `isActive`, `startDate`, `endDate`, `daysRunning` | How long the ad has been running. Long-running ads are usually the profitable ones |
| `bodyText`, `title`, `linkDescription`, `ctaText` | Full ad copy and call to action |
| `linkUrl`, `linkDomain` | Real landing page (Facebook redirect removed) |
| `imageUrls`, `videoUrls`, `videoPreviewUrls` | Full-resolution creatives |
| `cards` | Every card of carousel and catalog (DPA) ads |
| `displayFormat` | IMAGE, VIDEO, CAROUSEL, DPA, DCO… |
| `platforms` | Where the ad is shown |
| `spend`, `impressions`, `disclaimer` | For political and issue ads |

### How to use

1. Enter **search terms** (e.g. `nike`, `meal prep`) and pick a **country**, or
2. Paste any **Ad Library URL**, including a page's "See all ads" link, and all its filters are kept.
3. Set **Max ads per search** and run.

Export to JSON, CSV, Excel, or connect via API, Make, Zapier or n8n.

#### Example input

```json
{
  "searchTerms": ["nike", "adidas"],
  "country": "US",
  "activeStatus": "active",
  "mediaType": "video",
  "maxAdsPerQuery": 200
}
```

### Pricing

You pay only for ads you receive. No monthly rental fee.

### Tips

- **Find winners:** sort by `daysRunning`. Ads running 30+ days are almost always profitable for the advertiser.
- **Track a competitor:** open their page in the Ad Library, click "See all ads", and paste that URL.
- **Find landing pages:** group by `linkDomain` to see where a niche sends its traffic.

### FAQ

**Do I need a Facebook account?** No.

**Is it legal?** The Ad Library is public data published by Meta for transparency. Make sure your use complies with the laws that apply to you.

**Something broke?** Open an issue on the Issues tab. Fixes ship within 48 hours.

# Actor input Schema

## `searchTerms` (type: `array`):

Keywords or brand names to search in the Ad Library.

## `startUrls` (type: `array`):

Paste any Ad Library URL (with your filters or a page's 'view all' link). Filters below are ignored for these URLs.

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

Two-letter country code (e.g. US, PL, DE) or ALL.

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

Only currently running ads, only stopped ads, or both.

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

Ad Library category. Political/issue ads include spend and impressions.

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

Return only ads with images, videos, memes or no media.

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

Match any of the words, or the exact phrase.

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

Stop after this many ads for each search term or URL.

## `proxyConfiguration` (type: `object`):

Residential proxy is required: Facebook rate-limits datacenter IPs after the first ~30 ads.

## Actor input object example

```json
{
  "searchTerms": [
    "nike"
  ],
  "country": "ALL",
  "activeStatus": "active",
  "adType": "all",
  "mediaType": "all",
  "searchType": "keyword_unordered",
  "maxAdsPerQuery": 20,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# Actor output Schema

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

All scraped items in the default dataset.

# 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 = {
    "searchTerms": [
        "nike"
    ],
    "maxAdsPerQuery": 20,
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ]
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("scrapewonder/facebook-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 = {
    "searchTerms": ["nike"],
    "maxAdsPerQuery": 20,
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
    },
}

# Run the Actor and wait for it to finish
run = client.actor("scrapewonder/facebook-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 '{
  "searchTerms": [
    "nike"
  ],
  "maxAdsPerQuery": 20,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}' |
apify call scrapewonder/facebook-ads-library-scraper --silent --output-dataset

```

## MCP server setup

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