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

Extract ads from Facebook Ad Library instantly. Get complete ad details, images, videos, page info, impressions, and targeting data. Just paste the Ad Library URL and run. Fast, reliable extraction for competitor research and market analysis.

- **URL**: https://apify.com/agenscrape/facebook-ad-library-scraper.md
- **Developed by:** [Agenscrape](https://apify.com/agenscrape) (community)
- **Categories:** Automation, Developer tools, Agents
- **Features:** Limited permissions
- **Stats:** 310 total users, 9 monthly users, 100.0% runs succeeded, 10 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.50 / 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

## Facebook Ad Library Scraper - Extract Meta Ads Data

Extract valuable advertising intelligence from Facebook Ad Library instantly. Get complete ad details, creative assets, targeting data, and performance metrics with a single URL.

### Why Use This Scraper?

- ⚡ **Lightning Fast** - Get results in seconds
- 🎯 **Complete Data** - Extract all ad details, images, videos, and metrics
- 🚀 **Zero Setup** - Just paste the URL and run
- 📊 **Structured Data** - Export-ready JSON format
- 🔄 **Unlimited Scaling** - Extract as many ads as you need
- 💰 **Cost Effective** - Pay only for what you use

### Perfect For

- **Marketing Agencies** - Research client competitors and industry trends
- **Brand Managers** - Monitor competitor campaigns and strategies
- **Growth Marketers** - Find winning ad creatives and copy
- **Market Researchers** - Analyze advertising trends and patterns
- **E-commerce Stores** - Discover what's working in your niche

### Complete Data Extraction

#### Ad Content

- Title, body text, and captions
- All images with original and resized URLs
- Videos with HD/SD URLs and preview images
- Call-to-action buttons and types
- Destination URLs and descriptions

#### Page Information

- Page name and profile URL
- Profile pictures
- Page like count and categories
- Advertiser details

#### Performance Metrics

- Impression ranges
- Spend estimates
- Currency information
- Total active time

#### Campaign Details

- Start and end dates
- Active status
- Publisher platforms (Facebook, Instagram, etc.)
- Display format
- Geographic targeting

### How to Use

#### Step 1: Find Ads

Visit [Facebook Ad Library](https://www.facebook.com/ads/library/) and search using:

- Keywords (e.g., "fitness", "shoes", "software")
- Country targeting
- Ad status (active/inactive)
- Media type (video/image)

#### Step 2: Copy URL

Copy the full URL from your browser address bar

#### Step 3: Configure Input

```json
{
  "adLibraryUrl": "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=US&q=fitness&search_type=keyword_exact_phrase",
  "maxResults": 100
}
```

#### Step 4: Run & Export

Click run and download results in JSON or CSV format

### Input Parameters

| Parameter | Type | Description | Required |
|-----------|------|-------------|----------|
| **Ad Library URL** | String | Complete URL from Facebook Ad Library | ✅ Yes |
| **Maximum Results** | Integer | Limit results (0 or empty = unlimited) | ❌ No |

### Example Output

```json
{
  "ad_archive_id": "987654321",
  "page_name": "Nike",
  "page_id": "123456789",
  "page_like_count": 35000000,
  "ad_title": "Just Do It - New Collection",
  "ad_body": "Discover the latest athletic wear designed for champions. Free shipping on orders over $50.",
  "cta_text": "Shop Now",
  "cta_type": "SHOP_NOW",
  "link_url": "https://nike.com/new-collection",
  "images": [
    {
      "original_url": "https://scontent.xx.fbcdn.net/...",
      "resized_url": "https://scontent.xx.fbcdn.net/..."
    }
  ],
  "videos": [],
  "impressions": "100K-500K",
  "start_date": "2024-11-15",
  "end_date": null,
  "is_active": true,
  "currency": "USD",
  "publisher_platform": ["facebook", "instagram"],
  "display_format": "single_image"
}
```

### Real-World Use Cases

#### Competitive Intelligence

Track what your competitors are advertising, when they run campaigns, and what messaging they use.

#### Creative Research

Build a swipe file of high-performing ad creatives in your industry for inspiration.

#### Market Analysis

Identify trends, seasonal patterns, and emerging opportunities in your market.

#### Ad Spend Tracking

Monitor competitor spending patterns and campaign intensity.

#### Audience Insights

Understand which demographics and regions competitors target.

### Pro Tips

✅ **Narrow Your Search** - Use specific keywords for more relevant results
✅ **Track Regularly** - Run weekly to spot new campaigns early
✅ **Export & Analyze** - Use spreadsheet tools for deeper insights
✅ **Compare Markets** - Search different countries to find opportunities
✅ **Save Templates** - Create saved searches for recurring analysis

### Output Formats

- **JSON** - Full structured data with all fields
- **CSV** - Spreadsheet-friendly format for Excel/Google Sheets
- **Direct API** - Integrate with your tools via Apify API

### Frequently Asked Questions

**Q: How many ads can I extract?**
A: Unlimited! Set maxResults to 0 or leave it empty for no limit.

**Q: Does this include inactive ads?**
A: Yes, just include them in your search URL filters.

**Q: Can I get ads from specific pages?**
A: Yes, search by page name or use page filters in Ad Library.

**Q: How fresh is the data?**
A: Real-time! Data comes directly from Facebook Ad Library.

**Q: Can I automate this?**
A: Absolutely! Use Apify's scheduling or API for automation.

### Get Started Now

1. Click "Try for free" above
2. Paste your Facebook Ad Library URL
3. Get results in seconds

Transform your advertising strategy with real competitive intelligence!

# Actor input Schema

## `adLibraryUrl` (type: `string`):

Enter a Facebook Ad Library search URL to scrape multiple ads, or an ad_archive_id to fetch a specific ad's extended details.

Examples:

- Search URL: https://www.facebook.com/ads/library/?active_status=active\&ad_type=all\&country=US\&q=gym\&search_type=keyword_exact_phrase
- Ad ID: 1387126002807559

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

Maximum number of ads to scrape. Only applies to search URLs. Leave empty or set to 0 for unlimited results.

## Actor input object example

```json
{
  "adLibraryUrl": "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=US&q=delivery&search_type=keyword_exact_phrase",
  "maxResults": 50
}
```

# Actor output Schema

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

Quick view of scraped ads with key information

## `detailed` (type: `string`):

Complete ad data with all available fields

## `dataset` (type: `string`):

All scraped ads in JSON format

# 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 = {
    "adLibraryUrl": "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=US&q=delivery&search_type=keyword_exact_phrase",
    "maxResults": 50
};

// Run the Actor and wait for it to finish
const run = await client.actor("agenscrape/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 = {
    "adLibraryUrl": "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=US&q=delivery&search_type=keyword_exact_phrase",
    "maxResults": 50,
}

# Run the Actor and wait for it to finish
run = client.actor("agenscrape/facebook-ad-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 '{
  "adLibraryUrl": "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=US&q=delivery&search_type=keyword_exact_phrase",
  "maxResults": 50
}' |
apify call agenscrape/facebook-ad-library-scraper --silent --output-dataset

```

## MCP server setup

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