# Meta Ads Library Scraper — Facebook & Instagram Ads (`bakos_bence/meta-ads-library`) Actor

Scrape Meta Ad Library for Facebook and Instagram ads — copy, CTAs, links, creatives, dates, platforms, spend and reach when shown. Hard resultsLimit cap and honest onlyTotal counts. Residential proxy required. Unofficial; not affiliated with Meta.

- **URL**: https://apify.com/bakos\_bence/meta-ads-library.md
- **Developed by:** [Bakos Bence](https://apify.com/bakos_bence) (community)
- **Categories:** Social media, Lead generation
- **Stats:** 2 total users, 1 monthly users, 75.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.27 / 1,000 ads

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?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

### What does Meta Ads Library Scraper do?

**Scrape Meta Ad Library** search and Facebook Page URLs for **Facebook and Instagram ads** — ad copy, headlines, CTAs, landing links, image and video URLs, page names, start/end dates, platforms, and spend/reach when Meta shows them. Export **JSON or CSV**, schedule runs, or call via **API / MCP**.

**Unofficial.** Not affiliated with Meta. Public Ad Library data only — no login bypass.

#### Why use this scraper?

- 🔒 **Hard `resultsLimit` cap** — billing stops when the limit is hit (competitors often ignore max and overrun)
- 📊 **`onlyTotal` mode** — one honest count row per URL, billed as page-total (no phantom ad rows)
- 🌐 **Residential proxy built-in** — Meta blocks datacenter IPs (403)
- 🔁 **Drop-in keys** from `apify/facebook-ads-scraper` (`startUrls`, `resultsLimit`, `onlyTotal`, …)

#### How to scrape Meta ads

1. Open this Actor in [Apify Console](https://console.apify.com/).
2. Click **Start** on the prefilled US keyword search for Nike (`resultsLimit` 5).
3. Keep **Apify residential proxy** enabled.
4. Export the dataset or pull via API.

```json
{
  "startUrls": [
    { "url": "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=US&search_type=keyword&q=nike" }
  ],
  "resultsLimit": 5,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": ["RESIDENTIAL"]
  }
}
```

**Count-only mode:**

```json
{
  "startUrls": [
    { "url": "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=US&search_type=page&view_all_page_id=15087023444" }
  ],
  "onlyTotal": true
}
```

Returns one row per URL: `{ "totalCount": 1234, "mode": "onlyTotal" }` — **no ad rows, no ad charges**.

#### How much does it cost?

**PPE:** Actor start + **Ad** event per ad row, or **Page total count** ($0.009) in `onlyTotal` mode.

About **$0.49 / 1,000 ads** on Free; lower on paid plans (see Pricing tab).

#### Input

| Field | Description |
|-------|-------------|
| `startUrls` | Meta Ad Library URL or Facebook Page URL (required) |
| `resultsLimit` | Hard cap per URL (prefill **5**) |
| `onlyTotal` | Count only — one row + page-total charge per URL |
| `activeStatus` | `active` / `inactive` if not already in URL |
| `sorting` | `total_impressions` or `relevancy_monthly_grouped` |
| `isDetailsPerAd` | Compatibility stub — adds `ad_details.status=stub` |
| `includeAboutPage` | Compatibility stub — not yet implemented |
| `proxyConfiguration` | **Residential proxy required** |

#### Sample output (ad row)

```json
{
  "adArchiveId": "1234567890123456",
  "pageName": "Nike",
  "pageId": "15087023444",
  "isActive": true,
  "publisherPlatform": ["FACEBOOK", "INSTAGRAM"],
  "startDate": 1735689600,
  "snapshot": {
    "body": "Just Do It.",
    "title": "New collection",
    "linkUrl": "https://www.nike.com/",
    "ctaText": "Shop Now",
    "images": ["https://..."],
    "videos": []
  },
  "sourceUrl": "https://www.facebook.com/ads/library/?...&q=nike",
  "scrapedAt": "2026-08-28T11:00:00+00:00"
}
```

#### Limitations (v0.1)

- **`isDetailsPerAd`** and **`includeAboutPage`**: schema accepted; enrichment is stubbed (see README).
- **`onlyAdsNewerThan` / `onlyAdsOlderThan` / `enrichWithEcommerceData`**: accepted for clone compatibility; set filters in the Ad Library URL instead.
- GraphQL `doc_id` rotates — if extraction returns zero rows across retries, rebuild may be needed.

#### Related Actors

| Actor | Use together when… |
|-------|---------------------|
| [Instagram Profile Scraper](https://apify.com/bakos_bence/instagram-profile-scraper) | You need public profile metadata for brands running the ads |
| [Instagram Comments Scraper](https://apify.com/bakos_bence/instagram-comments) | You pair paid creatives with organic post comment research |
| [Apify Facebook Ads Scraper](https://apify.com/apify/facebook-ads-scraper) | You need the official Store leader with full EU reach enrichment |

#### SEO keywords

facebook ads library scraper, meta ad library api, facebook ad spy, instagram ads library, meta ads scraper, ad library export, competitor facebook ads

***

**Legal:** Public Ad Library transparency data only. No personal profiles or login-gated content.

# Actor input Schema

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

Paste a Meta Ad Library search URL or Facebook Page URL. Bulk edit supported.

## `resultsLimit` (type: `integer`):

Hard cap on ads per start URL — enforced in code (never ignored). Prefill 5 for a cheap first run.

## `onlyTotal` (type: `boolean`):

When enabled, return one row per URL with <code>totalCount</code> only — no ad rows, no ad charges.

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

Filter active or inactive ads when the start URL does not already set <code>active\_status</code>.

## `sorting` (type: `string`):

Sort by impressions or most recent when the start URL has no sort parameter.

## `isDetailsPerAd` (type: `boolean`):

Compatibility with apify/facebook-ads-scraper. Per-ad detail enrichment is stubbed in v0.1 (<code>ad\_details.status=stub</code>).

## `includeAboutPage` (type: `boolean`):

Accepted for compatibility. About-tab enrichment not implemented in v0.1.

## `onlyAdsNewerThan` (type: `string`):

Accepted for apify/facebook-ads-scraper compatibility. Set date filters in the Ad Library URL in v0.1.

## `onlyAdsOlderThan` (type: `string`):

Accepted for compatibility. Set date filters in the Ad Library URL in v0.1.

## `enrichWithEcommerceData` (type: `boolean`):

Accepted for compatibility. Not implemented in v0.1.

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

Meta Ad Library blocks datacenter IPs. Keep Apify residential proxy ON.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=US&search_type=keyword&q=nike"
    }
  ],
  "resultsLimit": 5,
  "onlyTotal": false,
  "activeStatus": "",
  "sorting": "",
  "isDetailsPerAd": false,
  "includeAboutPage": false,
  "enrichWithEcommerceData": false,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ],
    "apifyProxySession": "metaAdsLibSmoke"
  }
}
```

# Actor output Schema

## `overview` (type: `string`):

Default dataset items.

# 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 = {
    "startUrls": [
        {
            "url": "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=US&search_type=keyword&q=nike"
        }
    ],
    "resultsLimit": 5,
    "onlyTotal": false,
    "activeStatus": "",
    "sorting": "",
    "isDetailsPerAd": false,
    "includeAboutPage": false,
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ],
        "apifyProxySession": "metaAdsLibSmoke"
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("bakos_bence/meta-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 = {
    "startUrls": [{ "url": "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=US&search_type=keyword&q=nike" }],
    "resultsLimit": 5,
    "onlyTotal": False,
    "activeStatus": "",
    "sorting": "",
    "isDetailsPerAd": False,
    "includeAboutPage": False,
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
        "apifyProxySession": "metaAdsLibSmoke",
    },
}

# Run the Actor and wait for it to finish
run = client.actor("bakos_bence/meta-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 '{
  "startUrls": [
    {
      "url": "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=US&search_type=keyword&q=nike"
    }
  ],
  "resultsLimit": 5,
  "onlyTotal": false,
  "activeStatus": "",
  "sorting": "",
  "isDetailsPerAd": false,
  "includeAboutPage": false,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ],
    "apifyProxySession": "metaAdsLibSmoke"
  }
}' |
apify call bakos_bence/meta-ads-library --silent --output-dataset

```

## MCP server setup

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