# Facebook Ultimate Scraper (`khnaami/facebook-ultimate-scraper`) Actor

The most comprehensive, reliable, and stealthy Facebook Intelligence & Data Scraper on Apify.
Built with JavaScript (Node.js), Crawlee, and Playwright, featuring automatic URL routing, anti-blocking measures, and 11 specialized extraction modules.

- **URL**: https://apify.com/khnaami/facebook-ultimate-scraper.md
- **Developed by:** [khalid naami](https://apify.com/khnaami) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

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

## 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 Ultimate All-in-One Scraper (Enterprise Edition)

The most comprehensive, reliable, and stealthy **Facebook Intelligence & Data Scraper** on Apify.\
Built with **JavaScript (Node.js), Crawlee, and Playwright**, featuring automatic URL routing, anti-blocking measures, and 11 specialized extraction modules.

***

### 🌟 11 All-in-One Scraping Modules

1. **Pages & B2B Leads Scraper**: Official page bio, verification badge, follower counts, like counts, category, and direct contact leads (Email, Phone, WhatsApp, Website, Address).
2. **Public Groups Scraper**: Group name, privacy status, member counts, and public feed posts.
3. **Posts & Engagements Scraper**: Post text content, publication timestamps, reaction counts (Likes, Loves), comment counts, and share counts.
4. **Comments & Replies Scraper**: Post comments, author profiles, comment text, and engagement likes.
5. **Reels & Videos Scraper**: Facebook Reels and video posts, view counts, captions, and thumbnails.
6. **Facebook Ads Library Scraper**: Meta Ads Library data (Ad ID, active/inactive status, creative media, ad copy text, start running dates).
7. **Marketplace Scraper**: E-commerce products on Facebook Marketplace (item title, price, city/location, seller info, image).
8. **Events Scraper**: Public Facebook events, dates, location venues, and attendee statistics.
9. **Reviews & Recommendations Scraper**: Customer ratings out of 5, recommendation percentages, and reviewer comments.
10. **High-Res Photos & Albums Scraper**: High-definition image URLs from albums and timeline photo feeds.
11. **URL to Numeric ID Converter**: Converts vanity profile/page/group usernames into permanent Facebook Numeric IDs (FBID) and deep app URIs (`fb://page/<id>`).

***

### ⚡ Smart `AUTO_DETECT` Engine

You can paste **ANY Facebook URL** into `startUrls` and leave `scrapeMode: "AUTO_DETECT"`. The scraper will automatically inspect the URL pattern and dispatch the exact matching extractor!

***

### 📥 Input Configuration

| Parameter | Type | Default | Description |
| :--- | :--- | :--- | :--- |
| `scrapeMode` | Select | `"AUTO_DETECT"` | Choose from `AUTO_DETECT`, `PAGES`, `GROUPS`, `POSTS`, `COMMENTS`, `REELS_VIDEOS`, `ADS_LIBRARY`, `MARKETPLACE`, `EVENTS`, `REVIEWS`, `PHOTOS_ALBUMS`, or `URL_ID_CONVERTER`. |
| `startUrls` | Array | Required | List of Facebook URLs to scrape. |
| `maxItems` | Integer | `15` | Maximum items/posts/listings per target URL. |
| `maxComments` | Integer | `10` | Maximum comments per post. |
| `marketplaceCity` | String | `""` | Optional city filter for Marketplace searches. |
| `adsCountry` | String | `"ALL"` | Target country code for Meta Ads Library. |
| `proxyConfiguration` | Object | `RESIDENTIAL` | Apify Residential Proxy configuration. |
| `customCookies` | String | `""` | Optional Facebook session cookies for authenticated scraping. |

***

### 📤 Sample Outputs

#### 1. Facebook Page & Lead Output

```json
{
  "type": "PAGE",
  "pageName": "Nike",
  "pageUrl": "https://www.facebook.com/Nike",
  "verified": true,
  "followersCount": 35000000,
  "likesCount": 34000000,
  "email": "media.relations@nike.com",
  "phone": "+1 800 806 6453",
  "website": "https://www.nike.com",
  "category": "Sportswear & Footwear",
  "recentPosts": [
    {
      "postIndex": 1,
      "text": "Greatness is not born. It's made.",
      "reactions": "45K",
      "comments": "1.2K"
    }
  ],
  "scrapedAt": "2026-10-07T21:30:00.000Z"
}
```

#### 2. Marketplace Output

```json
{
  "type": "MARKETPLACE",
  "sourceUrl": "https://www.facebook.com/marketplace/category/electronics",
  "totalItems": 12,
  "items": [
    {
      "itemIndex": 1,
      "title": "iPhone 15 Pro Max 256GB",
      "price": "$950",
      "location": "Paris, France",
      "imageUrl": "https://scontent...jpg",
      "itemUrl": "https://www.facebook.com/marketplace/item/..."
    }
  ]
}
```

***

### 🛡️ Anti-Block & Stealth Technology

- Automatic dismissal of Facebook's "Log In / See More" modal dialog.
- Headless Chromium with customized canvas, navigator, and headers.
- Built-in Residential Proxy rotation.

***

### 📄 License

Apache-2.0

# Actor input Schema

## `scrapeMode` (type: `string`):

Select the Facebook data module to execute, or choose AUTO_DETECT to automatically identify the URL type.

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

List of Facebook URLs (Pages, Groups, Marketplace, Reels, Events, or Posts).

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

Maximum number of items (posts, group discussions, marketplace products, reels, or photos) to collect.

## `maxComments` (type: `integer`):

Maximum number of comments to extract when scraping posts or comments mode.

## `marketplaceCity` (type: `string`):

City filter for Marketplace searches (e.g. Paris, New York, Casablanca, London).

## `adsCountry` (type: `string`):

Country code for Facebook Ads Library scraping (e.g. US, FR, MA, GB, ALL).

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

Apify Proxy settings. Residential proxies are recommended for Facebook to prevent blocks.

## `customCookies` (type: `string`):

Optional Facebook cookies (JSON array or 'c_user=...; xs=...' format) to scrape in logged-in state or access private groups.

## Actor input object example

```json
{
  "scrapeMode": "AUTO_DETECT",
  "startUrls": [
    {
      "url": "https://www.facebook.com/Nike"
    },
    {
      "url": "https://www.facebook.com/marketplace/paris/electronics"
    }
  ],
  "maxItems": 15,
  "maxComments": 10,
  "marketplaceCity": "",
  "adsCountry": "ALL",
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# Actor output Schema

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

Scraped Facebook records (Pages & B2B Leads, Groups, Posts, Marketplace, Reels, Events, Reviews, Photos, and Numeric IDs)

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

High-level summary report and execution metrics stored in 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/Nike"
        },
        {
            "url": "https://www.facebook.com/marketplace/paris/electronics"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("khnaami/facebook-ultimate-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/Nike" },
        { "url": "https://www.facebook.com/marketplace/paris/electronics" },
    ] }

# Run the Actor and wait for it to finish
run = client.actor("khnaami/facebook-ultimate-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/Nike"
    },
    {
      "url": "https://www.facebook.com/marketplace/paris/electronics"
    }
  ]
}' |
apify call khnaami/facebook-ultimate-scraper --silent --output-dataset

```

## MCP server setup

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