# Meta (Facebook) Ad Library Scraper - Fast & Reliable (`whoareyouanas/meta-ad-scraper`) Actor

Scrape Meta ads in seconds - no fluff, just instant access to the ad data and insights you need.

Get detailed ad information including title, description, images, videos, CTA, Social platform and metadata

- **URL**: https://apify.com/whoareyouanas/meta-ad-scraper.md
- **Developed by:** [Anas Nadeem](https://apify.com/whoareyouanas) (community)
- **Categories:** Agents, Social media, Lead generation
- **Features:** Limited permissions
- **Stats:** 3,801 total users, 155 monthly users, 95.0% runs succeeded, 77 bookmarks
- **User rating**: 4.97 out of 5 stars

## Pricing

$10.00 / 1,000 ads

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 Ads Scraper — The Most Powerful Facebook Ad Library Scraper

**Trusted by 500+ marketers, agencies, and brands** — with over **1,000,000+ ad records** scraped and counting. Get complete, structured ad intelligence from the Meta Ad Library in minutes, not hours.

Whether you're tracking competitors, building creative swipe files, or powering an ad intelligence pipeline — this scraper delivers **99% data accuracy** with proxy support.

### Turn competitor ads into your next creative test with Seercraft

Turn your competitor ad research into ideas for your next campaign. We also build **[Seercraft](https://www.seercraft.io/)** for ongoing Meta ad research.

Track competitors daily, save Facebook and Instagram ads to boards, ask Seer questions with links to source ads, and turn your findings into creative briefs.

[Explore Seercraft](https://www.seercraft.io/).

***

### ⚡ Why This Scraper?

| Feature | Details |
|---|---|
| 🎯 **Complete Ad Data** | Brand, body copy, CTA, links, images, videos, carousel assets, platform breakdown |
| 📊 **1M+ Records Delivered** | Battle-tested across thousands of runs for brands worldwide |
| 🔄 **Two Input Modes** | Paste a URL directly **or** build your search with simple parameters |
| 🌍 **Any Country, Any Brand** | Supports all 200+ countries in the Meta Ad Library |
| 🛡️ **Anti-Detection Built-In** | Stealth mode, session rotation, human-like scrolling |
| 🖼️ **All Media Formats** | Images, videos (with duration), carousels — all captured |
| ⚙️ **Proxy Ready** | Plug in your Apify Residential proxy for 99% coverage |

***

### 🚀 Quick Start

You have **two ways** to tell the scraper what to fetch:

#### Option A: Paste a Direct URL

Already have a Facebook Ad Library URL? Just paste it:

```json
{
  "targetUrl": "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=US&view_all_page_id=108047081396228"
}
```

#### Option B: Build from Parameters (New! ✨)

Don't want to craft URLs manually? Just fill in the fields:

```json
{
  "country": "US",
  "searchQuery": "nike",
  "activeStatus": "active",
  "mediaType": "video",
  "sortMode": "total_impressions"
}
```

Or search by **Page ID**:

```json
{
  "country": "IN",
  "pageId": "786827864757998",
  "activeStatus": "active"
}
```

The scraper builds the correct URL automatically — no guesswork needed.

***

### 📋 Input Parameters

#### Search Identifiers (at least one required when using parameters)

| Parameter | Type | Description | Example |
|---|---|---|---|
| `targetUrl` | string | Full Facebook Ad Library URL (Option A) | `https://www.facebook.com/ads/library/...` |
| `country` | string | ISO 3166-1 alpha-2 country code | `US`, `IN`, `IT`, `GB` |
| `searchQuery` | string | Keyword search across all ads | `nike`, `adidas shoes` |
| `pageId` | string | Facebook Page ID to view all ads | `108047081396228` |
| `adId` | string | Look up a specific ad by ID | `1191898553123641` |

#### Filtering Options

| Parameter | Type | Values | Default |
|---|---|---|---|
| `activeStatus` | enum | `active`, `inactive`, `all` | `all` |
| `adType` | enum | `all`, `political_and_issue_ads`, `housing`, `employment`, `credit` | `all` |
| `mediaType` | enum | `all`, `image`, `video`, `meme` | `all` |
| `isTargetedCountry` | boolean | `true`, `false` | `false` |
| `contentLanguages` | array | ISO 639-1 codes (e.g. `["en", "it"]`) | all languages |

#### Sorting

| Parameter | Type | Values | Default |
|---|---|---|---|
| `sortMode` | enum | `total_impressions`, `relevance`, `start_date` | `total_impressions` |
| `sortDirection` | enum | `desc`, `asc` | `desc` |

#### Performance Settings

| Parameter | Type | Default | Description |
|---|---|---|---|
| `maxConcurrency` | integer | `1` | Browser tabs in parallel (1–10) |
| `requestHandlerTimeoutSecs` | integer | `900` | Max time per page (60–1200s) |
| `proxyUrl` | string | — | Your Apify Residential proxy URL |

***

### 📦 Output Format

Each run outputs a clean JSON array of ad objects:

```json
[
  {
    "libraryID": "1234567890",
    "brand": "Nike",
    "brandLogo": "https://scontent...",
    "active": true,
    "platforms": ["Facebook", "Instagram"],
    "totalPlatforms": 2,
    "similarAdCount": 5,
    "multipleVersions": true,
    "body": "Just Do It. Shop the latest collection...",
    "linkTitle": "Nike.com",
    "linkUrl": "https://nike.com/shop",
    "linkDescription": "Free shipping on orders over $50",
    "ctaText": "Shop Now",
    "ctaUrl": "https://nike.com/shop",
    "images": [{ "url": "https://..." }],
    "videos": [{ "url": "https://...", "duration": 30 }],
    "startDate": "1/15/2025",
    "format": "video"
  }
]
```

**Every field you need** — brand identity, creative assets, copy, CTA, platform breakdown, dates, and format detection (image / video / carousel).

***

### 🛡️ Proxy Setup (Recommended)

Without a proxy, Facebook limits results heavily. With an **Apify Residential proxy**, you get **99% of all ads**.

**How to set up:**

1. Go to **Apify Console → Proxy → Groups tab**
2. Click **RESIDENTIAL** → Copy the proxy URL
3. Paste it into the `proxyUrl` field

Format: `http://groups-RESIDENTIAL:YOUR_TOKEN@proxy.apify.com:8000`

External proxies (BrightData, Oxylabs, etc.) also work — just paste the URL.

***

### 🏗️ Built With

- **Apify SDK** + **Crawlee** for orchestration
- **Puppeteer** with stealth plugin for undetectable scraping
- Scroll-based pagination with intelligent stall detection
- Duplicate detection and memory-efficient DOM cleanup for large datasets (500+ ads)

***

### 💡 Pro Tips

1. **Start with `maxConcurrency: 1`** — increase only if you have enough memory
2. **Pages with 200+ ads** need at least 600s timeout
3. **Use `activeStatus: "active"`** to get only currently running ads
4. **Sort by `start_date`** to catch the freshest creatives first
5. **Combine `mediaType: "video"` + keyword search** to find video ads for specific niches

***

### 🤝 Enterprise & Custom Solutions

Building an ad intelligence platform? Need a full creative pipeline — from scraping to analysis to insights?

**Let's talk.** We've helped brands and agencies build end-to-end creative intelligence workflows.

🌐 **Website:** [whoareyouanas.com](https://whoareyouanas.com)\
📧 **Email:** <anas5678go@gmail.com>\
🐦 **Twitter/X:** [@whoareyouanas](https://twitter.com/whoareyouanas)

Whether you need custom scraping pipelines, bulk data delivery, or API integrations — reach out and let's build something great together.

# Actor input Schema

## `targetUrl` (type: `string`):

Paste the full Facebook Ad Library URL directly. If provided, all parameter fields below are ignored. Leave empty to build the URL from parameters instead.

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

ISO 3166-1 alpha-2 country code for ad targeting (e.g. US, IN, IT, GB). Required when not using a direct URL.

## `searchQuery` (type: `string`):

Keyword search query (e.g. 'nike', 'adidas shoes'). This searches across all ads by keyword.

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

Numeric Facebook Page ID to view all ads from a specific page (e.g. 108047081396228). You can find this in the URL when viewing a page's ads.

## `adId` (type: `string`):

Numeric ID of a specific ad to look up (e.g. 1191898553123641).

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

Filter by ad campaign status.

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

Filter by type of ads.

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

Filter by media format.

## `isTargetedCountry` (type: `boolean`):

If true, only show ads specifically targeting the selected country.

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

Filter by content language codes (ISO 639-1, e.g. 'en', 'it', 'hi'). Leave empty for all languages.

## `sortMode` (type: `string`):

Sort metric for results.

## `sortDirection` (type: `string`):

Sort order for results.

## `maxConcurrency` (type: `integer`):

Number of browser tabs to run in parallel. Keep at 1 for stability. Increase to 2-3 only if you need faster scraping and have sufficient memory. Higher values increase memory usage.

## `requestHandlerTimeoutSecs` (type: `integer`):

Maximum time to wait for a page to load and scrape all ads. Pages with 200+ ads need 600-900 seconds. Default of 900 seconds (15 minutes) handles large datasets.

## `proxyUrl` (type: `string`):

Add your Apify Proxy URL to get 99% of all ads! Format: http://groups-RESIDENTIAL:YOUR_APIFY_TOKEN@proxy.apify.com:8000. Get your token from Apify Console → Proxy → Groups tab → RESIDENTIAL link  → Copy link. External proxies (BrightData, Oxylabs) also work. Or connect with us directly if you don't want to use Proxy but want 99% of all ads.

## Actor input object example

```json
{
  "country": "US",
  "searchQuery": "nike",
  "pageId": "",
  "activeStatus": "active",
  "adType": "all",
  "mediaType": "all",
  "isTargetedCountry": false,
  "sortMode": "total_impressions",
  "sortDirection": "desc",
  "maxConcurrency": 1,
  "requestHandlerTimeoutSecs": 900
}
```

# Actor output Schema

## `overview` (type: `string`):

Overview of all scraped ads with key metrics and details

## `allAds` (type: `string`):

Complete dataset with all fields including metadata, images, and videos

# 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 = {
    "country": "US",
    "searchQuery": "nike",
    "pageId": "",
    "maxConcurrency": 1,
    "requestHandlerTimeoutSecs": 900
};

// Run the Actor and wait for it to finish
const run = await client.actor("whoareyouanas/meta-ad-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 = {
    "country": "US",
    "searchQuery": "nike",
    "pageId": "",
    "maxConcurrency": 1,
    "requestHandlerTimeoutSecs": 900,
}

# Run the Actor and wait for it to finish
run = client.actor("whoareyouanas/meta-ad-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 '{
  "country": "US",
  "searchQuery": "nike",
  "pageId": "",
  "maxConcurrency": 1,
  "requestHandlerTimeoutSecs": 900
}' |
apify call whoareyouanas/meta-ad-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,whoareyouanas/meta-ad-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/JHGi3kAzHO1t3Fxrb/builds/V6jsm80zhDueAhPkl/openapi.json
