# Facebook Ad Library / Page (Fetchproof) (`fetchproof/fetchproof-facebook-ad-library`) Actor

Search the Meta Ad Library or read a public Facebook page. $12 per 1,000 charged results.

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

## Pricing

$12.00 / 1,000 fetchproof calls

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 / Page (Fetchproof)

Two modes, one Actor, through the [Fetchproof](https://fetchproof.com) API. You do not need a Fetchproof account or API key.

- **ad_library** (default): search companies, list a page's ads, or fetch one ad by Library id or ads/library URL
- **page**: read a public Facebook page profile, optionally with posts (`maxPages` default 1, hard cap 10)

An empty company search is not billed. An ad no longer in the library is a 404 and is not billed.

### Input

| Field | Required | Description |
| --- | --- | --- |
| `mode` | no | `ad_library` (default) or `page` |
| `companyName` | ad_library, unless `pageId` / `adId` / `adUrl` is set | Ad Library search query |
| `pageId` | no | Ad Library page id; skips the company search when set |
| `country` | no | Two-letter country code (e.g. `US`) or `ALL` |
| `status` | no | Ad status. Defaults to `ACTIVE` |
| `adId` / `adUrl` | no | Fetch a single ad by id or `https://www.facebook.com/ads/library/?id=…` |
| `pageUrl` | page mode | Public Facebook page URL |
| `includePosts` | no | Page mode only. Also fetch `GET /v1/facebook/profile/posts` |
| `maxPages` | no | Page mode with `includePosts`. 3 posts per page. Default 1, hard cap 10 |

```json
{ "mode": "ad_library", "companyName": "Nike" }
```

### Output

Each run writes **one dataset item**. `kind` is `facebook_ad_library`, `facebook_ad`, or `facebook_page`.

```json
{
  "platform": "facebook",
  "kind": "facebook_ad_library",
  "companies": { "success": true, "credits_charged": 1, "searchResults": [{ "pageId": "123" }] },
  "pageId": "123",
  "ads": { "success": true, "credits_charged": 1, "results": [{ "id": "ad1" }] },
  "credits_charged": 2,
  "apify_events_charged": 2,
  "calls": [
    { "path": "/v1/facebook/adLibrary/search/companies", "status": 200, "credits_charged": 1, "success": true },
    { "path": "/v1/facebook/adLibrary/company/ads", "status": 200, "credits_charged": 1, "success": true }
  ]
}
```

### Pricing

**$0.012 per successful call** ($12 per 1,000). A successful call is a Fetchproof request that actually charged credits.

Errors, blocked or timed-out requests, invalid requests and cache hits cost nothing. A not-found or empty result is charged only where that operation's published cost says so. Those cases are not billed on Apify. Set a max total charge on the run to cap spend.

### Links

- Site: [fetchproof.com](https://fetchproof.com)
- Docs: [docs.fetchproof.com](https://docs.fetchproof.com)

# Actor input Schema

## `mode` (type: `string`):

ad_library (default) or page.

## `companyName` (type: `string`):

Ad Library search query. Used when pageId is not set.

## `pageId` (type: `string`):

From /v1/facebook/adLibrary/search/companies. Skips the search call when set.

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

Two-letter country code (e.g. US) or ALL. Default ALL.

## `status` (type: `string`):

Defaults to ACTIVE.

## `adId` (type: `string`):

If set, fetches only GET /v1/facebook/adLibrary/ad.

## `adUrl` (type: `string`):

e.g. https://www.facebook.com/ads/library/?id=...

## `pageUrl` (type: `string`):

Required in page mode.

## `includePosts` (type: `boolean`):

Page mode only. Adds GET /v1/facebook/profile/posts (3 posts per page).

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

Page mode with includePosts only. 3 posts per page. Default 1, hard cap 10.

## Actor input object example

```json
{
  "mode": "ad_library",
  "companyName": "Nike",
  "pageUrl": "https://www.facebook.com/mantraindianfolsom",
  "includePosts": false,
  "maxPages": 1
}
```

# Actor output Schema

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

Each run writes one dataset item. kind is facebook_ad_library, facebook_ad, or facebook_page.

# 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 = {
    "companyName": "Nike",
    "maxPages": 1
};

// Run the Actor and wait for it to finish
const run = await client.actor("fetchproof/fetchproof-facebook-ad-library").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 = {
    "companyName": "Nike",
    "maxPages": 1,
}

# Run the Actor and wait for it to finish
run = client.actor("fetchproof/fetchproof-facebook-ad-library").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 '{
  "companyName": "Nike",
  "maxPages": 1
}' |
apify call fetchproof/fetchproof-facebook-ad-library --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,fetchproof/fetchproof-facebook-ad-library"
        }
    }
}
```

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/qLcEGg36nqRrCdXGh/builds/lkfXCVxYe6dDi57E4/openapi.json
