# Facebook Ads Library Scraper – Meta Ads & Competitor Monitoring (`builtbysaif/meta-ads-library-scraper`) Actor

Scrape public Facebook and Instagram ads from Meta Ad Library by keyword, advertiser Page ID, or URL. Export ad copy, creative URLs, CTAs, and landing pages to CSV or JSON. Monitor new or changed competitor ads across runs.

- **URL**: https://apify.com/builtbysaif/meta-ads-library-scraper.md
- **Developed by:** [Md Saif Ahmed](https://apify.com/builtbysaif) (community)
- **Features:** Limited permissions
- **Stats:** 5 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.70 / 1,000 ad results

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 Ads Library Scraper

Export public Facebook and Instagram ads from Meta Ad Library to CSV, Excel, or JSON. Search by product keyword, advertiser Page ID, or an Ad Library URL. Each dataset record represents an ad and includes the available advertiser, copy, creative URLs, delivery status, call to action, and landing page.

### Start with an example

Open an example, select **Try for free** to load its input, then swap in your own keyword or advertiser. Start with a small result limit to check coverage for your market.

- [Research Competitor Facebook Ads](https://apify.com/builtbysaif/meta-ads-library-scraper/examples/research-competitor-facebook-ads)
- [Find Facebook Ads by Product Keyword](https://apify.com/builtbysaif/meta-ads-library-scraper/examples/find-facebook-ads-by-product-keyword)
- [Find Instagram Video Ads for Creative Research](https://apify.com/builtbysaif/meta-ads-library-scraper/examples/find-instagram-video-ads-for-creative-research)
- [Download Facebook Ad Creative Images and Videos](https://apify.com/builtbysaif/meta-ads-library-scraper/examples/download-facebook-ad-creative-images-and-videos)
- [Monitor New and Changed Competitor Facebook Ads](https://apify.com/builtbysaif/meta-ads-library-scraper/examples/monitor-new-and-changed-competitor-facebook-ads)
- [Compare Facebook Ads Across the U.S. and UK](https://apify.com/builtbysaif/meta-ads-library-scraper/examples/compare-facebook-ads-across-the-u-s-and-uk)
- [Find Facebook Image Ads for Creative Research](https://apify.com/builtbysaif/meta-ads-library-scraper/examples/find-facebook-image-ads-for-creative-research)
- [Find Inactive Facebook Ads for an Advertiser](https://apify.com/builtbysaif/meta-ads-library-scraper/examples/find-inactive-facebook-ads-for-an-advertiser)
- [Export Facebook Ad Landing Pages and CTAs](https://apify.com/builtbysaif/meta-ads-library-scraper/examples/export-facebook-ad-landing-pages-and-ctas)

After the run, open the **Dataset** to export your results. For a repeatable CSV or JSON export, use the [Actor API](https://apify.com/builtbysaif/meta-ads-library-scraper/api). Meta controls which ads and fields are publicly available. Use the export for creative research, since it does not contain private conversions or return on ad spend.

### Features

- Search by URL, one keyword query per run, or advertiser Page ID
- Country, status, category, platform, media, and date filters
- Images and videos with optional file downloads
- Runs without login cookies; residential proxy support is optional for fuller coverage
- Anonymous Meta warm-up, headful stealth Chrome, and human-paced navigation
- Persistent `firstSeenAt`, `lastSeenAt`, and change detection
- Incremental `onlyNewOrChanged` runs for scheduled monitoring
- Automatic retries and persistent request queues
- JSON, JSONL, CSV, XML, Excel, and API output through Apify Dataset

Only information publicly displayed by Meta on the Ads Library results page is collected.

Use `searchQuery` for a keyword or phrase. The Actor accepts one search query per run to keep execution time predictable and reduce timeout risk. Run separate Actor tasks for separate queries.

### Run locally

Install the Apify CLI and sign in if you want to use Apify Proxy locally:

```bash
npm install
npm run build
apify login
apify run
```

The example input runs without Apify Proxy. Add a residential proxy for larger or more reliable production runs.

### Deploy

```bash
apify login
apify push
```

The Actor Console creates its input form from `.actor/input_schema.json`. The default runs without a proxy; production users can enable an Apify residential or external proxy from the same field.

### Monitoring

Set a stable `monitoringKey`, enable `onlyNewOrChanged`, and schedule the Actor. Runs that use the same key share a named key-value store. Every ad is fingerprinted from its status, content, destination, and creatives. The Dataset then receives only new or changed ads.

### Output

The default Dataset contains flat fields for convenient CSV/Excel exports and a `media` array for structured integrations. `PROGRESS` and `OUTPUT` records are written to the default key-value store during each run.

### Notes

Meta changes Ads Library markup regularly. The extractor deliberately relies on visible labels, links, media dimensions, and Library IDs instead of generated CSS class names. Fixtures should be added whenever a changed Meta layout is encountered.

# Actor input Schema

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

Search result or advertiser URLs copied from Meta Ads Library.

## `searchQuery` (type: `string`):

One keyword or phrase to search in Meta Ads Library. Use one query per run to avoid long runs and timeouts.

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

Meta Page IDs whose ads should be collected.

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

Two-letter country codes used in generated Ads Library URLs.

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

Collect all ads, active ads, or inactive ads.

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

Filter the Ads Library by its supported ad category.

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

Limit results to a specific creative format.

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

Optional Meta platforms, such as facebook, instagram, messenger, and audience_network.

## `dateMin` (type: `string`):

Optional date in YYYY-MM-DD format.

## `dateMax` (type: `string`):

Optional date in YYYY-MM-DD format.

## `maxAds` (type: `integer`):

Maximum unique ads saved across the run.

## `downloadMedia` (type: `boolean`):

Save public image and video files to the run's key-value store.

## `onlyNewOrChanged` (type: `boolean`):

Compare ads with a persistent monitoring state and omit unchanged records.

## `monitoringKey` (type: `string`):

Reuse the same key on scheduled runs to track changes for one watchlist.

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

Maximum number of browser pages processed at the same time.

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

The scraper can run without a proxy. Use a residential proxy for fuller and more reliable production results.

## Actor input object example

```json
{
  "searchQuery": "nike",
  "countries": [
    "US"
  ],
  "activeStatus": "all",
  "adType": "all",
  "mediaType": "all",
  "maxAds": 100,
  "downloadMedia": false,
  "onlyNewOrChanged": false,
  "maxConcurrency": 1,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `results` (type: `string`):

Normalized ads collected during this run.

## `progress` (type: `string`):

Latest processing counters for the run.

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

Final processed and saved counts.

## `media` (type: `string`):

Creative files downloaded when downloadMedia is enabled.

# 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 = {
    "searchQuery": "nike"
};

// Run the Actor and wait for it to finish
const run = await client.actor("builtbysaif/meta-ads-library-scraper").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 = { "searchQuery": "nike" }

# Run the Actor and wait for it to finish
run = client.actor("builtbysaif/meta-ads-library-scraper").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 '{
  "searchQuery": "nike"
}' |
apify call builtbysaif/meta-ads-library-scraper --silent --output-dataset

```

## MCP server setup

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

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/3Co5cbySK46pfjBx0/builds/dYpqoENkXLlFxhT3C/openapi.json
