# Facebook Ad Library Scraper - Competitor Ad Spy Tool (`sngh_yvrj_999/facebook-ad-library-scraper-competitor-ad-spy-tool`) Actor

Facebook Ad Library Scraper: extract ads from Meta's Ad Library by keyword and country. Get ad copy, CTA, links, image and video URLs, advertiser names and dates. Export to JSON, CSV or Excel for competitor ad research and ad spy analysis. Beta.

- **URL**: https://apify.com/sngh_yvrj_999/facebook-ad-library-scraper-competitor-ad-spy-tool.md
- **Developed by:** [Yuvraj Singh](https://apify.com/sngh_yvrj_999) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.80 / 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.

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

Extract ads from Meta's public Ad Library: ad copy, titles, call-to-action text, destination links, image and video URLs, carousel cards, and advertiser details. Search by keyword and country, then export the results as JSON, CSV, or Excel.

### What you can do with it

- Monitor the ads competitors are currently running
- Collect ad copy and creative ideas for a niche
- Track which advertisers are active for a keyword
- Feed ad data into spreadsheets, dashboards, or automation tools

### Input

| Field | Type | Default | Description |
|---|---|---|---|
| `searchTerm` | string | – | Keyword or advertiser name to search for (required) |
| `country` | string | `US` | Two-letter country code, for example `US`, `GB`, `DE` |
| `maxResults` | integer | `50` | Maximum number of ads to save |
| `proxyConfiguration` | object | Apify Residential | Residential proxies are recommended |

Example input:

```json
{
  "searchTerm": "running shoes",
  "country": "US",
  "maxResults": 100,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": ["RESIDENTIAL"]
  }
}
```

### Output

Each ad is saved as one dataset item:

```json
{
  "ad_archive_id": "1234567890",
  "ad_library_url": "https://www.facebook.com/ads/library/?id=1234567890",
  "page_id": "987654321",
  "page_name": "Example Brand",
  "start_date": "2026-09-01T00:00:00+00:00",
  "end_date": null,
  "publisher_platforms": ["FACEBOOK", "INSTAGRAM"],
  "title": "Lightweight Running Shoes",
  "body_text": "Built for everyday comfort.",
  "cta_text": "Shop now",
  "destination_link": "https://example.com/shoes",
  "is_catalog_ad": false,
  "original_image_url": "https://...",
  "video_hd_url": null,
  "cards_carousel": []
}
```

Data can be downloaded as JSON, CSV, Excel, XML, or HTML from the dataset, or fetched through the Apify API.

### Notes and limitations

- Catalog (dynamic product) ads store template text such as `{{product.name}}` in Meta's data. The Actor replaces it with the real card text when available. When Meta does not expose it, the field is `null`, and `is_catalog_ad` is `true`.
- Keyword search matches ads whose content mentions the keyword, so results can include advertisers other than the brand you searched for.
- Image and video URLs are temporary links hosted by Meta and expire after some time. Download any media you need to keep.
- Meta can change its website at any time, which may affect results.
- This Actor collects publicly visible Ad Library data. Make sure your use complies with applicable laws and with Meta's terms.

1. Enter a search term and country.
2. Set a small `maxResults` for the first run.
3. Click **Start**, then open the **Output** tab to view or export the ads.

- Residential proxies may require a paid Apify plan. If you are on the free plan and a run fails to load ads, try again with a paid plan or contact the developer.
- For best results use 4096 MB of memory.

### Run it

Recommended memory: 4096 MB.

# Actor input Schema

## `searchTerm` (type: `string`):

Keyword or advertiser name to search for.

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

Two-letter country code, for example US, GB or DE.

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

Maximum number of ads to save.

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

Residential proxies are recommended.

## Actor input object example

```json
{
  "searchTerm": "nike",
  "country": "US",
  "maxResults": 50,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# 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 = {
    "searchTerm": "nike",
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ]
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("sngh_yvrj_999/facebook-ad-library-scraper-competitor-ad-spy-tool").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 = {
    "searchTerm": "nike",
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
    },
}

# Run the Actor and wait for it to finish
run = client.actor("sngh_yvrj_999/facebook-ad-library-scraper-competitor-ad-spy-tool").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 '{
  "searchTerm": "nike",
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}' |
apify call sngh_yvrj_999/facebook-ad-library-scraper-competitor-ad-spy-tool --silent --output-dataset

```

## MCP server setup

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

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/FIgBdcWUKAFKYLhX4/builds/rRjg5lgVNpdCApUoZ/openapi.json
