# Facebook Ads Library Scraper (`jimmy-o/facebook-ads-library`) Actor

Search the official Meta Ad Library API: the public archive of ads on Facebook, Instagram, Messenger, Audience Network, WhatsApp and Threads. Structured JSON per ad. Bring your own free Meta token. Free while in launch promo.

- **URL**: https://apify.com/jimmy-o/facebook-ads-library.md
- **Developed by:** [Omar Gamal](https://apify.com/jimmy-o) (community)
- **Categories:** Marketing, Social media
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## 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

The Facebook Ads Library Scraper searches Meta's **official Ad Library API** -
the same public ad archive behind
[facebook.com/ads/library](https://facebook.com/ads/library) - and returns
structured JSON for ads running (or previously run) on Facebook, Instagram,
Messenger, Audience Network, WhatsApp and Threads.

**Free while in launch promo.** No scraping, no proxies, no blocks: this actor
is a thin wrapper over Meta's own API, so it is stable by design.

### What you get per ad

- Advertiser: page ID + page name, and a live `adSnapshotUrl` to view the creative
- Creative: body text, link titles, descriptions, captions
- Delivery: start/stop times, creation time, platforms, languages, countries reached
- For political / social-issue ads also: spend range, impressions range, estimated
  audience size, aggregate demographic and per-region delivery breakdowns

### What you need (5 minutes, free)

The Ad Library API requires your own free Meta access token. This is Meta's
requirement, not ours - there is no way around it, and any tool claiming
otherwise is scraping against Meta's rules:

1. Confirm your identity with Meta at
   [facebook.com/ID](https://www.facebook.com/ID).
2. Go to [developers.facebook.com](https://developers.facebook.com), create a
   free developer account, then create an app (type: any, e.g. "Business").
3. In the app dashboard open **Tools > Graph API Explorer**.
4. Click **Generate Access Token** and copy it.
5. Paste it into this actor's **Meta access token** input and run.

Explorer tokens live about an hour; Meta's
[long-lived token docs](https://developers.facebook.com/docs/facebook-login/guides/access-tokens/get-long-lived)
explain the 60-day exchange.

### Example

Search terms `["real estate"]`, countries `["AE"]`, max results 100: you get up
to 100 property ads currently reaching the UAE, each with advertiser page,
creative text, platforms and start date.

### FAQ

**Why a token?** Meta gates the Ad Library API behind a free developer token;
it keeps the data official and your account safe.
**Does it scrape Facebook?** No - every row comes from Meta's official API.
**Historical ads?** Commercial ads show currently active delivery; political
and social-issue ads include archived spend/impression ranges.

### Cost

The actor itself is free. Runs use a few seconds of Apify compute, so a typical
run costs a fraction of a cent of Apify usage.

### More free scrapers from jimmy-o

- [UAE Real Estate Scraper](https://apify.com/jimmy-o/uae-real-estate-listings)
- [Saudi Real Estate Scraper](https://apify.com/jimmy-o/saudi-real-estate-listings)
- [Reddit Scraper](https://apify.com/jimmy-o/reddit-scraper)
- [YouTube Scraper](https://apify.com/jimmy-o/youtube-scraper)

# Actor input Schema

## `accessToken` (type: `string`):

Your Meta (Facebook) developer access token with Ad Library API access. Get one free at developers.facebook.com: create an app, confirm your identity with Meta, then generate a token. See the README for a 5-step guide.

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

Full-text search over ad creatives, like the search box on facebook.com/ads/library. Leave empty to list all ads for the selected countries (can be very large).

## `adReachedCountries` (type: `array`):

ISO country codes the ads were shown in (the Ad Library API requires at least one). Examples: \["US"], \["EG", "SA", "AE"].

## `adActiveStatus` (type: `string`):

Filter by whether the ad is currently running.

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

ALL returns commercial ads. The regulated categories (political, housing, employment, credit) are served from Meta's separate regulated archive.

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

Filter by the creative's media type.

## `publisherPlatforms` (type: `array`):

Optional. Limit to specific platforms: facebook, instagram, audience_network, messenger, whatsapp, threads. Empty means all.

## `searchPageIds` (type: `array`):

Optional. Limit to ads from specific Facebook Page IDs (as strings), e.g. \["123456789"].

## `adDeliveryDateMin` (type: `string`):

Optional. Only ads delivered on or after this date, format YYYY-MM-DD.

## `adDeliveryDateMax` (type: `string`):

Optional. Only ads delivered on or before this date, format YYYY-MM-DD.

## `maxResults` (type: `integer`):

Stop after this many ads (1-10000).

## Actor input object example

```json
{
  "searchTerms": "",
  "adReachedCountries": [
    "US"
  ],
  "adActiveStatus": "ALL",
  "adType": "ALL",
  "mediaType": "ALL",
  "publisherPlatforms": [],
  "searchPageIds": [],
  "adDeliveryDateMin": "",
  "adDeliveryDateMax": "",
  "maxResults": 100
}
```

# Actor output Schema

## `results` (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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("jimmy-o/facebook-ads-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 = {}

# Run the Actor and wait for it to finish
run = client.actor("jimmy-o/facebook-ads-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 '{}' |
apify call jimmy-o/facebook-ads-library --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,jimmy-o/facebook-ads-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/kRh4akXY6dh3gWSM6/builds/3pREWlX2Cn1mD7fGr/openapi.json
