# META Ad Leads Extractor (`leadsbrary/meta-ad-leads-extractor`) Actor

Extract enriched leads from Facebook Ad Library. Enter a keyword + country → get email, phone, website, adress, Instagram & more for every advertiser found. Powered by Leadsbrary.com. Pay only for results.

- **URL**: https://apify.com/leadsbrary/meta-ad-leads-extractor.md
- **Developed by:** [Alexandre Manguis](https://apify.com/leadsbrary) (community)
- **Categories:** Lead generation, Social media, Automation
- **Stats:** 99 total users, 27 monthly users, 100.0% runs succeeded, 3 bookmarks
- **User rating**: 4.38 out of 5 stars

## Pricing

from $3.50 / 1,000 leads

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — 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

## Facebook Ads Lead Extractor — Emails, Phones, Address & Contacts

Extract enriched business leads directly from **Facebook's Ad Library** using the Meta Graph API. Enter keywords and country — get a ready-to-use dataset with contact details for every advertiser found.

**v1.1 — New features:**

- 🔀 **matchAllKeywords** — AND logic: only pages whose ads contain ALL keywords (perfect for geo + niche targeting)
- 🔍 **pageFilter.nameContains** — post-filter by Facebook page name
- 📍 **pageFilter.addressContains** — post-filter by physical address (scraped from the profile page)
- 🏠 **Address field** — physical address extracted from each Facebook business page

Requires a **Meta access token** set as the `META_ACCESS_TOKEN` environment variable in actor settings.

***

### What you get per lead

| Field | Example |
|-------|---------|
| **Facebook URL** | https://facebook.com/bmturkiyeclinic |
| **Email** | info@bmturkiye.com |
| **Phone** | +905528006000 |
| **Website** | https://bmturkiye.com |
| **Address** | Cherni Vrah 47A, Sofia, Bulgaria, 1404 |
| **Instagram Username** | bmturkiyeclinic |
| **Instagram Followers** | 16537 |
| **Page Name** | BM Türkiye |
| **Category** | Health/Beauty |
| **Facebook Likes** | 1415 |
| **Facebook Verification** | NOT\_VERIFIED |
| **Country** | TR |
| **Ad Creation Date** | 2023-11-14 |
| **Ad Start Date** | 2023-11-15 |
| **Keyword** | dental clinic |

***

### How it works

1. Searches the Meta Ad Library (`ads_archive`) by keyword + country using your Meta access token
2. Collects unique advertiser page IDs from the results
3. For each page, scrapes the Facebook profile to extract **email, phone, website and address** from JSON-encoded page data
4. Also enriches with Instagram data via the Facebook Ad Library typeahead API
5. Optionally applies `pageFilter` post-processing (name / address)
6. Saves everything to a clean dataset (CSV / JSON / Excel / JSONL)

***

### Setup

Set the `META_ACCESS_TOKEN` environment variable in the actor's **Environment variables** settings.

***

### Input

| Parameter | Type | Description | Default |
|-----------|------|-------------|---------|
| **keywords** | string | Comma-separated search terms (e.g. `dentist, lawyer`) | `dental clinic` |
| **country** | string | 2-letter ISO country code | `FR` |
| **adStatus** | select | Active, Inactive, or All | Active |
| **maxLeads** | integer | Max leads to extract (1–1000) | 100 |
| **matchAllKeywords** | boolean | AND logic: only pages matching ALL keywords | `false` |
| **pageFilter** | object | Post-processing filters: `nameContains`, `addressContains` | `{}` |

#### matchAllKeywords — AND logic

By default, keywords are searched independently (OR logic):

- `formosa, restaurant` → pages with "formosa" in their ads **OR** pages with "restaurant" globally

With `matchAllKeywords: true`, only pages appearing in **all** keyword searches are kept (AND logic):

- `formosa, restaurant` → only pages whose ads contain **both** "formosa" **and** "restaurant"

The actor fetches up to **5× maxLeads** candidates per keyword then intersects the sets. This is the recommended setting for geo + niche targeting.

```json
{
  "keywords": "formosa, restaurant",
  "country": "ALL",
  "adStatus": "ALL",
  "maxLeads": 20,
  "matchAllKeywords": true
}
```

#### pageFilter — Post-processing filters

Applied after the Meta API search, before scraping contact info:

| Sub-field | Description | Example |
|-----------|-------------|---------|
| `nameContains` | Keep only pages whose Facebook name contains this string (case-insensitive) | `"formosa"` |
| `addressContains` | Keep only pages whose physical address contains this string (case-insensitive) | `"sofia"` or `"bulgaria"` |

```json
{
  "keywords": "restaurant",
  "country": "BG",
  "adStatus": "ACTIVE",
  "maxLeads": 20,
  "pageFilter": {
    "nameContains": "formosa",
    "addressContains": "sofia"
  }
}
```

Both filters can be combined with `matchAllKeywords` for maximum precision.

***

### Available countries

| Code | Country |
|------|---------|
| 🇦🇪 AE | United Arab Emirates |
| 🇦🇷 AR | Argentina |
| 🇦🇹 AT | Austria |
| 🇦🇺 AU | Australia |
| 🇧🇪 BE | Belgium |
| 🇧🇭 BH | Bahrain |
| 🇧🇴 BO | Bolivia |
| 🇧🇷 BR | Brazil |
| 🇧🇬 BG | Bulgaria |
| 🇨🇦 CA | Canada |
| 🇨🇭 CH | Switzerland |
| 🇨🇮 CI | Ivory Coast |
| 🇨🇱 CL | Chile |
| 🇨🇲 CM | Cameroon |
| 🇨🇴 CO | Colombia |
| 🇨🇷 CR | Costa Rica |
| 🇨🇿 CZ | Czech Republic |
| 🇩🇪 DE | Germany |
| 🇩🇰 DK | Denmark |
| 🇩🇴 DO | Dominican Republic |
| 🇩🇿 DZ | Algeria |
| 🇪🇨 EC | Ecuador |
| 🇪🇬 EG | Egypt |
| 🇪🇸 ES | Spain |
| 🇫🇮 FI | Finland |
| 🇫🇷 FR | France |
| 🇬🇧 GB | United Kingdom |
| 🇬🇭 GH | Ghana |
| 🇬🇷 GR | Greece |
| 🇬🇹 GT | Guatemala |
| 🇭🇰 HK | Hong Kong |
| 🇭🇳 HN | Honduras |
| 🇭🇷 HR | Croatia |
| 🇭🇺 HU | Hungary |
| 🇮🇩 ID | Indonesia |
| 🇮🇪 IE | Ireland |
| 🇮🇱 IL | Israel |
| 🇮🇳 IN | India |
| 🇮🇶 IQ | Iraq |
| 🇮🇹 IT | Italy |
| 🇯🇴 JO | Jordan |
| 🇯🇵 JP | Japan |
| 🇰🇪 KE | Kenya |
| 🇰🇷 KR | South Korea |
| 🇰🇼 KW | Kuwait |
| 🇱🇧 LB | Lebanon |
| 🇱🇺 LU | Luxembourg |
| 🇲🇦 MA | Morocco |
| 🇲🇽 MX | Mexico |
| 🇲🇾 MY | Malaysia |
| 🇳🇬 NG | Nigeria |
| 🇳🇮 NI | Nicaragua |
| 🇳🇱 NL | Netherlands |
| 🇳🇴 NO | Norway |
| 🇳🇿 NZ | New Zealand |
| 🇵🇦 PA | Panama |
| 🇵🇪 PE | Peru |
| 🇵🇭 PH | Philippines |
| 🇵🇱 PL | Poland |
| 🇵🇹 PT | Portugal |
| 🇵🇾 PY | Paraguay |
| 🇶🇦 QA | Qatar |
| 🇷🇴 RO | Romania |
| 🇸🇦 SA | Saudi Arabia |
| 🇸🇪 SE | Sweden |
| 🇸🇬 SG | Singapore |
| 🇸🇮 SI | Slovenia |
| 🇸🇰 SK | Slovakia |
| 🇸🇳 SN | Senegal |
| 🇸🇻 SV | El Salvador |
| 🇹🇭 TH | Thailand |
| 🇹🇳 TN | Tunisia |
| 🇹🇷 TR | Turkey |
| 🇹🇼 TW | Taiwan |
| 🇺🇦 UA | Ukraine |
| 🇺🇾 UY | Uruguay |
| 🇺🇸 US | United States |
| 🇻🇪 VE | Venezuela |
| 🇻🇳 VN | Vietnam |
| 🇿🇦 ZA | South Africa |

> **Your country is missing?** Don't hesitate to request it by [opening an issue](../../issues) or sending a private message — we'll add it promptly!

***

### Sample output

```json
[
  {
    "Facebook URL": "https://www.facebook.com/309686782231976",
    "Email": "info@bmturkiye.com",
    "Phone": "+905528006000",
    "Website": "https://bmturkiye.com/",
    "Address": "Bağcılar, Istanbul, Turkey, 34200",
    "Followers": 1400,
    "Page ID": "309686782231976",
    "Page Name": "BM Türkiye",
    "Category": "Health/Beauty",
    "Facebook Likes": 1415,
    "Facebook Verification": "NOT_VERIFIED",
    "Country": "TR",
    "Entity Type": "person_profile",
    "Instagram Username": "bmturkiyeclinic",
    "Instagram Followers": 16537,
    "Instagram Verified": null,
    "All Emails": "info@bmturkiye.com",
    "All Phones": "+905528006000",
    "All Websites": "https://bmturkiye.com/",
    "Platforms": "facebook, instagram",
    "Ad Creation Date": "2023-11-14",
    "Ad Start Date": "2023-11-15",
    "Keyword": "dental clinic",
    "Captured At": "2026-04-01T10:22:41Z"
  }
]
```

***

### Tips for best results

- Use **specific keywords** for more targeted leads: `dental implants` > `dentist`
- Set **Ad Status = Active** to get advertisers currently spending money
- Enable **matchAllKeywords** when combining a niche keyword with a location/brand name (e.g. `formosa, restaurant`)
- Use **pageFilter.addressContains** to narrow to a city or region (e.g. `sofia`, `new york`)
- Use **pageFilter.nameContains** when the brand name should appear in the page title
- Export as **CSV** for direct CRM import

***

### Keywords

Facebook ads leads, Meta ad library leads, Facebook advertiser emails, Facebook advertiser contacts, Meta ads email extractor, Facebook business leads, Meta ad library scraper, Facebook page email extractor, Instagram business contacts, Facebook ads prospecting, B2B leads Facebook, social media leads, advertiser contact info, Facebook marketing leads, Meta Graph API leads, Facebook page contacts, email scraper Facebook, phone number Facebook ads, website scraper Meta ads, lead generation Facebook, CRM import Facebook, sales leads Meta, Facebook ads intelligence, advertiser database, Facebook business directory, address scraper Facebook, business address extractor

# Actor input Schema

## `keywords` (type: `string`):

One or more keywords to search in the Meta Ad Library. Separate multiple keywords with commas.

Example (OR mode): `dentist, lawyer` → finds pages with "dentist" OR "lawyer" in their ads.
Example (AND mode — enable matchAllKeywords): `formosa, restaurant` → only pages whose ads contain BOTH words.

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

Enter a 2-letter ISO country code. Examples: FR (France), US (United States), DE (Germany), ES (Spain), BR (Brazil), AR (Argentina).

All supported codes:
AE · AR · AT · AU · BE · BH · BO · BR · BG · CA · CH · CI · CL · CM · CO · CR · CZ · DE · DK · DO · DZ · EC · EG · ES · FI · FR · GB · GH · GR · GT · HK · HN · HR · HU · ID · IE · IL · IN · IQ · IT · JO · JP · KE · KR · KW · LB · LU · MA · MX · MY · NG · NI · NL · NO · NZ · PA · PE · PH · PL · PT · PY · QA · RO · SA · SE · SG · SI · SK · SN · SV · TH · TN · TR · TW · UA · UY · US · VE · VN · ZA

## `adStatus` (type: `string`):

Filter by ad status. Active = advertisers currently running ads (recommended for fresh leads).

## `maxLeads` (type: `integer`):

Maximum number of unique Facebook pages (leads) to extract. The actor stops when this limit is reached or when the Meta API has no more results.

## `matchAllKeywords` (type: `boolean`):

When enabled, only return pages whose ads contain ALL of the provided keywords (AND logic instead of OR).

Example: keywords = `formosa, restaurant` with this enabled → only pages that have BOTH "formosa" AND "restaurant" in their ads, not all restaurants globally.

The actor fetches up to 5× maxLeads candidates per keyword then intersects the results. Recommended when combining a brand/location name with a category.

## `nameContains` (type: `string`):

Only keep pages whose **Facebook page name** contains this text (case-insensitive).

Example: `formosa` keeps only pages named 'Formosa Restaurant', 'Formosa Cafe', etc.

Leave empty to skip this filter.

## `addressContains` (type: `string`):

Only keep pages whose **physical address** (scraped from the Facebook profile) contains this text (case-insensitive).

Examples: `sofia`, `new york`, `75001`, `bulgaria`

Leave empty to skip this filter.

## Actor input object example

```json
{
  "keywords": "dentist",
  "country": "FR",
  "adStatus": "ACTIVE",
  "maxLeads": 5,
  "matchAllKeywords": false
}
```

# Actor output Schema

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

Dataset containing one row per unique Facebook advertiser page, including email, phone, website, Instagram and page metadata.

# 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 = {
    "keywords": "dental clinic",
    "country": "FR",
    "maxLeads": 5
};

// Run the Actor and wait for it to finish
const run = await client.actor("leadsbrary/meta-ad-leads-extractor").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 = {
    "keywords": "dental clinic",
    "country": "FR",
    "maxLeads": 5,
}

# Run the Actor and wait for it to finish
run = client.actor("leadsbrary/meta-ad-leads-extractor").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 '{
  "keywords": "dental clinic",
  "country": "FR",
  "maxLeads": 5
}' |
apify call leadsbrary/meta-ad-leads-extractor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=leadsbrary/meta-ad-leads-extractor",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/hsr4U7SSd3ckIzezS/builds/5ukoOcI3xq55rQ64V/openapi.json
