# Meta Ad Library Scraper for Facebook & Instagram (`fetchcraftlabs/facebook-ads-library-scraper`) Actor

Search public Facebook and Instagram ads by keyword or advertiser in the Meta Ad Library. Filter by country, ad status, or format, then export ad copy, creative URLs, calls to action, landing pages, and run dates.

- **URL**: https://apify.com/fetchcraftlabs/facebook-ads-library-scraper.md
- **Developed by:** [FetchCraft Labs](https://apify.com/fetchcraftlabs) (community)
- **Categories:** Social media, E-commerce
- **Features:** Limited permissions
- **Stats:** 3 total users, 2 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.20 / 1,000 ad returneds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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 Ad Library Scraper for Facebook & Instagram

Search public Facebook and Instagram ads in the Meta Ad Library by keyword or advertiser page. Export ad copy, image and video URLs, calls to action, landing pages, and run dates to an Apify dataset for competitor research or creative analysis.

### Quick start

1. Enter one or more terms in **Keyword searches**, or add a numeric Facebook Page ID or a Meta Ad Library page URL under **Advertiser page IDs**. For advertiser-only research, clear any prefilled keyword.
2. Select a country and ad status. Start with a single search and set **Max ads per search** to 20.
3. Run the Actor and open **Ads** in the run output. Use **Creative and delivery** for creative and delivery fields, or export the dataset as CSV, Excel, or JSON.

The example below searches for up to 20 active ads matching “running shoes” in the United States. Paste it into the **JSON** tab of the Actor input.

```json
{
  "queries": ["running shoes"],
  "country": "US",
  "activeStatus": "active",
  "mediaType": "all",
  "maxAdsPerQuery": 20
}
```

### What you can research

- **Competitor campaigns**. Search by advertiser page to compare a brand's current ad copy, offers, calls to action, and landing pages.
- **Creative formats**. Search a product category, filter by image or video, and compare the creatives you find.
- **Market comparisons**. Run the same search for two countries and compare the ads Meta returns for each.
- **Campaign monitoring**. Save the Actor input as an Apify task and schedule repeat runs. Compare the `ad_archive_id` values in each export to identify newly observed ads.

### Search options

| Input | How to use it |
| --- | --- |
| Keyword searches (`queries`) | Add search terms such as `running shoes` or `meal delivery`. Each term runs as its own search. |
| Advertiser page IDs (`advertiserPageIds`) | Enter a numeric Facebook Page ID or a Meta Ad Library URL with a `view_all_page_id` parameter. |
| Country (`country`) | Use a two-letter code such as `US`, `GB`, or `DE`, or enter `ALL` for a worldwide search. The default is `US`. |
| Ad status (`activeStatus`) | Choose `active`, `inactive`, or `all`. The default is `active`. |
| Ad type and creative type | Search across ad types or select political and issue ads. Filter creatives by image, video, or meme. |
| Started after (`startDate`) | Limit results by the ad start date. |
| Sort order (`sortMode`) | Choose total impressions, time active, or relevancy. |
| Max ads per search (`maxAdsPerQuery`) | Set the upper limit separately for each keyword or advertiser. The default is 100. |

### What the output includes

| Data | Example fields |
| --- | --- |
| Ad and advertiser | `ad_archive_id`, `ad_snapshot_url`, `page_id`, `page_name` |
| Copy and calls to action | `title`, `body`, `cta_text`, `link_url` |
| Creative and placement | `display_format`, `images`, `videos`, `video_thumbnails`, `publisher_platforms` |
| Status and dates | `is_active`, `start_date`, `end_date` |
| Search context | `search_mode`, `search_query`, `search_page_id`, `search_country`, `scraped_at` |

Each dataset row represents an ad returned by one search. **Search summary** shows how many rows each search produced. This abbreviated example uses illustrative data.

```json
{
  "ad_archive_id": "123456789012345",
  "page_name": "Example Running Co.",
  "body": "Find your next pair of running shoes.",
  "cta_text": "Shop now",
  "link_url": "https://example.com/running-shoes",
  "is_active": true,
  "publisher_platforms": ["FACEBOOK", "INSTAGRAM"],
  "search_query": "running shoes",
  "search_country": "US"
}
```

### FAQ

#### Can I search for ads from a specific brand?

Yes. Use the brand's numeric Facebook Page ID or its advertiser page URL from the Meta Ad Library. A keyword search can return ads from multiple advertisers.

#### Why did I get fewer ads than my limit?

The limit is a maximum per search. Availability depends on the country, filters, and ads Meta makes available. Check **Search summary** for each search, and broaden the filters if you need more matches.

#### Can I see inactive ads or delivery metrics?

Choose **Inactive** or **All** to include inactive ads where Meta makes them available. Fields such as end date, impressions, and reach may be empty when Meta does not publish them for a particular ad.

#### Can the same ad appear more than once?

The Actor deduplicates results within each search. An ad that matches two searches can appear in both. Use `ad_archive_id` to deduplicate an export across searches.

#### Do I get image and video files?

The dataset provides image, video, and thumbnail URLs when Meta supplies them. Media URLs can change over time.

#### Can I use the results in my own workflow?

Yes. Export from the dataset or retrieve the results programmatically. The Actor's **API** tab shows how to start a run and read its dataset.

# Actor input Schema

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

One or more keywords, brand names or product terms. Each entry is a separate search and adds a search_query field to its ads.

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

Numeric Facebook page IDs, or Ad Library URLs that contain view_all_page_id (for example https://www.facebook.com/ads/library/?view_all_page_id=15087023444). Every ID is scraped as its own search.

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

Two-letter country code for the ad search and proxy location (for example US, GB, DE). Use ALL to search worldwide.

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

Only active ads (default), only inactive ads, or both.

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

All ads, or only political and issue ads.

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

Filter by the ad's creative format.

## `startDate` (type: `string`):

Only return ads that started after this date (YYYY-MM-DD). Leave empty for no date filter.

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

Order in which Meta returns matching ads.

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

Descending returns the biggest or longest-running ads first.

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

Stop a search after this many ads. Each ad is a billable result, so start with 20-50 while testing.

## `requestDelay` (type: `number`):

Pause between result pages. 1-2 seconds is a good default for large searches.

## `maxRetries` (type: `integer`):

How many times to retry a search with a fresh proxy session if it cannot complete.

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

Apify residential proxies are recommended for reliable, country-accurate results. Their traffic is billed to your Apify account. Disable the proxy only for a quick local test.

## Actor input object example

```json
{
  "queries": [
    "nike",
    "running shoes"
  ],
  "advertiserPageIds": [
    "15087023444"
  ],
  "country": "US",
  "activeStatus": "active",
  "adType": "all",
  "mediaType": "all",
  "sortMode": "total_impressions",
  "sortDirection": "desc",
  "maxAdsPerQuery": 100,
  "requestDelay": 1,
  "maxRetries": 3,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# Actor output Schema

## `ads` (type: `string`):

No description

## `creative` (type: `string`):

No description

## `summary` (type: `string`):

No description

# 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"
    ],
    "country": "US",
    "maxAdsPerQuery": 100,
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ]
    }
};

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

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

```

## MCP server setup

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