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

Facebook Ads Library scraper for collecting public ads from search results and advertiser pages. Extract ad creatives, advertiser details, dates, platforms, and available metrics for ad research and monitoring.

- **URL**: https://apify.com/laisi/facebook-ads-library-scraper.md
- **Developed by:** [laisi](https://apify.com/laisi) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 2 monthly users, 100.0% runs succeeded, 1 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $0.45 / 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.
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

## Facebook Ads Library Scraper

Collect publicly available ads from Facebook Ad Library search results and advertiser pages. Add one or more Facebook URLs, choose your filters, and find the collected ad records in the run's default dataset.

### ✨ Features

- 🔎 Search URLs can target keywords or other Ad Library query criteria.
- 📄 Public Facebook page URLs can be used to find ads associated with a page.
- 🔗 Process multiple URLs in one run.
- 📊 Get ad identifiers, advertiser page information, creative data, and available delivery or impression information.
- 🧾 Collect additional advertiser and AAA-related information when available.
- 🛡️ Uses residential proxies by default; no proxy setup or separate proxy fee is required.

### 📊 Dataset results

Each dataset item represents an ad returned for an input URL. Depending on the ad and the data available from Facebook, a result can include the following fields:

| Field                            | Description                                                                             |
| -------------------------------- | --------------------------------------------------------------------------------------- |
| Ad Archive ID                    | Archive identifier for locating the ad entry in the Ad Library.                         |
| Archive Types                    | Archive classification values associated with the record.                               |
| Categories                       | Category labels attached to the ad or its advertiser.                                   |
| Contains Digitally Created Media | Indicator for whether the creative is identified as digitally created or altered.       |
| Collation Count                  | Number of ad variants represented in a grouped result.                                  |
| Collation ID                     | Identifier used to associate related ad variants.                                       |
| Currency                         | Currency code associated with reported financial values.                                |
| End Date                         | Reported end date for the ad's delivery.                                                |
| Entity Type                      | Type of advertiser or page entity.                                                      |
| Gated Type                       | Audience or content gating classification, when provided.                               |
| Has User Reported                | Indicator of whether the ad has a user report flag.                                     |
| Hidden Safety Data               | Safety-related data returned by the source.                                             |
| Hide Data Status                 | Status information for fields hidden or restricted by the source.                       |
| Impressions With Index           | Impression range or indexed impression value.                                           |
| Is AAA Eligible                  | Indicator for eligibility in the source's AAA-related reporting.                        |
| Is Active                        | Indicates whether the ad is currently active.                                           |
| Is Profile Page                  | Indicates whether the advertiser is represented as a profile page.                      |
| Page ID                          | Identifier of the advertiser's page.                                                    |
| Page Name                        | Display name of the advertiser's page.                                                  |
| Political Countries              | Countries associated with political or social-issue ad classification.                  |
| Reach Estimate                   | Estimated audience reach, when the source provides it.                                  |
| Report Count                     | Number of reports or report-related records available for the ad.                       |
| Snapshot of Ad Creatives         | Creative payload, which may contain text, images, videos, or other format details.      |
| Spend                            | Reported spending range or amount, when available.                                      |
| Start Date                       | Reported date when the ad began running.                                                |
| State Media Run Label            | Label indicating a state-affiliated media designation, when present.                    |
| Publisher Platform               | Platforms where the ad is shown, such as Facebook or Instagram.                         |
| Menu Items                       | Additional menu or action metadata associated with the ad record.                       |
| Advertiser                       | Advertiser details returned by the source;availability may depend on `scrapeAdDetails`. |
| Insights                         | Performance or delivery insights included in the response.                              |
| AAA Info                         | Additional AAA-related details; availability may depend on `scrapeAdDetails`.           |

### ⚙️ Actor input

#### `urls` (required)

Type: `array of strings`

Facebook page URLs or Facebook Ad Library search URLs. To create a search URL, open the Ad Library, set the desired query filters, and use the resulting URL.

Example:

```json
[
  "https://www.facebook.com/Meta",
  "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=US&media_type=all&q=coffee&search_type=keyword_unordered"
]
```

#### `scrapeAdDetails`

Type: `boolean`

When enabled, request additional ad detail data, including advertiser or AAA-related fields when the source makes them available. Defaults to `false`.

#### `limitPerSource`

Type: `integer`

Maximum number of ads to collect for each URL. Leave it unset or use `0` for no per-URL limit beyond what the source provides.

#### `count`

Type: `integer`

Maximum total number of ads to collect across all URLs. If unset or `0`, no run-wide count limit is applied.

#### `period`

Type: `string`

Date window for page-based ad searches. Available values: `all`, `last24h`, `last7d`, `last14d`, and `last30d`. Defaults to `all`.

#### `activeStatus`

Type: `string`

Choose which ads to include: `all`, `active`, or `inactive`. Defaults to `all`.

#### `sortBy`

Type: `string`

Choose `impressions_desc` to order by impressions or `most_recent` to prioritize recent ads. Defaults to `impressions_desc`.

#### `countryCode`

Type: `string`

Country filter for page-based searches. Use an uppercase two-letter country code such as `US` or `IN`, or use `ALL` for all countries. Defaults to `ALL`.

### 🧪 Example input

```json
{
  "urls": [
    "https://www.facebook.com/Meta",
    "https://www.facebook.com/ads/library/?active_status=all&ad_type=all&country=US&is_targeted_country=false&media_type=all&q=coffee&search_type=keyword_unordered&sort_data[mode]=total_impressions&sort_data[direction]=desc"
  ],
  "scrapeAdDetails": false,
  "limitPerSource": 50,
  "count": 100,
  "period": "last30d",
  "activeStatus": "all",
  "sortBy": "impressions_desc",
  "countryCode": "ALL"
}
```

Not every field is available for every ad. Values and formats depend on the source record, country, ad type, and the data returned during the run. Creative and source-specific metadata may also appear inside `snapshot`.

### 🚀 How to run

1. Add one or more Facebook page or Ad Library URLs to `urls`.
2. Set optional limits and filters for the run.
3. Enable `scrapeAdDetails` if you need additional detail fields.
4. Start the Actor and review the results in the default dataset.

### ⚠️ Notes

- This Actor is intended for publicly visible Ad Library information.
- Use collected data in accordance with applicable laws, privacy requirements, and the source platform's terms.
- Facebook may change its pages or data formats, which can affect availability and structure.

*keywords: facebook ads scraper, meta ads scraper, facebook ads library scraper, scrape facebook ads*

# Actor input Schema

## `urls` (type: `array`):

List of Facebook page or Ad Library search URLs to scrape. Each entry can be a direct URL string. This follows the same functional pattern seen in popular Facebook Ad Library scrapers.

## `scrapeAdDetails` (type: `boolean`):

Enable additional metadata extraction for each ad when the source page provides extra ad fields and detail payloads.

## `limitPerSource` (type: `integer`):

Maximum number of ads to save from each input URL. Leave blank or set to 0 to fetch as much as available within the source limits.

## `count` (type: `integer`):

General result cap for the run. Useful when you want to stop after a fixed number of ad records.

## `period` (type: `string`):

Optional date window for page-based searches, expressed in the same format used by the Ad Library interface.

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

Filter the result set to active, inactive, or all ads reported by the source page.

## `sortBy` (type: `string`):

Controls how ad results are ordered, commonly by impressions or recency.

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

Two-letter ISO country code used by Facebook's library query, such as US, IN, or ALL for all countries.

## Actor input object example

```json
{
  "urls": [
    "https://www.facebook.com/Meta",
    "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=US&is_targeted_country=false&media_type=all&q=coffee&search_type=keyword_unordered&sort_data[mode]=total_impressions&sort_data[direction]=desc"
  ],
  "scrapeAdDetails": false,
  "count": 100,
  "period": "all",
  "activeStatus": "all",
  "sortBy": "impressions_desc",
  "countryCode": "ALL"
}
```

# Actor output Schema

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

Default dataset storing all collected Facebook Ad Library rows.

## `debug` (type: `string`):

Run metadata and debug artifacts stored in the default key-value store.

# 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 = {
    "urls": [
        "https://www.facebook.com/Meta",
        "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=US&is_targeted_country=false&media_type=all&q=coffee&search_type=keyword_unordered&sort_data[mode]=total_impressions&sort_data[direction]=desc"
    ],
    "count": 100,
    "period": "all",
    "activeStatus": "all",
    "sortBy": "impressions_desc",
    "countryCode": "ALL"
};

// Run the Actor and wait for it to finish
const run = await client.actor("laisi/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 = {
    "urls": [
        "https://www.facebook.com/Meta",
        "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=US&is_targeted_country=false&media_type=all&q=coffee&search_type=keyword_unordered&sort_data[mode]=total_impressions&sort_data[direction]=desc",
    ],
    "count": 100,
    "period": "all",
    "activeStatus": "all",
    "sortBy": "impressions_desc",
    "countryCode": "ALL",
}

# Run the Actor and wait for it to finish
run = client.actor("laisi/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 '{
  "urls": [
    "https://www.facebook.com/Meta",
    "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=US&is_targeted_country=false&media_type=all&q=coffee&search_type=keyword_unordered&sort_data[mode]=total_impressions&sort_data[direction]=desc"
  ],
  "count": 100,
  "period": "all",
  "activeStatus": "all",
  "sortBy": "impressions_desc",
  "countryCode": "ALL"
}' |
apify call laisi/facebook-ads-library-scraper --silent --output-dataset

```

## MCP server setup

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