# Facebook Ad Library Scraper (cheap) (`istmobot/facebook-ads-library-cheap`) Actor

Low-cost scraper for the public Facebook / Meta Ad Library: keyword searches and Page URLs, with the same input and output fields as the popular ad library scrapers. No login needed. $0.41 per 1,000 ads.

- **URL**: https://apify.com/istmobot/facebook-ads-library-cheap.md
- **Developed by:** [Istmobot](https://apify.com/istmobot) (community)
- **Categories:** Social media, Marketing, Lead generation
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.41 / 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 (cheap)

A cheaper drop-in alternative for scraping the public Facebook / Meta Ad Library. It uses the same input and output fields as the popular ad library scrapers, so you can switch without code changes. No login and no cookies needed.

| | Price |
|---|---|
| Per ad | **$0.00041** ($0.41 per 1,000 ads) |
| Per run start | $0.005 |
| Error rows | Free |

### Input

Paste Ad Library search URLs or Facebook Page URLs into `urls`.

```json
{
  "urls": [
    { "url": "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=US&q=nike&search_type=keyword_unordered&media_type=all" },
    { "url": "https://www.facebook.com/ZapierApp" }
  ],
  "limitPerSource": 200,
  "count": 500
}
```

| Field | What it does |
|---|---|
| `urls` | Ad Library search URLs (build the search on facebook.com/ads/library and copy the URL) or Page URLs. |
| `scrapeAdDetails` | Adds advertiser, EU reach and transparency fields to each ad. Off by default. Needs one extra request per ad, so runs are slower. Same price per ad. |
| `limitPerSource` | Stops a URL at the end of the page that reaches this number, so it can exceed the limit by up to 30 ads. |
| `count` | Stops the whole run at exactly this many ads. |
| `scrapePageAds.period` | Page URLs only: all time, or the last 24 hours, 7, 14 or 30 days. |
| `scrapePageAds.activeStatus` | Page URLs only: `all`, `active` or `inactive`. |
| `scrapePageAds.sortBy` | Page URLs only: `impressions_desc` or `most_recent`. |
| `scrapePageAds.countryCode` | Page URLs only: 2-letter country code, or `ALL`. |
| `runTag` | Copied to a `runTag` column on each ad. |
| `proxy` | Optional custom proxy. By default the Actor uses datacenter proxies, with residential as a fallback. |

### Output

One row per ad, in the order the Ad Library shows them.

- **Ad fields:** `ad_archive_id`, `collation_id`, `collation_count`, `is_active`, `page_id`, `page_name`, `snapshot` (body, title, images, videos, cards, link, call to action), `categories`, `currency`, `spend`, `reach_estimate`, `impressions_with_index`, `publisher_platform`, `start_date`, `end_date`, `targeted_or_reached_countries`, and more.

- **Added fields:** `url`, `position`, `ads_count`, `start_date_formatted`, `end_date_formatted`, `ad_library_url`.

- **Search URLs** add `total`, the number of ads Facebook reports for the search.

- **Page URLs** add `pageInfo`: `page_id`, `creation_date`, `admin_info`, `ad_status`, `transparency_see_all`.

- **With `scrapeAdDetails`** each ad also has `advertiser`, `aaa_info` (payer and beneficiary, audience, `eu_total_reach`, reach by country, age and gender), `violation_types`, `verified_voice_context`, `transparency_by_location` and `is_violating_eu_siep`.

A URL that fails produces a free row with `url`, `errorType` and `error`.

### Limitations

- With `scrapeAdDetails`, an ad whose details still fail after retries keeps its other fields, with the detail fields set to null, and the run log says how many.
- Image and video links are signed by Facebook and expire after some days. Download the files if you need to keep them.

### Is scraping the Ad Library legal?

This Actor reads the public Ad Library without logging in. Ads can still contain personal data, such as names in ad text or on Pages, which laws like the GDPR protect. Only process it if you have a legitimate reason, and ask your lawyers if you're unsure.

# Actor input Schema

## `urls` (type: `array`):

Facebook Ad Library search URLs or Page URLs to scrape ads from.

## `scrapeAdDetails` (type: `boolean`):

Adds the advertiser, EU reach and transparency fields to each ad. Needs one extra request per ad, so runs are slower. Same price per ad.

## `limitPerSource` (type: `integer`):

Stop a URL once this many ads were scraped. The actual number may exceed the limit by up to 30, because the page that reaches it is kept. Leave blank for all ads.

## `count` (type: `integer`):

Stop the run at exactly this many ads. Leave blank for no limit.

## `scrapePageAds.period` (type: `string`):

Search ads in the given date range.

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

Active, inactive or all ads.

## `scrapePageAds.sortBy` (type: `string`):

Sort by impressions or date.

## `scrapePageAds.countryCode` (type: `string`):

2-letter uppercase ISO country code, such as `IN` or `US`. Use `ALL` for all countries.

## `runTag` (type: `string`):

Added to the 'runTag' column of each ad.

## `proxy` (type: `object`):

Optional. By default the Actor uses datacenter proxies, with residential as a fallback.

## Actor input object example

```json
{
  "urls": [
    {
      "url": "https://www.facebook.com/ads/library/?active_status=all&ad_type=all&country=IN&q=linkedin&search_type=keyword_unordered&media_type=all"
    },
    {
      "url": "https://www.facebook.com/ZapierApp"
    }
  ],
  "count": 100,
  "scrapePageAds.period": "",
  "scrapePageAds.activeStatus": "all",
  "scrapePageAds.sortBy": "impressions_desc",
  "scrapePageAds.countryCode": "ALL"
}
```

# 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 = {
    "urls": [
        {
            "url": "https://www.facebook.com/ads/library/?active_status=all&ad_type=all&country=IN&q=linkedin&search_type=keyword_unordered&media_type=all"
        },
        {
            "url": "https://www.facebook.com/ZapierApp"
        }
    ],
    "count": 100,
    "scrapePageAds.period": "",
    "scrapePageAds.activeStatus": "all",
    "scrapePageAds.sortBy": "impressions_desc",
    "scrapePageAds.countryCode": "ALL"
};

// Run the Actor and wait for it to finish
const run = await client.actor("istmobot/facebook-ads-library-cheap").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 = {
    "urls": [
        { "url": "https://www.facebook.com/ads/library/?active_status=all&ad_type=all&country=IN&q=linkedin&search_type=keyword_unordered&media_type=all" },
        { "url": "https://www.facebook.com/ZapierApp" },
    ],
    "count": 100,
    "scrapePageAds.period": "",
    "scrapePageAds.activeStatus": "all",
    "scrapePageAds.sortBy": "impressions_desc",
    "scrapePageAds.countryCode": "ALL",
}

# Run the Actor and wait for it to finish
run = client.actor("istmobot/facebook-ads-library-cheap").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 '{
  "urls": [
    {
      "url": "https://www.facebook.com/ads/library/?active_status=all&ad_type=all&country=IN&q=linkedin&search_type=keyword_unordered&media_type=all"
    },
    {
      "url": "https://www.facebook.com/ZapierApp"
    }
  ],
  "count": 100,
  "scrapePageAds.period": "",
  "scrapePageAds.activeStatus": "all",
  "scrapePageAds.sortBy": "impressions_desc",
  "scrapePageAds.countryCode": "ALL"
}' |
apify call istmobot/facebook-ads-library-cheap --silent --output-dataset

```

## MCP server setup

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

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/swFHKjSR0VSHaSyeZ/builds/gUPbQTDGwd5hRkhKT/openapi.json
