# 📢 Facebook Ads Library Scraper \[From 💰$0.45/1K] (`misterkhan/facebook-ads-library-scraper`) Actor

\[From $0.45/1K] Extract active & inactive ads from the Meta / Facebook Ad Library by keyword, advertiser Page ID, or Ad Library URL — HD video MP4s, images, carousel cards, unwrapped landing pages, UTMs & days running.

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

## Pricing

from $0.45 / 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

## 📢 Facebook Ads Library Scraper \[From 💰$0.45/1K]

**Extract active and inactive ads from the Meta / Facebook Ad Library (`facebook.com/ads/library`) by search keyword, competitor brand, advertiser Facebook Page ID, or direct Ad Library URL — including HD & SD video MP4 links, high-resolution images, carousel/DCO cards, clean unwrapped destination URLs, UTM parameters, days running, and EU/DSA transparency reach data. Zero Facebook login, cookies, or proxy configuration required.**

Built for **performance marketers, D2C e-commerce brands, creative strategists, media buyers, B2B lead generation teams, and ad spy intelligence platforms** who need fast, structured creative and funnel data from Facebook, Instagram, Messenger, Audience Network, and Threads ads.

***

### ✨ Key Features

| Feature | Why It Matters |
| :--- | :--- |
| **🔍 Multi-Mode Input (Keywords, Page IDs, or URLs)** | Search by product keywords (`"creatine gummies"`, `"medspa"`), advertiser Facebook Page IDs (`view_all_page_id`), Facebook Page URLs, or full Ad Library search URLs. |
| **🎬 Direct HD & SD Video MP4s + Carousel Cards** | Extracts direct `videoHdUrl`, `videoSdUrl`, preview thumbnails, high-resolution `imageUrls`, and every individual card inside `CAROUSEL` and `DCO` (Dynamic Creative) ads. |
| **🔗 Clean Unwrapped Destination URLs & UTMs** | Automatically unwraps `l.facebook.com/l.php?u=...` redirect links, strips `fbclid` tracking noise, extracts `landingPageDomain`, parses `utmParameters`, and classifies `funnelType` (`shopify_ecommerce`, `click_to_whatsapp`, `lead_gen_form`, `calendly_booking`, `custom_lander`). |
| **🏆 Winning Ad Longevity Filter (`minDaysRunning`)** | Computes exact `daysRunning`, `collationCount` (number of active duplicate variations), and `isScalingWinner` so you can filter strictly for proven, profitable ads running 14+, 30+, or 60+ days. |
| **🇪🇺 EU/UK DSA Transparency & Political Spend Data** | Captures `euTotalReach`, `impressionsText`, `spend`, `currency`, and `byline` disclaimers whenever disclosed by Meta Ad Library. |
| **🛡️ Zero Login & Built-In Anti-Blocking** | Works 100% without Facebook cookies or accounts. Automatic residential proxy rotation and challenge handling are included out of the box. |
| **📧 Landing Page Contacts Enrichment (Optional)** | Toggle `scrapeContacts` to crawl each unique ad landing-page domain for emails, phones, and social profiles. Charged once per unique domain on success (`website-contacts` PPE event). |
| **🧩 Landing Page Tech Stack Scan (Optional)** | Toggle `scrapeTechStack` to detect CMS, analytics, pixels, and frameworks on each unique landing domain. Charged once per unique domain on success (`tech-stack` PPE event). |
| **📊 Ready for Automation & AI Workflows** | Export directly to **JSON, CSV, Excel, Google Sheets, Make, n8n, Clay, or Zapier**, or pipe ad copy and video URLs straight into multimodal AI creative analysis pipelines. |

***

### 🧭 How to Use (Step-by-Step Console Guide)

1. **Open the Actor in Apify Console:** Click **Try for free** to open the visual input configuration form.
2. **Choose Your Target Ads:**
   - Paste one or more Facebook Ad Library URLs into **Facebook Ad Library URLs** (`startUrls`), **or**
   - Enter keywords/competitor brands in **Search Keywords** (`searchQueries`), **or**
   - Enter numeric advertiser Page IDs in **Advertiser Facebook Page IDs** (`pageIds`).
3. **Configure Filters (Optional):** Select your target **Country** (`US`, `GB`, `DE`, `ALL`, etc.), **Ad Delivery Status** (`active`, `inactive`, `all`), **Creative Media Format** (`all`, `video`, `image`), and **Winning Ad Filter — Minimum Days Active** (`minDaysRunning`).
4. **Set Your Extraction Limit:** Enter the maximum number of ads to extract in **Max Ads to Extract** (`maxItems`).
5. **Optional Enrichment:** Enable **Landing Page Contacts Enrichment** (`scrapeContacts`) and/or **Landing Page Tech Stack Scan** (`scrapeTechStack`) to enrich each unique website landing domain. Meta/WhatsApp destinations are skipped automatically.
6. **Run & Export:** Click **Start**, watch real-time ad extraction in the log and **Output** table, and download your dataset in **CSV, Excel, or JSON**.

***

### ⚙️ Input Parameters & Sample Input JSON

| Parameter | Type | Default | Description |
| :--- | :--- | :--- | :--- |
| `startUrls` | `array` | Sample Shopify search URL | One or more Facebook Ad Library search URLs or Facebook Page URLs. |
| `searchQueries` | `array` | `[]` | Keywords, niches, or brand names to search in the Meta Ad Library (e.g., `["shopify", "creatine gummies"]`). |
| `pageIds` | `array` | `[]` | Numeric Facebook Page IDs (`view_all_page_id`) to extract all ads from specific advertisers. |
| `country` | `string` | `"US"` | Two-letter ISO country code (`US`, `GB`, `CA`, `AU`, `DE`, `FR`, `AE`, `BR`, etc.) or `"ALL"`. |
| `activeStatus` | `string` | `"active"` | Filter by delivery state: `"active"`, `"inactive"`, or `"all"`. |
| `mediaType` | `string` | `"all"` | Filter by creative media type: `"all"`, `"video"`, `"image"`, `"meme"`, or `"none"`. |
| `platforms` | `array` | `[]` | Optional publisher platform filter (`["FACEBOOK", "INSTAGRAM", "MESSENGER", "AUDIENCE_NETWORK", "THREADS"]`). |
| `minDaysRunning` | `integer` | `0` | Minimum days an ad must have been active to be included in the output (e.g., `14` or `30` for winning ads). |
| `startDateMin` | `string` | `""` | Optional lower launch date bound (`YYYY-MM-DD`). |
| `startDateMax` | `string` | `""` | Optional upper launch date bound (`YYYY-MM-DD`). |
| `maxItems` | `integer` | `40` | Maximum number of ads to extract. Free plan runs are capped at 40 items per run; paid Apify plans support unlimited extraction. |
| `scrapeContacts` | `boolean` | `false` | Crawl each unique website landing-page domain for emails, phones, and social profiles. Bills `website-contacts` once per domain on success. |
| `scrapeTechStack` | `boolean` | `false` | Detect CMS, analytics, pixels, and frameworks on each unique website landing domain. Bills `tech-stack` once per domain on success. |

#### Example 1: Keyword & Winning Ad Spy Search

```json
{
  "searchQueries": ["shopify", " supplement gummies"],
  "country": "US",
  "activeStatus": "active",
  "mediaType": "all",
  "minDaysRunning": 14,
  "maxItems": 100
}
```

#### Example 2: Direct Facebook Ad Library Search URL or Page ID

```json
{
  "startUrls": [
    {
      "url": "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=US&q=shopify&search_type=keyword_unordered&media_type=all"
    }
  ],
  "pageIds": ["359717073888008"],
  "maxItems": 40
}
```

#### Example 3: Ads + Landing Page Contacts & Tech Stack

```json
{
  "searchQueries": ["shopify"],
  "country": "US",
  "activeStatus": "active",
  "minDaysRunning": 14,
  "maxItems": 40,
  "scrapeContacts": true,
  "scrapeTechStack": true
}
```

***

### 📦 Output Schema & Sample Output JSON

Each extracted ad is saved as a structured JSON object in your Apify Dataset:

```json
{
  "id": "1576835113754964",
  "adArchiveId": "1576835113754964",
  "adLibraryUrl": "https://www.facebook.com/ads/library/?id=1576835113754964",
  "collationId": "1626456112064707",
  "collationCount": 2,
  "isActive": true,
  "daysRunning": 338,
  "isScalingWinner": true,
  "startDateIso": "2025-11-12T08:00:00Z",
  "endDateIso": "2026-10-16T07:00:00Z",
  "pageId": "359717073888008",
  "pageName": "WhatChimp",
  "pageProfileUrl": "https://www.facebook.com/whatchimp/",
  "pageProfilePictureUrl": "https://scontent.xx.fbcdn.net/v/t39.35426-6/sample_profile.jpg",
  "pageCategories": ["Business"],
  "pageLikeCount": 13991,
  "displayFormat": "DCO",
  "publisherPlatforms": ["facebook", "instagram", "threads"],
  "title": "0% Markup Fees on API",
  "bodyText": "Send personalized bulk broadcasts on WhatsApp using the official WhatsApp Business API.",
  "caption": "whatchimp.com",
  "linkDescription": "Get 50% OFF Early-Bird Offer",
  "ctaText": "Sign up",
  "ctaType": "SIGN_UP",
  "landingPageUrl": "https://whatchimp.com/special-offer/",
  "landingPageDomain": "whatchimp.com",
  "funnelType": "custom_lander",
  "utmParameters": {},
  "imageUrls": [
    "https://scontent.xx.fbcdn.net/v/t39.35426-6/580616304_n.jpg?oe=6AD85831"
  ],
  "videos": [
    {
      "videoHdUrl": "https://video.xx.fbcdn.net/v/t42/sample_hd.mp4?oe=6AD85831",
      "videoSdUrl": "https://video.xx.fbcdn.net/v/t42/sample_sd.mp4?oe=6AD85831",
      "videoPreviewImageUrl": "https://scontent.xx.fbcdn.net/v/t39.35426-6/thumb.jpg?oe=6AD85831"
    }
  ],
  "carouselCards": [
    {
      "title": "0% Markup Fees on API",
      "body": "Send personalized bulk broadcasts on WhatsApp.",
      "linkDescription": "Get 50% OFF Early-Bird Offer",
      "ctaText": "Sign Up",
      "ctaType": "SIGN_UP",
      "linkUrl": "https://whatchimp.com/special-offer/",
      "imageUrl": "https://scontent.xx.fbcdn.net/v/t39.35426-6/580616304_n.jpg?oe=6AD85831",
      "videoHdUrl": null,
      "videoSdUrl": null
    }
  ],
  "mediaExpiresAtIso": "2026-10-21T06:14:09Z",
  "euTotalReach": null,
  "impressionsText": null,
  "spend": null,
  "currency": null,
  "byline": null,
  "totalSearchResultsCount": 11897,
  "searchCountry": "US",
  "searchQuery": "shopify",
  "scrapedAt": "2026-10-16T18:14:42Z"
}
```

***

### 💰 Transparent Pay-Per-Event (PPE) Pricing

**`$0.00` Actor start fee — you only pay for results successfully delivered to your dataset.**

All residential proxy bandwidth, anti-bot challenge solving, and multi-slice pagination are included in the per-result event price. Running inside a lightweight **`128 MB`** native Rust container keeps your Apify platform Compute Unit (CU) usage near `$0.0001` per run.

| Apify Plan Tier | Price per Ad (`apify-default-dataset-item`) | Price per 1,000 Ads | Per-Run Quota Cap |
| :--- | :--- | :--- | :--- |
| **Free Plan** | `$0.005` | **`$5.00 / 1K`** | Up to `40` ads / run |
| **Starter (`Bronze`)** | `$0.0011` | **`$1.10 / 1K`** | Unlimited (respects `maxItems` & budget) |
| **Scale (`Silver`)** | `$0.00075` | **`$0.75 / 1K`** | Unlimited (respects `maxItems` & budget) |
| **Business+ (`Gold` / `Platinum` / `Diamond`)** | `$0.00045` | **`$0.45 / 1K`** | Unlimited (respects `maxItems` & budget) |

#### Optional: Landing Page Contacts (`website-contacts`)

Charged **once per unique landing-page domain** when contacts enrichment succeeds (not per ad). Meta / WhatsApp destinations are skipped.

| Apify Plan Tier | Price per Domain | Price per 1,000 Domains |
| :--- | :--- | :--- |
| **Free Plan** | `$0.005` | **`$5.00 / 1K`** |
| **Starter (`Bronze`)** | `$0.0014` | **`$1.40 / 1K`** |
| **Scale (`Silver`)** | `$0.00095` | **`$0.95 / 1K`** |
| **Business+ (`Gold` / `Platinum` / `Diamond`)** | `$0.0006` | **`$0.60 / 1K`** |

#### Optional: Landing Page Tech Stack (`tech-stack`)

Charged **once per unique landing-page domain** when the tech stack scan succeeds (not per ad).

| Apify Plan Tier | Price per Domain | Price per 1,000 Domains |
| :--- | :--- | :--- |
| **Free Plan** | `$0.01` | **`$10.00 / 1K`** |
| **Starter (`Bronze`)** | `$0.002` | **`$2.00 / 1K`** |
| **Scale (`Silver`)** | `$0.0015` | **`$1.50 / 1K`** |
| **Business+ (`Gold` / `Platinum` / `Diamond`)** | `$0.0012` | **`$1.20 / 1K`** |

***

### 🔌 API Integration Examples (`Python`, `Node.js`, `cURL`)

#### Python (`apify-client`)

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_API_TOKEN")

run_input = {
    "searchQueries": ["shopify"],
    "country": "US",
    "activeStatus": "active",
    "minDaysRunning": 14,
    "maxItems": 40,
    # Optional Phase 1 enrichment (billed once per unique landing domain):
    # "scrapeContacts": True,
    # "scrapeTechStack": True,
}

run = client.actor("misterkhan/facebook-ads-library-scraper").call(run_input=run_input)

for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(f"{item.get('pageName')} ({item.get('daysRunning')}d) -> {item.get('landingPageUrl')}")
```

#### Node.js (`apify-client`)

```javascript
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: 'YOUR_APIFY_API_TOKEN' });

const run = await client.actor('misterkhan/facebook-ads-library-scraper').call({
    searchQueries: ['shopify'],
    country: 'US',
    activeStatus: 'active',
    maxItems: 40,
});

const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(`Extracted ${items.length} Facebook ads:`, items[0]);
```

#### cURL

```bash
curl -X POST "https://api.apify.com/v2/acts/misterkhan~facebook-ads-library-scraper/runs?token=YOUR_APIFY_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "searchQueries": ["shopify"],
    "country": "US",
    "activeStatus": "active",
    "maxItems": 40
  }'
```

***

### ❓ Frequently Asked Questions (FAQ)

#### Do I need to provide Facebook cookies, login credentials, or proxies?

**No.** This Actor works 100% without a Facebook account or cookies, and residential proxy rotation is handled automatically at no extra cost.

#### How can I find only profitable "winning" ads?

Set `minDaysRunning` to `14` or `30` (and `activeStatus` to `"active"`). Ads that advertisers keep paying to run for 14–30+ consecutive days or across multiple collated variations (`isScalingWinner: true`) are strong indicators of positive ROAS creatives.

#### Why do Facebook CDN image and video URLs include a `mediaExpiresAtIso` field?

Meta signs `fbcdn.net` image and video URLs with a hex expiration parameter (`oe=`). The scraper automatically decodes this hex timestamp into `mediaExpiresAtIso` so your downstream automation knows the exact UTC date/time before which media files should be downloaded if permanent archiving is required.

#### Is scraping the Facebook Ad Library legal?

The Meta Ad Library is a public transparency database published for public inspection. This Actor extracts only publicly visible ad records and does not collect private personal data. For general context on web scraping compliance, read [Apify's guide on the legality of web scraping](https://blog.apify.com/is-web-scraping-legal/).

***

### 🔗 Related Actors from Our Store

Combine this Actor with our other **`128 MB` Pay-Per-Event (PPE)** tools in the same workflow (`$0.00` start fee):

| Related Actor | Best For | Starting Price |
| :--- | :--- | :--- |
| **[📍 Google Maps Places Scraper](https://apify.com/misterkhan/google-maps-scraper)** | Local business leads, phones, websites, ratings & coordinates | **From 💰`$0.55 / 1K`** |
| **[📧 Website Contact & Email Scraper](https://apify.com/misterkhan/contact-enricher-scraper)** | Extract business emails, phone numbers & social links from any website domain | **From 💰`$0.60 / 1K`** |
| **[🧩 Website Tech Stack Scanner](https://apify.com/misterkhan/website-tech-stack-scanner)** | Detect 7,000+ technologies, CMS, analytics, ad pixels & e-commerce platforms | **From 💰`$0.50 / 1K`** |
| **[📄 Website to Clean Text & Markdown](https://apify.com/misterkhan/ai-markdown-crawler)** | Convert any web page into clean Markdown for LLMs, RAG pipelines & AI agents | **From 💰`$0.50 / 1K`** |
| **[📸 Instagram Profile Status Checker](https://apify.com/misterkhan/instagram-profile-status-checker)** | Bulk check Instagram handles for active vs. banned status, followers & bio links | **From 💰`$0.35 / 1K`** |

👉 **[See all Actors by `misterkhan` on Apify Store →](https://apify.com/misterkhan)**

***

### 💬 Support & 🧑‍⚖️ Legal Disclaimer

- **Support & Feature Requests:** Have a question, custom workflow need, or issue? Open a ticket in the **Issues** tab on this Actor's Apify Store page and we will respond promptly.
- **Disclaimer:** This Actor is an independent data extraction tool and is not affiliated with, endorsed by, or sponsored by Meta Platforms, Inc. or Facebook.

# Actor input Schema

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

Paste one or more Facebook Ad Library search URLs (e.g., https://www.facebook.com/ads/library/?active_status=active\&ad_type=all\&country=US\&q=shopify) or Facebook Page URLs.

## `searchQueries` (type: `array`):

Enter keywords, product niches, or brand names to search directly in the Meta Ad Library (e.g., \["medspa", "creatine gummies", "gymshark"]). Works alongside or instead of startUrls.

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

Enter numeric Facebook Page IDs (`view_all_page_id`) to extract all ads run by specific advertisers (e.g., \["359717073888008"]).

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

Two-letter ISO country code for the Ad Library search (e.g., US, GB, CA, AU, DE, FR, AE, IN, BR, or ALL).

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

Filter by active delivery status: 'active' (currently running ads), 'inactive' (paused/ended ads), or 'all' (both active and inactive).

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

Filter ads by creative format: all formats, video ads only, image ads only, or meme/text ads.

## `platforms` (type: `array`):

Filter by Meta publisher placement (e.g., \["FACEBOOK", "INSTAGRAM", "MESSENGER", "AUDIENCE_NETWORK", "THREADS"]). Leave empty for all placements.

## `minDaysRunning` (type: `integer`):

Only output ads that have been running continuously for at least this many days (e.g., set to 14 or 30 to isolate proven, profitable evergreen ads). Set to 0 to include all ads.

## `startDateMin` (type: `string`):

Filter ads launched on or after this date (format: YYYY-MM-DD).

## `startDateMax` (type: `string`):

Filter ads launched on or before this date (format: YYYY-MM-DD).

## `maxItems` (type: `integer`):

Maximum number of unique ads to extract across your search targets. Free plan runs are capped at 40 items per run; paid Apify plans support unlimited extraction.

## `scrapeContacts` (type: `boolean`):

When an ad has a website landing page, crawl that domain for emails, phones, and social profile links. Deduped per unique domain across ads. Bills `website-contacts` only on success (once per domain). Off by default.

## `scrapeTechStack` (type: `boolean`):

When an ad has a website landing page, detect CMS, analytics, pixels, and frameworks. Deduped per unique domain. Bills `tech-stack` only on success (once per domain). Off by default.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=US&q=shopify&search_type=keyword_unordered&media_type=all"
    }
  ],
  "country": "US",
  "activeStatus": "active",
  "mediaType": "all",
  "minDaysRunning": 0,
  "maxItems": 40,
  "scrapeContacts": false,
  "scrapeTechStack": false
}
```

# Actor output Schema

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

Structured table of extracted Facebook & Instagram ads with advertiser, days active, creative format, and destination URL.

## `dataset_items` (type: `string`):

Complete dataset including HD video MP4 URLs, high-res images, carousel cards, UTM parameters, and page metadata.

## `usage_summary` (type: `string`):

Execution telemetry and extraction summary stored in the default key-value store.

# 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&q=shopify&search_type=keyword_unordered&media_type=all"
        }
    ],
    "country": "US",
    "activeStatus": "active",
    "mediaType": "all",
    "minDaysRunning": 0,
    "maxItems": 40,
    "scrapeContacts": false,
    "scrapeTechStack": false
};

// Run the Actor and wait for it to finish
const run = await client.actor("misterkhan/facebook-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 = {
    "startUrls": [{ "url": "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=US&q=shopify&search_type=keyword_unordered&media_type=all" }],
    "country": "US",
    "activeStatus": "active",
    "mediaType": "all",
    "minDaysRunning": 0,
    "maxItems": 40,
    "scrapeContacts": False,
    "scrapeTechStack": False,
}

# Run the Actor and wait for it to finish
run = client.actor("misterkhan/facebook-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 '{
  "startUrls": [
    {
      "url": "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=US&q=shopify&search_type=keyword_unordered&media_type=all"
    }
  ],
  "country": "US",
  "activeStatus": "active",
  "mediaType": "all",
  "minDaysRunning": 0,
  "maxItems": 40,
  "scrapeContacts": false,
  "scrapeTechStack": false
}' |
apify call misterkhan/facebook-ads-library-scraper --silent --output-dataset

```

## MCP server setup

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