# Meta Ad Library API Scraper - Official Graph API Token (`sonic_scraper/meta-ads-library-monitor`) Actor

Wrapper for Meta's official Ad Library API (ads_archive). Bring your own Meta token, search by keyword or page ID across countries, and export ad copy, page IDs, snapshot URLs, platforms, delivery dates and spend/impression ranges for political and EU ads.

- **URL**: https://apify.com/sonic_scraper/meta-ads-library-monitor.md
- **Developed by:** [Group Oject](https://apify.com/sonic_scraper) (community)
- **Categories:** Social media, Developer tools
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.80 / 1,000 results

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

## Meta Ad Library API Scraper - Official Graph API (Your Token)

Query Meta's **official Ad Library API** (`ads_archive` on the Graph API) with your own Meta access token and export the results as clean JSON, CSV, or Excel. Search by keyword or Facebook page ID across countries and get ad copy, page IDs, snapshot URLs, delivery dates, platforms, reached countries, and, where Meta publishes them, spend and impressions ranges.

> **Don't have a Meta API token?** Use our [Facebook Ads Library Scraper - No Login](https://apify.com/sonic_scraper/meta-ads-library-scraper-no-login) instead. It reads the public Ad Library website and needs no token or account. This Actor is for teams that already have Ad Library API access and want a managed, schedulable wrapper around it.

### What can this Meta Ad Library API Actor do?

- **Keyword search** through `search_terms`, with bulk input (one term per line).
- **Page ID search** through `search_page_ids` to pull one advertiser's ads.
- **Multiple countries per query** via `ad_reached_countries`.
- **Filter by ad type and status** - `ALL` or `POLITICAL_AND_ISSUE_ADS`; `ACTIVE`, `INACTIVE`, or `ALL`.
- **Automatic pagination** with cursor handling, up to 1,000 ads per query.
- **Retries** with exponential backoff on rate limits (HTTP 429) and server errors.
- **Deduplication** of ad archive IDs across all queries in a run.

### Requirements: a Meta Ad Library API token

1. Confirm your identity and location at [facebook.com/ID](https://www.facebook.com/ID).
2. Create a Meta developer app and accept the Ad Library API terms.
3. Generate a user access token in the Graph API Explorer and paste it into **Access token**.

**Coverage rule from Meta:** the API returns ads about social issues, elections, or politics worldwide. Other (commercial) ads are only returned when they were delivered to the **EU** (and other regions where Meta publishes them for transparency). A search for commercial ads with `countries: ["US"]` will usually return nothing; use EU country codes such as `DE`, `FR`, `NL` for commercial competitor research, or use the [No Login scraper](https://apify.com/sonic_scraper/meta-ads-library-scraper-no-login) for any country.

### What data can I extract?

| Field | Description |
| --- | --- |
| `adArchiveId` | Meta Ad Library ID |
| `pageId`, `pageName` | Advertiser page |
| `adSnapshotUrl` | Meta's snapshot URL for the ad creative |
| `adCreativeBody` | Ad text |
| `adCreativeLinkTitle`, `adCreativeLinkDescription`, `adCreativeLinkCaption` | Link headline, description, and caption |
| `adDeliveryStartTime`, `adDeliveryStopTime` | Delivery dates |
| `publisherPlatforms` | `facebook`, `instagram`, `messenger`, `audience_network` |
| `targetedOrReachedCountries` | Countries from Meta's response |
| `spend`, `impressions`, `currency` | Ranges Meta publishes (mainly political and issue ads); `null` otherwise |
| `raw` | The original API object |
| `query`, `queryType`, `fetchedAt` | Which search produced the row and when |

### How much does it cost?

Pay per ad saved: **$4.00 per 1,000 ads** ($0.004 per ad). Queries that return nothing cost nothing. The Meta API itself is free but rate-limited by Meta. Check the **Pricing** tab for the current rate.

### How to use it

1. Paste your **Access token**.
2. Add **Search terms** and/or **Facebook page IDs**.
3. Set **Countries** (EU codes for commercial ads, see above), **Ad type**, and **Active status**.
4. Set **Max ads per query** and click **Start**.

#### Input example

```json
{
  "accessToken": "<YOUR_META_TOKEN>",
  "searchTerms": ["running shoes"],
  "countries": ["DE", "FR"],
  "adType": "ALL",
  "activeStatus": "ACTIVE",
  "maxAdsPerQuery": 200
}
```

#### Output example

```json
{
  "query": "running shoes",
  "queryType": "search_term",
  "adArchiveId": "1234567890123456",
  "pageId": "123456789",
  "pageName": "Example Brand",
  "adSnapshotUrl": "https://www.facebook.com/ads/archive/render_ad/?id=1234567890123456",
  "adCreativeBody": "Example ad text",
  "adDeliveryStartTime": "2026-09-01",
  "adDeliveryStopTime": null,
  "publisherPlatforms": ["facebook", "instagram"],
  "targetedOrReachedCountries": ["DE"],
  "spend": null,
  "impressions": null,
  "currency": null,
  "fetchedAt": "2026-10-01T10:00:00.000Z"
}
```

This is an illustrative record. The run also saves `SUMMARY` and `ERRORS` in the key-value store.

### Run via API

```python
from apify_client import ApifyClient

client = ApifyClient("<YOUR_APIFY_TOKEN>")
run = client.actor("sonic_scraper/meta-ads-library-monitor").call(run_input={
    "accessToken": "<YOUR_META_TOKEN>",
    "searchTerms": ["electric bike"],
    "countries": ["NL"],
    "maxAdsPerQuery": 100,
})
print(client.dataset(run["defaultDatasetId"]).list_items().items[:3])
```

### Use with AI agents (MCP)

Connect the Apify MCP server at `https://mcp.apify.com?tools=sonic_scraper/meta-ads-library-monitor` in Claude Desktop, Cursor, VS Code or any MCP client, and your AI assistant can call this actor as a tool. Example prompt: *"Pull the active Meta ads for these advertiser pages with my token and list the new ones since last week."*

### FAQ

#### Is my token stored in the output?

No. The token is only used to call the Graph API; it is not written to the dataset or the run summary. Store it as a secret input in saved tasks.

#### Why are spend and impressions empty?

Meta only publishes spend and impression ranges for political and issue ads. Commercial ads return `null` for these fields.

#### Why do I get zero results for US commercial ads?

That is Meta's API coverage rule, not a scraper error. See **Requirements** above.

#### Does it download images or videos?

No. Use `adSnapshotUrl` to view the creative.

### Related Actors

- [Facebook Ads Library Scraper - No Login](https://apify.com/sonic_scraper/meta-ads-library-scraper-no-login) - no token needed, any country.
- [Facebook Page Posts Monitor](https://apify.com/sonic_scraper/facebook-page-posts-monitor) - organic posts from the same advertisers.

# Changelog

This Actor's version history is a separate document: https://apify.com/sonic_scraper/meta-ads-library-monitor/changelog.md

# Actor input Schema

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

Required. Meta Graph API access token with access to the Ad Library API.

## `searchTerms` (type: `array`):

Keywords to search in Meta Ad Library.

## `searchTermsText` (type: `string`):

Paste one search term per line or comma-separated.

## `pageIds` (type: `array`):

Optional Facebook page IDs to search by advertiser/page.

## `countries` (type: `array`):

Country codes passed to ad_reached_countries.

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

Meta ad_type parameter. ALL is broad; POLITICAL_AND_ISSUE_ADS exposes more transparency fields where available.

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

Meta ad_active_status parameter.

## `apiVersion` (type: `string`):

Meta Graph API version.

## `maxAdsPerQuery` (type: `integer`):

Maximum ads to fetch per search term or page ID.

## `maxQueries` (type: `integer`):

Maximum search terms/page IDs to process.

## `dedupe` (type: `boolean`):

Remove duplicate ad archive IDs across all queries.

## `requestDelayMs` (type: `integer`):

Delay between API requests.

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

Parallel API queries.

## `debugMode` (type: `boolean`):

Verbose logging.

## Actor input object example

```json
{
  "searchTerms": [
    "nike",
    "openai",
    "crm software"
  ],
  "countries": [
    "US"
  ],
  "adType": "ALL",
  "activeStatus": "ALL",
  "apiVersion": "v20.0",
  "maxAdsPerQuery": 100,
  "maxQueries": 100,
  "dedupe": true,
  "requestDelayMs": 500,
  "maxConcurrency": 2,
  "debugMode": false
}
```

# Actor output Schema

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

One row per ad from Meta Ad Library API.

## `adsByPage` (type: `string`):

Ads grouped by advertiser/page.

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

Totals, top pages, top platforms, and warnings.

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

API queries that failed.

# 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 = {
    "searchTerms": [
        "nike",
        "openai",
        "crm software"
    ],
    "countries": [
        "US"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("sonic_scraper/meta-ads-library-monitor").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 = {
    "searchTerms": [
        "nike",
        "openai",
        "crm software",
    ],
    "countries": ["US"],
}

# Run the Actor and wait for it to finish
run = client.actor("sonic_scraper/meta-ads-library-monitor").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 '{
  "searchTerms": [
    "nike",
    "openai",
    "crm software"
  ],
  "countries": [
    "US"
  ]
}' |
apify call sonic_scraper/meta-ads-library-monitor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,sonic_scraper/meta-ads-library-monitor"
        }
    }
}
```

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/iZUO1nWMW335EjLbL/builds/Cd2GQNM6OnYOgPjma/openapi.json
