# Facebook Ads: Search the Meta Ad Library by Advertiser (`deepmine/facebook-ads`) Actor

Facebook Ads Scraper by advertiser. Enter a Page ID, pick a country and export active ads with stable IDs, ad text, headlines, calls to action and creative URLs.

- **URL**: https://apify.com/deepmine/facebook-ads.md
- **Developed by:** [DeepMine](https://apify.com/deepmine) (community)
- **Categories:** Marketing, Social media
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.34 / 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.
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: Search the Meta Ad Library by Advertiser

Facebook Ads Scraper by advertiser. Enter a Page ID, pick a country and export active ads with stable IDs, ad text, headlines, calls to action and creative URLs.

### Try it: Active US ads by Page ID

```json
{
  "advertisers": [
    "15087023444"
  ],
  "country": "US",
  "activeStatus": "active",
  "maxAdsPerQuery": 50
}
```

### Output

The result fields and dataset views match [meta-ad-library-scraper](https://apify.com/deepmine/meta-ad-library-scraper). Open the Output tab to see the result rows, or download the dataset as JSON or CSV.

- [dataset_schema.json](.actor/dataset_schema.json)

### Pricing

The primary result price per 1,000 rows is `USD 0.55/0.45/0.39/0.34` (Free / Starter / Scale / Business).

If this Actor helps, please leave a review on its Apify Store page.

# Actor input Schema

## `advertisers` (type: `array`):

Advertisers whose ads you want: a Facebook page link (facebook.com/nike), a page id, an Ad Library link of the advertiser, or the page name exactly as it shows on its ads.

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

Keywords to search ads for, as you'd type them in the Ad Library search box, a list of strings (one search per line in the form). Give at least one of searchQueries, advertisers or startUrls.

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

Two-letter country code where the ads ran (US, GB, DE, ...), or ALL for every country (left out = ALL).

## `maxAdsPerQuery` (type: `integer`):

Stop each search, advertiser or URL after this many ads. You pay per ad, so this caps the cost of each search. Ads come in the order of Sort ads by. About 3 minutes per 1,000 ads.

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

Searches copied from facebook.com/ads/library in your browser. The filters in the link (country, active status, media type, dates) are used. A link to one ad (facebook.com/ads/library/?id=...) returns that ad.

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

Also fetch each ad's details: the advertiser's verification and Instagram account and followers and, for ads shown in the EU or UK, the reach, reach by country, targeted ages and gender, plus the payer and beneficiary (Meta's full details, with reach by age and gender, are in ad_details). Details are included in the ad price at no extra cost; each ad needs one more request, so runs are slower.

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

`impressions` (default): top ads first, the ones with the most impressions, as the Ad Library sorts them; `recent`: most recent first (grouped by the month they started).

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

`active` (default): only active ads; `inactive`: only ads that stopped; `all`: both.

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

Only ads with this kind of media.

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

All ads, or only one of Meta's special categories: social issues, elections or politics (these carry spend and impressions ranges), housing, employment, or credit and financial products.

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

Two-letter country codes (US, GB, DE, ...) to search all at once, instead of the one Country above. Each search covers all of them, and an ad shown in several of them is one row.

## `contentLanguages` (type: `array`):

Only ads in these languages, as two-letter codes (en, es, de, fr, ...). Left empty: every language.

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

Only ads shown on any of these platforms. Left empty: every platform.

## `exactPhrase` (type: `boolean`):

Match the search terms as an exact phrase instead of any order.

## `dateFrom` (type: `string`):

Only ads that were shown on or after this date (YYYY-MM-DD), whatever day they started. This is the Ad Library's own date filter.

## `dateTo` (type: `string`):

Only ads that were shown on or before this date (YYYY-MM-DD).

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

Residential proxies are the default: Meta refuses most datacenter IPs past the first page of results, so an Apify Proxy setting without residential still reads the result pages over residential (at no cost to you). First pages, details and lookups use datacenter IPs first.

## Actor input object example

```json
{
  "advertisers": [
    "15087023444"
  ],
  "country": "US",
  "maxAdsPerQuery": 50,
  "includeAdDetails": false,
  "sortBy": "impressions",
  "activeStatus": "active",
  "mediaType": "all",
  "adType": "all",
  "exactPhrase": false,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ],
    "apifyProxyCountry": "US"
  }
}
```

# Actor output Schema

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

No description

## `summary` (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 = {
    "advertisers": [
        "15087023444"
    ],
    "country": "US",
    "maxAdsPerQuery": 50,
    "activeStatus": "active"
};

// Run the Actor and wait for it to finish
const run = await client.actor("deepmine/facebook-ads").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 = {
    "advertisers": ["15087023444"],
    "country": "US",
    "maxAdsPerQuery": 50,
    "activeStatus": "active",
}

# Run the Actor and wait for it to finish
run = client.actor("deepmine/facebook-ads").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 '{
  "advertisers": [
    "15087023444"
  ],
  "country": "US",
  "maxAdsPerQuery": 50,
  "activeStatus": "active"
}' |
apify call deepmine/facebook-ads --silent --output-dataset

```

## MCP server setup

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

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/cKdiqRY9zxKJRiCeY/builds/yUX4LEoSDaJlJb5FF/openapi.json
