# Meta Ads Library Scraper (Optimized for Developers) (`w3crawler/facebook-ads-library-scraper`) Actor

Scrape ads from Facebook Ad Library without cookies or authentication. Search by keywords or page names, filter by country, ad status, ad type, and media type. Extracts ad text, page info, media URLs, dates, CTA, landing page links, and more.

- **URL**: https://apify.com/w3crawler/facebook-ads-library-scraper.md
- **Developed by:** [w3crawler](https://apify.com/w3crawler) (community)
- **Features:** Limited permissions
- **Stats:** 3 total users, 3 monthly users, 3.7% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.99 / 1,000 ads

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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 Library Scraper (Optimized for Developers)

**Facebook Ads Library Scraper** collects normalized records from the public Meta Ad Library. It searches by keyword or advertiser, accepts public Ad Library URLs, preserves the ad's creative and advertiser context, and follows a bounded amount of the page's public load-more behavior. It does not use login state, private APIs, CAPTCHA solving, stealth, or access-control bypasses.

### Get started

1. Open the [Actor Store page](https://apify.com/w3crawler/facebook-ads-library-scraper) and select **Try for free** or open the **Input** tab.
2. Enter a `query` and `country`, or supply `queries` or public Ad Library `startUrls` for additional targets.
3. Set `maxPages`, `maxItems`, and the status, ad-type, media, and platform filters for the data you need. Keep the limits small for the first run.
4. Start the Actor, open the dataset, and export the saved records as JSON, CSV, or Excel. Open **Run summary** (`OUTPUT`) to check the outcome and counts.

### Input

All fields are optional; the defaults below are ready to use. Unsupported field names and out-of-range values are rejected before requests start.

| Field | Type | Required? | Default | Meaning |
| --- | --- | --- | --- | --- |
| `query` | string | Optional | `Nike` | One public keyword or advertiser search term. Use this, queries, or startUrls. up to 200 characters. |
| `queries` | string array | Optional | Not supplied | Optional additional public keyword or advertiser searches. At most 10 searches are run with the shared maxItems limit. up to 10 items. |
| `startUrls` | object array | Optional | Not supplied | Optional existing public facebook.com/ads/library URLs. Only Meta Ad Library URLs are accepted; no external detail or private URLs are followed. up to 10 items. |
| `country` | string | Optional | `US` | Two-letter ISO 3166-1 country code used by the public Ad Library search. |
| `maxItems` | integer | Optional | `50` | Maximum number of unique public ad records across all queries or URLs. 1–1000. |
| `maxPages` | integer | Optional | `10` | Maximum number of bounded list/load-more passes per search page. 1–20. |
| `activeStatus` | string enum | Optional | `all` | Public Ad Library status filter. Allowed values: "all", "active", "inactive". |
| `adType` | string enum | Optional | `all` | Public Ad Library ad-type filter. Allowed values: "all", "political", "commercial". |
| `mediaType` | string enum | Optional | `all` | Public Ad Library media filter. Allowed values: "all", "image", "video". |
| `platform` | string enum | Optional | `all` | Public publisher-platform filter used by the Ad Library URL. Allowed values: "all", "facebook", "instagram", "audience_network", "messenger". |
| `includeDetails` | boolean | Optional | `true` | Include public page metadata, categories, carousel cards, transparency fields, and other detail fields when exposed. |
| `includeMedia` | boolean | Optional | `true` | Include public image, video, preview, and media URL fields exposed in the page response. |
| `includeRatings` | boolean | Optional | `false` | Read public rating/review fields only if Meta exposes them in the current Ad Library response; absent fields are omitted. |
| `maxConcurrency` | integer | Optional | `1` | Maximum number of public search pages processed at once. 1–3. |
| `delayMs` | integer | Optional | `1500` | Bounded delay after page settling and list advancement. 0–5000. |
| `maxRequestRetries` | integer | Optional | `2` | Bounded Crawlee retries for a public page request. Access-denial pages are stopped, not retried to bypass the restriction. 0–5. |
| `navigationTimeoutSecs` | integer | Optional | `120` | Maximum public page navigation time in seconds. 30–180. |
| `requestHandlerTimeoutSecs` | integer | Optional | `600` | Maximum time allowed for one bounded public page handler. 60–900. |
| `proxyConfiguration` | object | Optional | `{}` | Optional Apify proxy configuration for permitted public traffic. A proxy is never used to bypass an access challenge; challenged pages fail closed. |

Full default input:

```json
{
  "query": "Nike",
  "country": "US",
  "maxItems": 50,
  "maxPages": 10,
  "activeStatus": "all",
  "adType": "all",
  "mediaType": "all",
  "platform": "all",
  "includeDetails": true,
  "includeMedia": true,
  "includeRatings": false,
  "maxConcurrency": 1,
  "delayMs": 1500,
  "maxRequestRetries": 2,
  "navigationTimeoutSecs": 120,
  "requestHandlerTimeoutSecs": 600,
  "proxyConfiguration": {}
}
```

The Actor reads public data from Facebook. It uses one default `query` unless `queries` or `startUrls` supplies additional targets. Each `startUrls` entry is an object with a required `url` string pointing to a public `facebook.com/ads/library` URL. Optional `proxyConfiguration` uses the standard Apify Proxy settings and is never used to bypass a challenge.

### Output

The dataset contains one row per saved public ad. The schema declares no required fields; optional information appears only when Meta publishes it in the current public Ad Library response, and missing values are omitted rather than inferred. No diagnostic or placeholder rows are written.

| Field | Type | Availability | Meaning |
| --- | --- | --- | --- |
| `url` | string | When a Library ID is available | Canonical public Ad Library URL for the ad, constructed from its observed Library ID when available. |
| `libraryId` | string | When published | Meta Ad Library ID shown on the public result card. |
| `adId` | string | When published | Public ad identifier when exposed in the structured response. |
| `collationCount` | integer | When published | Number of ads grouped with this creative when exposed. |
| `collationId` | string | When published | Public creative-collation identifier when exposed. |
| `pageId` | string | When published | Public advertiser/page identifier. |
| `pageName` | string | When published | Advertiser or Facebook Page name shown with the ad. |
| `pageUrl` | string | When published | Public advertiser/Page URL associated with the ad. |
| `pageProfilePictureUrl` | string | When published | Advertiser profile image URL when the public ad snapshot exposes it. |
| `pageLikeCount` | integer | When published | Public advertiser Page like count when exposed. |
| `pageCategories` | string array | When published | Public advertiser Page categories. |
| `categories` | string array | When published | Ad Library categories exposed for the ad. |
| `adText` | string | When published | Full public primary text/body of the ad. |
| `title` | string | When published | Public creative title when exposed. |
| `description` | string | When published | Public link description or creative description. |
| `caption` | string | When published | Public media caption or destination label. |
| `linkUrl` | string | When published | Public destination URL exposed by the creative. |
| `ctaLink` | string | When published | Public call-to-action destination URL. |
| `ctaText` | string | When published | Public call-to-action label. |
| `ctaType` | string | When published | Public call-to-action type code when exposed. |
| `displayFormat` | string | When published | Public creative format such as IMAGE, VIDEO, or CAROUSEL. |
| `status` | string | When published | Business status shown by Ad Library, such as Active or Inactive. |
| `isActive` | boolean | When published | Whether the public structured response marks the ad active. |
| `startDate` | string | When published | ISO timestamp for the observed ad start date. |
| `endDate` | string | When published | ISO timestamp for the observed ad end date when exposed. |
| `startDateTimestamp` | integer | When published | Source start-date Unix timestamp when exposed. |
| `endDateTimestamp` | integer | When published | Source end-date Unix timestamp when exposed. |
| `publisherPlatforms` | string array | When published | Public platforms on which the ad is shown. |
| `impressionsIndex` | number | When published | Public impressions index value when exposed; it is not an impression count. |
| `impressionsText` | string | When published | Public impressions label when exposed. |
| `gatedType` | string | When published | Public delivery eligibility code when exposed. |
| `hideDataStatus` | string | When published | Public data-visibility status from the ad snapshot. |
| `isAaaEligible` | boolean | When published | Public AAA eligibility flag when exposed. |
| `containsDigitalCreatedMedia` | boolean | When published | Public flag indicating digitally created media when exposed. |
| `containsSensitiveContent` | boolean | When published | Public sensitive-content flag when exposed. |
| `pageIsDeleted` | boolean | When published | Public flag indicating whether the advertiser page is deleted. |
| `isReshared` | boolean | When published | Public creative resharing flag when exposed. |
| `disclaimerLabel` | string | When published | Public disclaimer label attached to the creative. |
| `mediaUrl` | string | When published | First valid image or video URL belonging to the ad creative. |
| `imageUrls` | string array | When published | Deduplicated public image URLs belonging to the ad snapshot or its cards. |
| `videoUrls` | string array | When published | Deduplicated public video or preview URLs belonging to the ad snapshot or its cards. |
| `cards` | object array | When published | Bounded public carousel-card creative data when exposed and requested. |
| `regionalRegulationData` | object | When published | Public regional delivery/regulation flags when exposed. |
| `targetedOrReachedCountries` | object array | When published | Public country objects or codes associated with targeting/reach when exposed. |
| `brandedContent` | object | array | string | number | boolean | When published | Public branded-content data when exposed; shape varies by creative. |
| `ratings` | object | When published | Public advertiser/ad rating evidence only when requested and exposed. |
| `platform` | string | When a row is saved | Requested publisher-platform filter. |
| `query` | string | When a row is saved | Keyword or advertiser query that produced the record. |
| `country` | string | When a row is saved | Two-letter Ad Library country filter. |
| `sourceUrl` | string | When a row is saved | Generated or supplied Ad Library search URL that produced the record. |
| `searchUrl` | string | When a row is saved | Alias for the producing Ad Library search URL. |
| `sourcePageUrl` | string | When a result page is rendered | Rendered public result-page URL used for extraction and pagination provenance. |
| `resultCount` | integer | When published | Public total result count reported by the search connection when exposed. |
| `hasNextPage` | boolean | When published | Public search connection flag indicating more result data may be available. |
| `pageNum` | integer | When a row is saved | Bounded page/load pass number in this Actor run. |
| `position` | integer | When a row is saved | Stable one-based output position across the run. |
| `itemPosition` | integer | When a row is saved | One-based item position in the emitted run result set. |
| `scrapedAt` | string | When a row is saved | UTC time when the Actor normalized the record. |

No current-schema ad rows are stored in the Actor's default local dataset, so the example is an empty array rather than an invented ad record:

```json
[]
```

When rows are saved, only fields exposed by the current public Ad Library response are present. Requested filters and provenance fields such as `query`, `country`, `platform`, `pageNum`, `position`, and `scrapedAt` appear on produced records; an absent creative field is not replaced with a placeholder.

### Run summary

**Run summary** is stored separately from the dataset in the run's key-value store under `OUTPUT`.

| Field | Meaning |
| --- | --- |
| `recordType` | Summary discriminator; always `facebook-ads-library-run-summary`. |
| `id` | Run-summary identifier derived from the requested Ad Library search. |
| `status` | Actor process outcome: `SUCCEEDED` or `FAILED`. |
| `runStatus` | Canonical run status; matches `status`. |
| `dataStatus` | Completeness of the saved ads: `COMPLETE`, `PARTIAL`, `NO_RESULTS`, or `FAILED`. |
| `queryCount` | Number of keyword, advertiser, or URL targets processed. |
| `itemCount` | Unique ad records saved to the dataset. |
| `datasetItems` | Dataset rows written, matching `itemCount` for ad records. |
| `diagnosticItems` | Diagnostic dataset rows; always zero because diagnostics stay in the summary and logs. |
| `diagnosticCount` | Operational issues recorded for the run. |
| `blockedCount` | Public responses that were blocked or presented an access-denial page. |
| `pagesProcessed` | Bounded public list or load-more passes processed. |
| `dataAvailable` | Whether at least one source-backed ad was saved. |
| `proxyConfigured` | Whether an Apify Proxy configuration was supplied. |
| `scrapedAt` | Time the summary was written, in ISO UTC. |

No current-schema `OUTPUT` snapshot is stored in the Actor's default key-value store, so the summary table is shown without a value example. When present, `OUTPUT` uses the fields above and the statuses below.

| Status | Data status | Meaning |
| --- | --- | --- |
| `SUCCEEDED` | `COMPLETE` | Eligible ads were saved without an extraction problem. |
| `SUCCEEDED` | `PARTIAL` | Some ads were saved, but a later page or detail failed. Saved rows remain available. |
| `SUCCEEDED` | `NO_RESULTS` | The Ad Library search completed cleanly and returned no matching ads. |
| `FAILED` | `FAILED` | A fatal error occurred before any usable ad was saved. |

### Coverage and limitations

The Actor reads public data from the Meta Ad Library. It does not log in, use cookies, call private APIs, solve CAPTCHAs, or bypass access controls. Each run uses one default keyword unless `queries` adds searches or `startUrls` supplies Ad Library URLs; all targets share `maxItems`. `maxPages` bounds list and load-more passes, and `activeStatus`, `adType`, `mediaType`, and `platform` narrow the public result set.

Creative fields, advertiser details, carousel cards, media URLs, ratings, and regional transparency data appear only when the current public response exposes them and the corresponding `include*` option permits them. `impressionsIndex` is an index value, not an impression count. Access-denied or blocked pages are reported in `OUTPUT` and logs and are never retried to bypass the restriction. Optional `proxyConfiguration` is used only for permitted public traffic.

### Usage and support

More page passes, larger item limits, media arrays, retries, and detail fields increase compute and runtime. Start with small item and page limits, inspect the dataset and run summary, then scale gradually. See the Actor's Pricing tab for current account rates. Use the [Actor Issues page](https://apify.com/w3crawler/facebook-ads-library-scraper/issues) to report a problem. Include the run ID, the input used, and the run summary; do not include tokens, cookies, or private data. This Actor is not affiliated with Meta or Facebook. Use it only for public data and in accordance with the source's terms, robots guidance, and applicable law. Public pages can contain personal information; use the output only for lawful purposes.

# Changelog

This Actor's version history is a separate document: https://apify.com/w3crawler/facebook-ads-library-scraper/changelog.md

# Actor input Schema

## `query` (type: `string`):

One public keyword or advertiser search term. Use this, queries, or startUrls.

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

Optional additional public keyword or advertiser searches. At most 10 searches are run with the shared maxItems limit.

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

Optional existing public facebook.com/ads/library URLs. Only Meta Ad Library URLs are accepted; no external detail or private URLs are followed.

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

Two-letter ISO 3166-1 country code used by the public Ad Library search.

## `maxItems` (type: `integer`):

Maximum number of unique public ad records across all queries or URLs.

## `maxPages` (type: `integer`):

Maximum number of bounded list/load-more passes per search page.

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

Public Ad Library status filter.

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

Public Ad Library ad-type filter.

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

Public Ad Library media filter.

## `platform` (type: `string`):

Public publisher-platform filter used by the Ad Library URL.

## `includeDetails` (type: `boolean`):

Include public page metadata, categories, carousel cards, transparency fields, and other detail fields when exposed.

## `includeMedia` (type: `boolean`):

Include public image, video, preview, and media URL fields exposed in the page response.

## `includeRatings` (type: `boolean`):

Read public rating/review fields only if Meta exposes them in the current Ad Library response; absent fields are omitted.

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

Maximum number of public search pages processed at once.

## `delayMs` (type: `integer`):

Bounded delay after page settling and list advancement.

## `maxRequestRetries` (type: `integer`):

Bounded Crawlee retries for a public page request. Access-denial pages are stopped, not retried to bypass the restriction.

## `navigationTimeoutSecs` (type: `integer`):

Maximum public page navigation time in seconds.

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

Maximum time allowed for one bounded public page handler.

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

Optional Apify proxy configuration for permitted public traffic. A proxy is never used to bypass an access challenge; challenged pages fail closed.

## Actor input object example

```json
{
  "query": "Nike",
  "country": "US",
  "maxItems": 50,
  "maxPages": 10,
  "activeStatus": "all",
  "adType": "all",
  "mediaType": "all",
  "platform": "all",
  "includeDetails": true,
  "includeMedia": true,
  "includeRatings": false,
  "maxConcurrency": 1,
  "delayMs": 1500,
  "maxRequestRetries": 2,
  "navigationTimeoutSecs": 120,
  "requestHandlerTimeoutSecs": 600,
  "proxyConfiguration": {}
}
```

# Actor output Schema

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

No description

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

No description

## `runSummary` (type: `string`):

Run status and counters stored by the Actor.

# 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 = {
    "query": "Nike",
    "country": "US",
    "maxItems": 50,
    "maxPages": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("w3crawler/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 = {
    "query": "Nike",
    "country": "US",
    "maxItems": 50,
    "maxPages": 10,
}

# Run the Actor and wait for it to finish
run = client.actor("w3crawler/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 '{
  "query": "Nike",
  "country": "US",
  "maxItems": 50,
  "maxPages": 10
}' |
apify call w3crawler/facebook-ads-library-scraper --silent --output-dataset

```

## MCP server setup

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