# Facebook Ad Library Scraper - Ads, Creatives & Advertisers (`apivault_labs/facebook-ad-library-scraper`) Actor

Collect public Facebook ad text, images, videos, advertiser IDs and landing URLs by keyword or Page ID. Paginated, deduplicated results. US residential proxy recommended. $0.40–$0.70 per 1,000 ads by Apify tier, plus usage.

- **URL**: https://apify.com/apivault_labs/facebook-ad-library-scraper.md
- **Developed by:** [Apivault Labs](https://apify.com/apivault_labs) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.40 / 1,000 ad delivereds

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
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 Ad Library Scraper — Ads, Creatives & Advertisers (No Login)

> **Scrape the public [Facebook Ad Library](https://www.facebook.com/ads/library/) at scale.** Search by keyword or advertiser page, with a requested country filter, and pull ad copy, image & video creatives, call-to-action, landing URLs, the advertiser page, publisher platforms (Facebook / Instagram / Messenger / Audience Network) and active-status with start/end dates. No account login or imported cookies. A fresh anonymous homepage session is used.

**Release and coverage:** production 1.1.2 restored collection: 60 distinct ads across 7 pages in a bounded QA run. Version 1.2 adds a result spending-limit check. US residential proxy access is required for the verified path; source restrictions can still cause partial or failed collection.

***

### ✨ Highlights

- 🔎 **Search by keyword or page** — paste a ready Ad Library URL or just type a keyword.
- 🌍 **Requested market** — send an ISO country filter (or all); live verification covers US active ads.
- 🖼️ **Creative fields** — ad text, title, caption, CTA, landing URL, plus image and available video URLs. Optional fields may be absent.
- 🏢 **Advertiser details** — page name, page id, likes, categories, profile link.
- 📡 **Placement & status** — publisher platforms, active flag, start & end dates.
- 🧰 **Filters** — ad category (all / political / employment / housing / financial), media type, active status.
- 🆓 **No login** — reads only the public Ad Library.

***

### Quick start

Use the following bounded request for the verified US keyword path:

```json
{"searchTerms":"shoes","country":"US","activeStatus":"active","maxAds":5,"maxPages":3,"useResidentialProxy":true,"proxyCountry":"US"}
```

Inspect the Dataset count and `SUMMARY` before treating the run as complete. Export via Apify Dataset to JSON, CSV or Excel. No API keys from a third-party scraping provider are required.

***

### 📥 Input

| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `searchUrl` | string | — | A URL copied from the Ad Library after setting filters. Overrides the fields below. |
| `searchTerms` | string | `shoes` | Keyword to search ads for (when no URL is given). |
| `country` | string | `US` | ISO 2-letter country code, or `ALL`. |
| `adType` | string | `all` | `all` / `political_and_issue_ads` / `employment_ads` / `housing_ads` / `financial_products_and_services_ads`. |
| `activeStatus` | string | `active` | `active` / `inactive` / `all`. |
| `mediaType` | string | `all` | `all` / `image` / `video` / `meme` / `none`. |
| `maxAds` | integer | `50` | Maximum number of ads to return. |
| `useResidentialProxy` | boolean | `true` | Use Apify residential proxy (recommended). |
| `proxyCountry` | string | `US` | ISO country for the residential proxy. |

#### Example — keyword search

```json
{ "searchTerms": "real estate", "country": "US", "activeStatus": "active", "maxAds": 100 }
```

#### Example — paste an Ad Library URL

```json
{ "searchUrl": "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=GB&q=coffee&search_type=keyword_unordered&media_type=all" }
```

***

### 📤 Output (one item per ad)

```json
{
  "adArchiveId": "607401198534818",
  "isActive": true,
  "pageId": "110341895329134",
  "pageName": "Good Story",
  "pageLikeCount": 777,
  "pageCategories": ["Book"],
  "adText": "Hello",
  "title": null,
  "caption": "example.net",
  "ctaText": "Learn more",
  "ctaType": "LEARN_MORE",
  "linkUrl": "https://example.net/landing",
  "displayFormat": "VIDEO",
  "images": [],
  "videos": [{ "hd": "https://video...mp4", "preview": "https://scontent...jpg" }],
  "publisherPlatforms": ["FACEBOOK", "INSTAGRAM", "AUDIENCE_NETWORK", "MESSENGER"],
  "startDate": "2024-12-15",
  "endDate": "2024-12-19",
  "country": "US",
  "adLibraryUrl": "https://www.facebook.com/ads/library/?id=607401198534818"
}
```

***

### 💡 Use cases

- **Competitor ad intelligence** — inspect the public creatives and offers returned for advertiser searches.
- **Ad inspiration & swipe files** — collect observed hooks, CTAs and formats by niche.
- **Market & trend research** — inspect sampled advertisers returned for a keyword and market.
- **Agency reporting** — monitor a client's or competitor's live ads over time.
- **Ad research exports** — export available ad rows for analysis. Political categories are accepted inputs but not independently verified in this release.

***

### ⚙️ Notes & limits

- Active PPE pricing: $0.40–$0.70 per 1,000 delivered ad rows by Apify discount tier, no separate start event. Apify platform and residential proxy usage is additional; check the Pricing tab for the active rate.
- Reads only the **public** Ad Library — the same data Facebook shows any visitor.
- For best reliability keep residential proxy on; Facebook rate-limits datacenter IPs.
- The Ad Library only exposes the data Facebook chooses to publish; some fields (spend, impressions) are populated only for political / issue ads.

***

Built and maintained by **Apivault** — reliable data Actors, fair pricing.

### Collection and coverage

The collector bootstraps an anonymous public session from the Facebook homepage, reads only values actually present, and requests `AdLibrarySearchPaginationQuery`. It does not import account cookies or silently solve a challenge. The Ad Library HTML endpoint may refuse access while the GraphQL search is available through an explicitly requested residential proxy. Session tokens are not output fields.

`maxPages` (default20,range1–100), `runBudgetSecs` (180,10–600) and `requestTimeoutSecs` (30,5–60) limit collection. `maxAds` remains a requested upper bound, not guaranteed volume. Source pages can contain fewer ads than requested. A short page continues when the source provides a next cursor. IDs are deduplicated across pages; repeated cursors stop with a pagination diagnostic.

KVS records `SUMMARY` and `ERRORS` have no result fee and distinguish `OK`, verified `EMPTY`, `FAILED`, `PARTIAL` and spending-limited `LIMITED`. Source denial/query errors are not empty-search evidence. Late failure preserves collected ads and reports incomplete coverage. `coverageComplete` is false when limits or errors prevent source exhaustion. The Dataset contains validated ad rows only.

Output retains existing fields and adds `success`, `type`, `sourcePage`, `scrapedAt`, `countryFilterRequested` and `countryFilterVerified:false`. The legacy `country` field is also the requested market, not verified geography for each ad. Commercial ad spend, impressions and reach are not inferred or promised. Keywords are source search semantics, not proof every creative text literally contains the string. A numeric Page ID is checked against each returned advertiser; active-status and image/video predicates are checked before delivery. Missing optional fields remain null/empty lists.

### Availability and costs

**Active result pricing (verified 21 October 2026):**

| Apify discount tier | Fee per 1,000 delivered ads |
|---|---:|
| FREE | $0.70 |
| BRONZE | $0.60 |
| SILVER | $0.50 |
| GOLD | $0.40 |
| PLATINUM | $0.40 |
| DIAMOND | $0.40 |

One synthetic `apify-default-dataset-item` event is charged per validated ad written to the default Dataset. No start fee, subscription, error or summary event. **Apify compute/storage and residential proxy traffic are additional** (`isPPEPlatformUsagePaidByUser=true`). The active Pricing tab is authoritative. Five ads cost $0.002–$0.0035 in result fees depending on tier; this is not an all-in quote.

These are Apify discount tiers, not discounts based on the number of rows in a single run. Apify normalized enterprise tiers to the GOLD rate when saving this configuration. A failed or empty collection writes no result rows and charges no result events; any already delivered useful rows remain chargeable on a later source failure.

Real billing checks on the Actor delivered 60 rows = 60 result events and 5 = 5; invalid input, direct source failure and verified empty search gave 0 = 0. The collector checks the remaining result budget before requesting ads and reduces the requested cap to the number of ads that can still be charged. A refused SDK push never increases the reported delivered count.

Use your own Apify account and API token. The recommended default run is 256 MB with a 240-second platform timeout. Available saved Tasks, if any, are shown on the Actor page; the JSON examples below work directly as run input.

### API, clients and limitations

Use an authenticated Apify client with the exact Actor ID `iKdo3ZtYYdDcCSWPv` or `apivault_labs/facebook-ad-library-scraper`. Official [REST API](https://docs.apify.com/api/v2), [Python client](https://docs.apify.com/api/client/python/) and [JavaScript client](https://docs.apify.com/api/client/js/) support run and storage access. These are platform SDKs, not proof of a separate Facebook Ads-specific client. MCP discovery/collection and dedicated n8n/GitHub/Python client mappings must be verified separately; no working integration is claimed merely from a package name. This actor differs from the portfolio's combined Facebook/TikTok/Google Ad Library actor.

**Will a request for 5,000 return 5,000?** Only if the source exposes that many valid distinct ads within page/time/account limits. Full source coverage and sustained access are not guaranteed.

**Does HTTP 200 mean ads were collected?** No. GraphQL can return structured errors inside HTTP 200. Read `SUMMARY`/`ERRORS` and the actual Dataset count.

**Why can I see PARTIAL?** Useful ads were collected before a source, pagination or validation problem. Exported rows remain useful; coverage is incomplete.

#### Existing n8n integration

The published [n8n-nodes-apivault-facebook-ads0.1.0](https://www.npmjs.com/package/n8n-nodes-apivault-facebook-ads) distributed code targets this exact Actor. That establishes the package mapping, not n8n verification, n8n Cloud availability, support for the new controls or verification of every supported operation. Its linked GitHub repository returned 404 during this repair; a dedicated Python package is not confirmed. Use your own Apify credentials and inspect the current Actor schema.

**Why can the total exceed the ad fee?** This pricing configuration passes Apify compute/storage and residential traffic charges to the run owner separately. Set a run spending limit and a small `maxAds` when trying the Actor.

**Can it return every advertiser ad?** Only ads exposed by the source within configured limits are returned. A completed request at `maxAds` is a capped sample, not a complete archive.

# Changelog

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

# Actor input Schema

## `searchUrl` (type: `string`):

Paste a URL from https://www.facebook.com/ads/library/ after setting your filters. If provided, it overrides the fields below.

## `searchTerms` (type: `string`):

Keyword to search ads for (used when no search URL is given), e.g. 'real estate', 'sneakers'.

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

ISO 2-letter country code for the ad market (e.g. US, GB, DE). Use ALL for all countries.

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

Which Ad Library category to search.

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

Show active ads, inactive ones, or both.

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

Filter by ad media type.

## `maxAds` (type: `integer`):

Maximum number of ads to return.

## `useResidentialProxy` (type: `boolean`):

Facebook rate-limits datacenter IPs. Residential proxy is strongly recommended.

## `proxyCountry` (type: `string`):

ISO 2-letter country for the residential proxy (e.g. US). Empty = automatic.

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

Safety cap on source pages; each page may return fewer than30unique ads.

## `runBudgetSecs` (type: `integer`):

Shared budget for homepage bootstrap and all search pages; platform shutdown time is reserved.

## `requestTimeoutSecs` (type: `integer`):

Maximum duration per source request, bounded by the remaining collection budget.

## Actor input object example

```json
{
  "searchUrl": "",
  "searchTerms": "shoes",
  "country": "US",
  "adType": "all",
  "activeStatus": "active",
  "mediaType": "all",
  "maxAds": 50,
  "useResidentialProxy": true,
  "proxyCountry": "US",
  "maxPages": 20,
  "runBudgetSecs": 180,
  "requestTimeoutSecs": 30
}
```

# Actor output Schema

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

Useful delivered ad rows in the default Dataset.

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

Status, counts, coverage and stop reason.

## `errors` (type: `string`):

Collection errors; these are not billable ad rows.

# 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 = {
    "searchUrl": "",
    "searchTerms": "shoes"
};

// Run the Actor and wait for it to finish
const run = await client.actor("apivault_labs/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 = {
    "searchUrl": "",
    "searchTerms": "shoes",
}

# Run the Actor and wait for it to finish
run = client.actor("apivault_labs/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 '{
  "searchUrl": "",
  "searchTerms": "shoes"
}' |
apify call apivault_labs/facebook-ad-library-scraper --silent --output-dataset

```

## MCP server setup

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