# Facebook Ads Library Scraper (`krazee_kaushik/facebook-ads-library-scraper`) Actor

Scrape Facebook Ads Library using Ads Library search URLs. Automatically splits long date ranges into monthly requests for complete data collection. Extract creatives, media, delivery, and optional reach/spend data. 200+ ads/min. Export to Excel, CSV, JSON & more. Starting from $0.6/1000 Ads.

- **URL**: https://apify.com/krazee\_kaushik/facebook-ads-library-scraper.md
- **Developed by:** [Krazee](https://apify.com/krazee_kaushik) (community)
- **Categories:** AI, Developer tools, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.60 / 1,000 facebook ad scrapeds

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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use 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 is Facebook Ads Library Scraper?

Facebook Ads Library Scraper extracts publicly available ads from Facebook Ads Library using search URLs generated from [Facebook Ads Library](https://www.facebook.com/ads/library). Collect structured advertising data for keyword or advertiser searches with configurable scraping options and optional ad detail extraction.

For large historical searches, the actor automatically partitions date ranges into monthly requests to improve data coverage and collect more complete historical datasets—all handled transparently in a single run.

It's designed for marketers, researchers, agencies, journalists, compliance teams, and anyone looking to analyze or monitor advertising activity at scale.

Simply configure your search on Facebook Ads Library with the filters you need, paste the generated search URL, click **Save & Start**, and start collecting structured advertising datasets.

---

### ⭐ Why Use This Actor?

- 📅 **Smart Date Range Partitioning:** Automatically partitions long date ranges into monthly requests, helping collect more complete historical datasets.

- 📋 **Optional Extra Ad Details:** Enrich your datasets with additional ad details such as estimated reach, spend, demographic distribution, and other publicly available metadata when available.

- ⚡ **Fast API-Based Extraction:** Collect Facebook Ads Library data through direct API requests instead of browser automation, making scraping faster, more reliable, and resource-efficient.

- 🛡️ **Reliable Session Management:** Built-in session handling, retries, and recovery mechanisms help keep long-running scraping jobs stable and resilient.

- 🔄 **Apify Resurrect Run Support:** Long-running scraping jobs can automatically resume from the last saved progress after an interruption instead of starting over.

- 💰 **Affordable Pricing:** Scrape Facebook Ads Library data for just **$0.60 per 1,000 ads**, making it a cost-effective solution for both small and large-scale data collection.

---

### 📊 What Data Can You Extract?

The actor returns one dataset item per ad.

#### Basic Ad Data

| Category | Included Data |
|---|---|
| 📢 Ad Information | Ad Archive ID, ad status, delivery dates, display format, ad title, ad text, caption, CTA text, CTA type, disclaimers, and reshared content information |
| 🏢 Advertiser Information | Page ID, page name, profile URL, profile picture, page categories, page likes, and page status |
| 🖼️ Creative Assets | Images, videos, carousel cards, thumbnails, media URLs, extra images, extra videos, and creative metadata |
| 🔗 Landing Pages & Links | Landing page URLs, captions, bylines, link descriptions, destination URLs, and additional links |
| 🌍 Delivery Information | Publisher platforms, targeted countries, regional regulation data, content flags, and other delivery metadata |

#### ⭐ Ad Details (Optional)

Enable **Include Ad Details** to enrich each ad with the following additional information when available.

| Category | Included Data |
|---|---|
| 👤 Advertiser Profile | Advertiser About, Instagram username, followers, verification, page alias, category, cover photo, profile photo, page verification, and profile type |
| 📊 Transparency & Audience | Reach insights, audience demographics, transparency by location, age, gender, country breakdowns, and regional transparency information |
| ⚖️ Compliance & Page Insights | Page spend, political advertiser indicators, restriction status, verified voice context, violation types, AI disclosure eligibility, and other compliance metadata |


### 🚀 How to Scrape Facebook Ads Library

#### Scrape Ads from an Advertiser

The simplest way to scrape ads from a Facebook page is to copy the advertiser's Ads Library URL and provide it as input.

```json
{
  "urls": [
    "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=IN&is_targeted_country=false&media_type=all&search_type=page&sort_data[direction]=desc&sort_data[mode]=total_impressions&view_all_page_id=15087023444"
  ]
}
````

#### Scrape Ads with Additional Details

Enable Include Extra Ad Details to enrich each ad with additional advertiser information, reach, spend, and transparency data when available. Since this performs one additional request per ad, runs may take slightly longer to complete.

```json
{
  "resultsPerUrl": 100,
  "includeAdDetails": true,
  "urls": [
    "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=IN&is_targeted_country=false&media_type=all&search_type=page&sort_data[direction]=desc&sort_data[mode]=total_impressions&view_all_page_id=15087023444"
  ]
}
```

#### Scrape Ads Within a Date Range

Apply filters and sorting either while generating the Ads Library URL or later using the actor's input options.

```json
{
  "impressionsFrom": "2025-01-01",
  "impressionsTo": "2025-06-30",
  "urls": [
    "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=IN&is_targeted_country=false&media_type=all&search_type=page&sort_data[direction]=desc&sort_data[mode]=total_impressions&view_all_page_id=15087023444"
  ]
}
```

***

### 📥 Sample Output

#### Basic Output

```json
 {
    "ad_archive_id": "1565227778300572",
    "ad_id": null,
    "collation_id": null,
    "collation_count": null,
    "is_active": true,
    "start_date": 1780642800,
    "end_date": 1782716400,
    "page_id": "15087023444",
    "page_name": "Nike",
    "page_profile_uri": "https://facebook.com/nike",
    "page_profile_picture_url": "https://scontent-lax3-1.xx.fbcdn.net/v/t39.35426-6/714759574_978804974955243_8724360225588544713_n.jpg?stp=dst-jpg_s60x60_tt6&_nc_cat=110&ccb=1-7&_nc_sid=c53f8f&_nc_ohc=pqvbGWkpGtgQ7kNvwHKdevF&_nc_oc=AdofmwD-IPk5QFvEfzWdSY6ybB7zZzayohGIovFaK928wtGJPqggz6txEFhfK2DKeaU&_nc_zt=14&_nc_ht=scontent-lax3-1.xx&_nc_gid=OpbV7PdDiOM8f0ubH0gaFQ&_nc_ss=79180&oh=00_AQDnMfwOcqQ14LnURL7oNRSO8DyzaKZ5huP3LACxkftWeg&oe=6A49568D",
    "page_categories": [
      "Sportswear"
    ],
    "page_like_count": 39602147,
    "page_is_deleted": false,
    "title": "{{product.name}}",
    "ad_text": "Free delivery, easy returns and the widest range of Nike® innovation.",
    "caption": "nike.in",
    "cta_text": "Shop now",
    "cta_type": "SHOP_NOW",
    "cards": [
      {
        "body": "Free delivery, easy returns and the widest range of Nike® innovation.",
        "cta_type": "SHOP_NOW",
        "caption": "nike.in",
        "link_description": "Nike - Official Online Store for Athletic Shoes, Clothing & Sports Gear. Shop the latest Nike products and enjoy free shipping.",
        "link_url": "https://www.nike.in/nike-as-u-nsw-tee-lse-prem-ess-wash/p/24928094",
        "title": "AS U NSW TEE LSE PREM ESS WASH",
        "cta_text": "Shop Now",
        "video_hd_url": null,
        "video_preview_image_url": null,
        "video_sd_url": null,
        "watermarked_video_hd_url": null,
        "watermarked_video_sd_url": null,
        "image_crops": [],
        "original_image_url": "https://scontent-lax3-2.xx.fbcdn.net/v/t39.35426-6/716922492_1023869790177871_6994111317368725597_n.jpg?_nc_cat=100&ccb=1-7&_nc_sid=c53f8f&_nc_ohc=wTkyDJa471sQ7kNvwFyhK38&_nc_oc=Adpb67ItXgppE5wSendjVTMGnIGGS_qBKqUvjNqANDexVyjy4EIa3K2JwdpYWo0Hpms&_nc_zt=14&_nc_ht=scontent-lax3-2.xx&_nc_gid=OpbV7PdDiOM8f0ubH0gaFQ&_nc_ss=79180&oh=00_AQBiIgNqT19YL-vDFPu-k9gg3PTInmSA87CXnHoTVFq62w&oe=6A494790",
        "resized_image_url": "https://scontent-lax3-2.xx.fbcdn.net/v/t39.35426-6/716922492_1023869790177871_6994111317368725597_n.jpg?stp=dst-jpg_s600x600_tt6&_nc_cat=100&ccb=1-7&_nc_sid=c53f8f&_nc_ohc=wTkyDJa471sQ7kNvwFyhK38&_nc_oc=Adpb67ItXgppE5wSendjVTMGnIGGS_qBKqUvjNqANDexVyjy4EIa3K2JwdpYWo0Hpms&_nc_zt=14&_nc_ht=scontent-lax3-2.xx&_nc_gid=OpbV7PdDiOM8f0ubH0gaFQ&_nc_ss=79180&oh=00_AQCfBN4NdW96F6Pqzh3-wuwQA0EGONO1xEzKD7ipQWXMyw&oe=6A494790",
        "watermarked_resized_image_url": ""
      }
    
    ],
    "extra_links": [],
    "extra_texts": [],
    "extra_images": [],
    "extra_videos": [],
    "disclaimer_label": null,
    "country_iso_code": null,
    "byline": null,
    "root_reshared_post": null,
    "is_reshared": false,
    "display_format": "DPA",
    "link_url": "http://www.nike.in/",
    "link_description": null,
    "images": [],
    "videos": [],
    "publisher_platform": [
      "FACEBOOK",
      "INSTAGRAM",
      "THREADS"
    ],
    "targeted_or_reached_countries": [],
    "reach_estimate": null,
    "currency": "",
    "spend": null,
    "contains_sensitive_content": false,
    "gated_type": "ELIGIBLE",
    "contains_digital_created_media": false,
    "hide_data_status": "NONE",
    "regional_regulation_data": {
      "finserv": {
        "is_deemed_finserv": false,
        "is_limited_delivery": false
      },
      "tw_anti_scam": {
        "is_limited_delivery": false
      }
    }
   
  }
```

#### Output with Ad Details

```json
 {
    "ad_archive_id": "2146111439489893",
    "ad_id": null,
    "collation_id": "1193720922378650",
    "collation_count": 8,
    "is_active": false,
    "start_date": 1774508400,
    "end_date": 1781161200,
    "page_id": "129669023798560",
    "page_name": "Gymshark",
    "page_profile_uri": "https://facebook.com/Gymshark",
    "page_profile_picture_url": "https://scontent-lga3-2.xx.fbcdn.net/v/t39.35426-6/656126655_2414253592350694_7696471576237674723_n.jpg?stp=dst-jpg_s60x60_tt6&_nc_cat=107&ccb=1-7&_nc_sid=c53f8f&_nc_ohc=qLErWZd4aNQQ7kNvwHWHky3&_nc_oc=AdqR6Kgv8d4UWtm7a7sI4_KGQI-jXKODnHEmlJo3xzskxLKaRAvp1f7WZq8tMDaDjhc&_nc_zt=14&_nc_ht=scontent-lga3-2.xx&_nc_gid=7UVx8OwJy7R97XEmsHg4xQ&_nc_ss=79180&oh=00_AQCk9jYFkEWy2f3ZIV3fALb5LieHGMapPibIJYZ6ZM-9RA&oe=6A49E125",
    "page_categories": [
      "Clothing (Brand)"
    ],
    "page_like_count": 2189525,
    "page_is_deleted": false,
    "title": null,
    "ad_text": "{{product.brand}}",
    "caption": "de.gymshark.com",
    "cta_text": "Shop now",
    "cta_type": "SHOP_NOW",
    "cards": [
      {
        "body": "Häng dich rein und mach 2026 zu deinem ✨besten✨ Jahr 🔥\n\nSpare mit dem Code WELCOME10 10 % extra auf deine erste Bestellung.",
        "cta_type": "SHOP_NOW",
        "caption": "",
        "link_description": "Entdecke unsere Kollektion mit den Must-Haves für Damen jetzt und bringe deine Fitness Reise auf das nächste Level. Shoppe jetzt.",
        "link_url": "https://de.gymshark.com/collections/must-have/womens",
        "title": "Gymshark. We Do Gym.",
        "cta_text": "Shop Now",
        "video_hd_url": null,
        "video_preview_image_url": null,
        "video_sd_url": null,
        "watermarked_video_hd_url": null,
        "watermarked_video_sd_url": null,
        "image_crops": [],
        "original_image_url": "https://scontent-lga3-3.xx.fbcdn.net/v/t39.35426-6/656389226_1372751888221065_6699105897432097880_n.jpg?_nc_cat=106&ccb=1-7&_nc_sid=c53f8f&_nc_ohc=Vx87ZmKYqtMQ7kNvwFHW0de&_nc_oc=AdoxMLwgnEmoKx25jrbh2QIjb6PEkiFU_k3_3pj757dF_PVjm4j8HRZb7kjPlyXVjg0&_nc_zt=14&_nc_ht=scontent-lga3-3.xx&_nc_gid=7UVx8OwJy7R97XEmsHg4xQ&_nc_ss=79180&oh=00_AQD6RFrNvlGli1qFpWRDaCp82ASfaQaYUyymWTjHhU9ixQ&oe=6A49C154",
        "resized_image_url": "https://scontent-lga3-3.xx.fbcdn.net/v/t39.35426-6/655722698_1457132209496623_5905703204039821190_n.jpg?stp=dst-jpg_s600x600_tt6&_nc_cat=102&ccb=1-7&_nc_sid=c53f8f&_nc_ohc=nYnEx0twLsYQ7kNvwGZxox2&_nc_oc=AdrFGED2gcgtiQ8jozy_XrHjUi8ZS2pkHBnEQRfUHbsizeZp-gsVBek4Tnyy6of0Kpg&_nc_zt=14&_nc_ht=scontent-lga3-3.xx&_nc_gid=7UVx8OwJy7R97XEmsHg4xQ&_nc_ss=79180&oh=00_AQAHXvSiDimMhwBPHpVFI4iPyNg7DNMLJhnsftsrwn2NDg&oe=6A49EB83",
        "watermarked_resized_image_url": ""
      }
    
    ],
    "extra_links": [],
    "extra_texts": [],
    "extra_images": [],
    "extra_videos": [],
    "disclaimer_label": null,
    "country_iso_code": null,
    "byline": null,
    "root_reshared_post": null,
    "is_reshared": false,
    "display_format": "DCO",
    "link_url": "https://de.gymshark.com/collections/must-have/womens",
    "link_description": null,
    "images": [],
    "videos": [],
    "publisher_platform": [
      "INSTAGRAM"
    ],
    "targeted_or_reached_countries": [],
    "reach_estimate": null,
    "currency": "",
    "spend": null,
    "contains_sensitive_content": false,
    "gated_type": "ELIGIBLE",
    "contains_digital_created_media": false,
    "hide_data_status": "NONE",
    "regional_regulation_data": {
      "finserv": {
        "is_deemed_finserv": false,
        "is_limited_delivery": false
      },
      "tw_anti_scam": {
        "is_limited_delivery": false
      }
    },
    "total_active_time": null,
    "impressions_with_index": {
      "impressions_text": null,
      "impressions_index": -1
    },
    "advertiser_about": "Contact us at www.support.gymshark.com for all your enquiries!",
    "is_delegate_page_with_linked_primary_profile": false,
    "is_political_page": false,
    "page_spend": {
      "current_week": null,
      "lifetime_by_disclaimer": [],
      "weekly_by_disclaimer": [],
      "is_political_page": false
    },
    "entity_type": "PERSON_PROFILE",
    "ig_username": "gymshark",
    "ig_followers": 8541026,
    "ig_verification": true,
    "page_alias": "Gymshark",
    "page_category": "Clothing (brand)",
    "page_cover_photo": "https://scontent-iad6-1.xx.fbcdn.net/v/t39.30808-6/486532481_1255553642852985_5814589256817883854_n.jpg?_nc_cat=106&ccb=1-7&_nc_sid=957871&_nc_ohc=X9vfvtA3GQAQ7kNvwGDN3I4&_nc_oc=AdqGKOIRmGB-cyQTvHmqHaoesGwEDt1r1DpdepV2fSlN1bbIItz9i0GZ7Z6UHUsv_84&_nc_zt=23&_nc_ht=scontent-iad6-1.xx&_nc_gid=qMEK7tHze9GvHkROy-301A&_nc_ss=79289&oh=00_AQAIaDvsyZVTcT0GbTiK9mpTjJH9LQyEl90vNocm6jPEaw&oe=6A49D0AD",
    "page_is_restricted": false,
    "page_verification": "BLUE_VERIFIED",
    "profile_photo": "https://scontent-iad3-1.xx.fbcdn.net/v/t39.30808-1/430887636_977245634017122_247869779462390570_n.jpg?stp=dst-jpg_s148x148_tt6&_nc_cat=1&ccb=1-7&_nc_sid=418b77&_nc_ohc=XjTA6Pj3c1sQ7kNvwEstzAC&_nc_oc=AdofamIOfYo3J1hpnuwwevpaw2XUf7AJVQ1mBSIM9QXeZn_7Ki_R6viCrQZ7Hiyb6Lc&_nc_zt=24&_nc_ht=scontent-iad3-1.xx&_nc_gid=qMEK7tHze9GvHkROy-301A&_nc_ss=79289&oh=00_AQDrEYOsNJyFob07pk6Ga9K8N1GuvbH7B35W-s0o5mX13Q&oe=6A49DD25",
    "is_profile_page": false,
    "violation_types": [],
    "verified_voice_context": null,
    "transparency_by_location": {
      "br_transparency": null,
      "eu_transparency": {
        "targets_eu": true,
        "location_audience": [
          {
            "name": "Germany",
            "num_obfuscated": 0,
            "type": "countries",
            "excluded": false
          }
        ],
        "gender_audience": "Women",
        "age_audience": {
          "min": 18,
          "max": 35
        },
        "eu_total_reach": 3578884,
        "age_country_gender_reach_breakdown": [
          {
            "country": "DE",
            "age_gender_breakdowns": [
              {
                "age_range": "18-24",
                "male": null,
                "female": 1431622,
                "unknown": null
              },
              {
                "age_range": "25-34",
                "male": null,
                "female": 2007707,
                "unknown": null
              },
              {
                "age_range": "35-44",
                "male": null,
                "female": 155816,
                "unknown": null
              },
              {
                "age_range": "Unknown",
                "male": null,
                "female": 556,
                "unknown": 2
              }
            ]
          }
        ]
      },
      "uk_transparency": null
    },
    "is_siep_advertiser_eligible_for_ai_disclosure": true,
    "is_violating_eu_siep": false
  }
```

***

### ⚙️ Input Options

| Input | Type | Description |
|---|---|---|
| `urls` | array | One or more Facebook Ads Library search URLs to scrape |
| `resultsPerUrl` | number | Maximum number of ads to collect from each search URL |
| `includeAdDetails` | boolean | Enrich each ad with additional advertiser, reach, spend, and transparency data. Requires one additional request per ad and may increase scraping time. |
| `sortBy` | string | Sort ads by **Impressions (High to Low)** or **Most Recent** |
| `activeStatus` | string | Scrape **Active Only** ads or include both active and inactive ads |
| `impressionsFrom` | date | Only include ads with impressions on or after the selected date |
| `impressionsTo` | date | Only include ads with impressions on or before the selected date |

***

### 📅 Smart Date Range Partitioning

Large historical searches processed through a single pagination chain may not always return the most complete dataset. To improve historical data coverage, the actor automatically partitions the selected date range into monthly requests, collects each period independently, and merges the results into a single, chronologically ordered dataset.

The date range can come from either the Facebook Ads Library search URL or the actor's **Advanced Filters**. If no date range is specified, the actor automatically searches the last **7 years**, partitioning the entire period into monthly requests until the configured **Results per URL** limit is reached.

This process is fully automatic—simply provide your search URL (and optionally a date range), and the actor handles the partitioning, pagination, and result aggregation for you.

***

### ⚡ Apify Resurrect Run Support

The actor supports Apify resurrect runs for interrupted or partially completed scraping jobs.

If a run crashes or stops unexpectedly, the resurrected run can continue from the same scraping position instead of starting from the beginning.

***

### 💰 How Much Does It Cost?

| Feature | Free Apify Users | Paid Apify Users |
|----------|----------|----------|
| Ad Scraping | $0.75 per 1,000 results | $0.6 per 1,000 results |
| Ad URLs Limit | Includes 2 Ads Search URLs for testing | Unlimited URLs |
| Ad Limit | 50 Ads per URL | Unlimited |

💡 Start with a small test run to verify the output structure and estimate usage before launching larger scraping jobs.

Free users can unlock comments scraping, unlimited profiles, and higher limits by upgrading their Apify subscription: https://apify.com/pricing

***

### ⚠️ Limitations & Troubleshooting

- **No ads returned**

  Verify that the Facebook Ads Library URL is valid and returns ads when opened in your browser. Searches with no matching ads will produce an empty dataset.

- **Fewer ads than expected**

  The actor follows the search criteria defined by your Ads Library URL and any additional filters configured in the actor input. Check that your country, date range, active status, and other filters are not overly restrictive.

- **Missing ad details**

  Additional advertiser, reach, spend, and transparency information is only available when **Include Ad Details** is enabled and Facebook provides those details for the specific ad.

- **Include Ad Details increases scraping time**

  When **Include Ad Details** is enabled, the actor performs one additional request for each scraped ad to retrieve Facebook's **See ad details** information. As a result, runs with this option enabled may take longer than standard scraping runs.

- **Monitoring progress**

  Open the actor run and check the **Logs** tab to monitor scraping progress, extracted ads, and any warnings generated during the run.

***

### ❓ Frequently Asked Questions

#### Can I scrape Facebook Ads Library without logging in?

Yes. The actor extracts publicly available ads from Facebook Ads Library without requiring a Facebook account, cookies, API keys, or manual authentication.

#### Can I scrape ads from a specific advertiser or Facebook page?

Yes. Simply copy the advertiser's Facebook Ads Library URL and provide it as input. The actor will scrape ads matching that search.

#### Can I scrape Facebook Ads by keyword?

Yes. Create a keyword search on Facebook Ads Library, copy the generated search URL, and use it as input. The actor supports both keyword and advertiser-based searches.

#### Can I scrape ads from multiple Facebook Ads Library URLs in one run?

Yes. Provide multiple Ads Library search URLs, and the actor will process each one during the same run.

#### Can I filter ads by date?

Yes. You can either apply date filters while creating the Ads Library search URL or use the actor's built-in impression date filters to further refine the results.

#### What additional information does Include Extra Ad Details provide?

When enabled, the actor performs one additional request per ad to retrieve Facebook's **See ad details** information, including advertiser details, reach, spend, transparency data, audience breakdowns, and other publicly available metadata when available.

#### Why is my scraping run taking longer than expected?

Large searches naturally require more requests. Enabling **Include Extra Ad Details** also performs one additional request for every scraped ad, which may increase the total run time.

#### Can I export the scraped data to CSV or Excel?

Yes. Data is stored in an Apify dataset and can be exported to CSV, Excel, JSON, XML, HTML, RSS, and other formats supported by Apify.

***

### 💬 Support

Check the troubleshooting section above before opening an issue.

For bug reports, scraping issues, or feature requests, please open an [issues](https://console.apify.com/organization/XjtvaC9MoQZuFl4Da/actors/hksZfp0xVIVMiWBE5/issues) on the actor page.

If you need custom scraper modifications, automation workflows, or additional extraction features, feel free to contact:

📧 kamakrazeekaushik@gmail.com

When reporting issues, please include the Actor Run ID or relevant run logs to help speed up debugging.

***

### 🔗 Related Actors

- 📘 [Facebook Posts & Comments Scraper](https://apify.com/krazee_kaushik/facebook-posts-and-comments-scraper) - Scrape Facebook posts from one or multiple public Facebook pages, including comments for every post. Configure comment limits and sorting options without using a separate comments scraper.

# Actor input Schema

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

Enter one or more Facebook Ads Library search URLs.

## `resultsPerUrl` (type: `integer`):

Maximum number of ads to scrape from each Ads Library URL.

## `includeAdDetails` (type: `boolean`):

Fetch additional ad details such as reach, spend, and advertiser information when available. This requires an extra request per ad and may slightly increase scraping time.

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

Choose how ads should be ordered.

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

Filter ads by activity status.

## `impressionsFrom` (type: `string`):

Only include ads with impressions on or after this date.

## `impressionsTo` (type: `string`):

Only include ads with impressions on or before this date.

## Actor input object example

```json
{
  "urls": [
    "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=IN&is_targeted_country=false&media_type=all&search_type=page&sort_data[direction]=desc&sort_data[mode]=total_impressions&view_all_page_id=15087023444"
  ],
  "resultsPerUrl": 50,
  "includeAdDetails": false,
  "sortBy": "IMPRESSIONS",
  "activeStatus": "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": [
        "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=IN&is_targeted_country=false&media_type=all&search_type=page&sort_data[direction]=desc&sort_data[mode]=total_impressions&view_all_page_id=15087023444"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("krazee_kaushik/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 = { "urls": ["https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=IN&is_targeted_country=false&media_type=all&search_type=page&sort_data[direction]=desc&sort_data[mode]=total_impressions&view_all_page_id=15087023444"] }

# Run the Actor and wait for it to finish
run = client.actor("krazee_kaushik/facebook-ads-library-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).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": [
    "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=IN&is_targeted_country=false&media_type=all&search_type=page&sort_data[direction]=desc&sort_data[mode]=total_impressions&view_all_page_id=15087023444"
  ]
}' |
apify call krazee_kaushik/facebook-ads-library-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=krazee_kaushik/facebook-ads-library-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Facebook Ads Library Scraper",
        "description": "Scrape Facebook Ads Library using Ads Library search URLs. Automatically splits long date ranges into monthly requests for complete data collection. Extract creatives, media, delivery, and optional reach/spend data. 200+ ads/min. Export to Excel, CSV, JSON & more. Starting from $0.6/1000 Ads.",
        "version": "0.0",
        "x-build-id": "0sTVM0idphqOfPoTW"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/krazee_kaushik~facebook-ads-library-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-krazee_kaushik-facebook-ads-library-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/krazee_kaushik~facebook-ads-library-scraper/runs": {
            "post": {
                "operationId": "runs-sync-krazee_kaushik-facebook-ads-library-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/krazee_kaushik~facebook-ads-library-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-krazee_kaushik-facebook-ads-library-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "urls": {
                        "title": "Ads Library URLs",
                        "type": "array",
                        "description": "Enter one or more Facebook Ads Library search URLs.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "resultsPerUrl": {
                        "title": "Results Per URL",
                        "minimum": 1,
                        "type": "integer",
                        "description": "Maximum number of ads to scrape from each Ads Library URL.",
                        "default": 50
                    },
                    "includeAdDetails": {
                        "title": "Include Extra Ad Details (Reach & Spend Data)",
                        "type": "boolean",
                        "description": "Fetch additional ad details such as reach, spend, and advertiser information when available. This requires an extra request per ad and may slightly increase scraping time.",
                        "default": false
                    },
                    "sortBy": {
                        "title": "Sort By",
                        "enum": [
                            "IMPRESSIONS",
                            "MOST_RECENT"
                        ],
                        "type": "string",
                        "description": "Choose how ads should be ordered.",
                        "default": "IMPRESSIONS"
                    },
                    "activeStatus": {
                        "title": "Active Status",
                        "enum": [
                            "ALL",
                            "ACTIVE",
                            "INACTIVE"
                        ],
                        "type": "string",
                        "description": "Filter ads by activity status.",
                        "default": "ALL"
                    },
                    "impressionsFrom": {
                        "title": "Impressions From",
                        "type": "string",
                        "description": "Only include ads with impressions on or after this date."
                    },
                    "impressionsTo": {
                        "title": "Impressions To",
                        "type": "string",
                        "description": "Only include ads with impressions on or before this date."
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
