# Facebook Comments Scraper - Deep, No Login (`haketa/facebook-comments-scraper`) Actor

Scrape comments from public Facebook posts with deep pagination. By post URL, get each comment's author name, profile link, text, like count, timestamp and replies — far beyond the preview comments. No login, no API key, no browser. Export to JSON, CSV or Excel.

- **URL**: https://apify.com/haketa/facebook-comments-scraper.md
- **Developed by:** [Haketa](https://apify.com/haketa) (community)
- **Categories:** Social media, Lead generation
- **Features:** Limited permissions
- **Stats:** 5 total users, 2 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 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 Comments Scraper — Author, Text, Likes, Replies & Timestamps

[![Apify Actor](https://img.shields.io/badge/Apify-Actor-orange?style=flat-square\&logo=apify)](https://apify.com/haketa/facebook-comments-scraper)
[![Version](https://img.shields.io/badge/Version-v1.2.0-blue?style=flat-square)](https://apify.com/haketa/facebook-comments-scraper)
[![Pagination](https://img.shields.io/badge/Pagination-1%2C000%2B%20Comments-success?style=flat-square)](https://apify.com/haketa/facebook-comments-scraper)
[![Output Formats](https://img.shields.io/badge/Export-JSON%20%7C%20CSV%20%7C%20Excel-brightgreen?style=flat-square)](https://apify.com/haketa/facebook-comments-scraper)
[![Maintenance](https://img.shields.io/badge/Maintained-Active-2ea44f?style=flat-square)](https://apify.com/haketa/facebook-comments-scraper)

Extract comments from public Facebook posts at scale — **no login, no browser overhead, no Graph API approval required**. This enterprise-grade **Facebook comments scraper** extracts full comment threads from any public post URL, capturing **author names, profile IDs, clickable profile links, comment text, reaction/like counts, reply nesting depth, and ISO timestamps**.

Export your structured social listening data directly to **JSON, CSV, Excel, XML**, or stream it straight into your analytical pipelines via the Apify REST API.

***

### ⚡ At a glance

| Feature | Specification |
|:---|:---|
| **Target Platform** | Facebook (Public posts, reels, video posts, permalinks) |
| **Data Extracted** | Comment ID, Author Name, Author ID, Profile Link, Text, Likes, Depth, Reply Status, Timestamps |
| **Authentication** | 🔓 No login required (optional `loginCookie` supported for private enterprise depth) |
| **Pagination Depth** | 🚀 **Unlocked 1,000+ comments per post** with multi-session automatic rollover |
| **Duplicate Rate** | 🛡️ **0% Duplicates** (Strict global cross-post & in-thread ID deduplication) |
| **Proxy Requirement** | Residential Proxy enabled by default (required for Facebook guest endpoints) |
| **Execution Speed** | ~15–45 seconds for typical prefill runs (50–100 comments); pure HTTP protocol |
| **Export Formats** | Dataset API, JSON, CSV, Excel (XLSX), HTML Table, XML, RSS |
| **Integration Support** | Make, Zapier, Webhooks, Google Sheets, Airbyte, Python, Node.js |

***

### 🔎 Why scrape Facebook comments?

The comment section under a public [Facebook](https://www.facebook.com) post is where unfiltered consumer sentiment, brand feedback, and prospect conversations live. While post-level reaction counts only signal superficial visibility, **comment data uncovers exactly how audiences think, react, and make buying decisions**:

- **B2B Lead Generation & Prospecting**: Identify high-intent individuals discussing industry pain points, asking questions under competitor posts, or expressing purchasing needs. Profile links allow direct SDR follow-up.
- **Sentiment Analysis & Social Listening**: Mine customer reactions to product launches, corporate announcements, public relations crises, or political debates.
- **Competitor Intelligence & Ad Research**: Scrape comment threads on rival brands' public posts and sponsored campaigns to uncover competitor weaknesses and feature requests.
- **Community Moderation & Crisis Alerting**: Audit large community threads for spam, negative virality, trolling, or customer support escalations.
- **Market & Academic Research**: Build comprehensive corpora of natural language discussions across international news outlets and public pages.

Collecting comments manually via copy-paste is impossible at scale due to Facebook's dynamic infinite scroll, hidden "View more replies" toggles, and aggressive ranking filters. The official Meta Graph API enforces stringent app reviews, Page access tokens, and restricts access to third-party public threads. This scraper solves both challenges by fetching public discussion threads over fast, structured HTTP pagination without browser bloat.

***

### 🥊 Method Comparison: Why This Actor Wins

| Capability | Manual Copy-Paste | Meta Graph API | Browser Scrapers (Puppeteer) | Facebook Comments Scraper |
|:---|:---|:---|:---|:---|
| **Setup Time** | None | Weeks (App Review) | Hours (Script setup) | **Instant (Zero Setup)** |
| **Access Requirements** | Manual browser | Page Admin Token | High CPU/RAM VPS | **No Login / No API Key** |
| **Pagination Depth** | ~20 comments | Post Admin Only | 50–150 (Memory crashes) | **1,000+ Comments per Post** |
| **Nested Replies** | Painful manual clicks | Complex Graph edges | Fragile DOM selectors | **Automatic Full Hierarchy** |
| **Speed & Resource Cost** | Extremely slow | Fast | Very Heavy & Expensive | **Ultra-Fast Pure HTTP** |
| **Deduplication** | None | Manual | Prone to loop duplicates | **Built-in Global Deduplication** |
| **Export Formats** | Manual spreadsheets | Raw JSON only | Depends on script | **JSON, CSV, Excel, API** |

***

### ✨ Core Features & Capabilities

- 🚀 **Deep Pagination Beyond the Preview**: Unlike basic scrapers that only capture the first 2-3 preview comments, this actor steps through pagination tokens across multiple sessions to retrieve hundreds or thousands of comments per post.
- 💬 **Full Thread & Reply Capture**: Collects both top-level comments and nested multi-tier replies. Each item includes its `depth` index and a boolean `isReply` flag.
- 🎯 **Configurable Comment Sorting**: Extract by **All comments (unfiltered)**, **Most relevant (ranked)**, **Newest activity**, or **Top-level only**.
- 🛡️ **Zero-Duplicate Guarantee**: Deduplicates by globally unique comment FBID across the entire run, preventing duplicate rows and unnecessary compute costs.
- ⚡ **Lightweight Pure HTTP Protocol**: Built without heavy headless browsers (Puppeteer/Playwright), consuming minimal memory and delivering blazing-fast extraction speeds.
- 🔄 **Multi-Session Resilience**: If a logged-out guest session hits an upstream boundary, the actor automatically cycles to a fresh session, continuing until your target `maxComments` is reached.
- 🔌 **Seamless Integration Ready**: Native webhooks, Zapier, Make, and Google Sheets integrations allow continuous automated monitoring.

***

### 📊 Extracted Data Fields

Every scraped comment is output as a clean, standardized record with high fill rates across all core attributes:

#### 💬 Comment & Engagement Data

| Field Name | Type | Coverage | Description |
|:---|:---|:---|:---|
| `commentId` | String | 🟢 High (100%) | Unique Facebook comment identifier (used for exact deduplication). |
| `text` | String | 🟢 High (100%) | Full text content of the comment, preserving emoji and Unicode characters. |
| `likeCount` | Integer | 🟢 High (100%) | Total reaction and like count (0 if no reactions recorded). |
| `depth` | Integer | 🟢 High (100%) | Comment nesting level (`0` for top-level, `1+` for nested replies). |
| `isReply` | Boolean | 🟢 High (100%) | `true` if the item is a reply to another comment, otherwise `false`. |
| `createdTime` | String | 🟢 High (95%+) | ISO 8601 formatted publication timestamp of the comment. |

#### 👤 Author & Profile Information

| Field Name | Type | Coverage | Description |
|:---|:---|:---|:---|
| `authorName` | String | 🟢 High (100%) | Display name of the commenter or public page. |
| `authorId` | String | 🟢 High (100%) | Numeric or vanity Facebook profile ID of the author. |
| `authorUrl` | String | 🟢 High (100%) | Direct URL to the commenter's profile (`https://www.facebook.com/{authorId}`). |

#### 📌 Post & Contextual Metadata

| Field Name | Type | Coverage | Description |
|:---|:---|:---|:---|
| `postUrl` | String | 🟢 High (100%) | Original public Facebook post URL provided in the input. |
| `postId` | String | 🟢 High (100%) | Unique Facebook post identifier parsed from the URL. |
| `postTotalComments`| Integer | 🟡 Conditional | Total comments reported on the parent post by Facebook. |
| `scrapedAt` | String | 🟢 High (100%) | ISO 8601 timestamp recording when the extraction took place. |

***

### 📥 Input Parameters

The actor is designed to be plug-and-play. All parameters are optional; running with default settings automatically analyzes a trending public news post.

| Parameter | Type | Default | Description |
|:---|:---|:---|:---|
| `postUrls` | Array | `["https://www.facebook.com/..."]` | List of public Facebook post URLs. Accepts `posts/{id}`, `permalink.php`, `story.php`, and video URLs. |
| `maxComments` | Integer | `100` (prefill `50`) | Maximum comments to collect per post (`0` for unlimited pagination). |
| `includeReplies` | Boolean | `true` | When enabled, collects nested comment replies in addition to top-level comments. |
| `commentsSort` | String | `RANKED_UNFILTERED` | Ranking filter: `RANKED_UNFILTERED` (All), `RANKED_FILTERED` (Top), `RECENT` (Newest), or `CHRONOLOGICAL`. |
| `loginCookie` | String | `null` | *Optional.* Facebook session cookie header for accessing deep enterprise or high-volume threads. |
| `proxyConfiguration` | Object | `RESIDENTIAL` | Proxy configuration. Facebook blocks datacenter IPs; residential proxy is enabled by default. |

#### Example Input Configuration

```json
{
  "postUrls": [
    "https://www.facebook.com/cnn/posts/pfbid0V91q399yAUSE5EAUQapwc9CHzPRKZ2wsjnh8a48xbfUobU16RK3BNoo8jK2yaRK2l"
  ],
  "maxComments": 100,
  "includeReplies": true,
  "commentsSort": "RANKED_UNFILTERED",
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": ["RESIDENTIAL"],
    "apifyProxyCountry": "US"
  }
}
```

***

### 📤 Sample Output Record

```json
{
  "postUrl": "https://www.facebook.com/cnn/posts/pfbid0V91q399yAUSE5EAUQapwc9CHzPRKZ2wsjnh8a48xbfUobU16RK3BNoo8jK2yaRK2l",
  "postId": "pfbid0V91q399yAUSE5EAUQapwc9CHzPRKZ2wsjnh8a48xbfUobU16RK3BNoo8jK2yaRK2l",
  "postTotalComments": 1318,
  "commentId": "3288600681329253",
  "authorName": "Billy W Thompson",
  "authorId": "100001981282178",
  "authorUrl": "https://www.facebook.com/100001981282178",
  "text": "Since she was previously part of the family, I bet she has some good stories to share.",
  "likeCount": 160,
  "depth": 0,
  "isReply": false,
  "createdTime": "2026-10-13T14:25:40.000Z",
  "scrapedAt": "2026-11-10T15:30:00.000Z"
}
```

***

### 🔁 Deep Pagination & Scaling to 1,000+ Comments

Facebook employs aggressive cursor rotation and lazy-loading boundaries on public logged-out posts. This actor overcomes these boundaries through a resilient multi-session architecture:

1. **Initial Cursor Extraction**: Extracts the baseline feedback identifier, cryptographic session tokens, and initial comment cursor from the page stream.
2. **Sequential Protocol Pagination**: Dispatches successive pagination queries, stepping forward block by block to gather newly revealed comment batches.
3. **Session Rollover**: If an upstream session hits a temporary rate ceiling before reaching your `maxComments` target, the scraper gracefully spins up a fresh residential session to continue from the newest cursor.
4. **Global Cross-Post Deduplication**: Every incoming comment ID is verified against an in-memory hash set. Duplicate nodes leaked across Facebook recommendation widgets are eliminated before reaching the dataset.

To collect **1,000+ comments** from active viral posts:

- Set `maxComments` to `1000` or `0` (unlimited).
- Ensure your Apify account has active residential proxy access.
- For maximum depth on threads with 10,000+ comments, providing an optional `loginCookie` allows seamless access to deep archival layers.

***

### 🛠️ Step-by-Step Execution Guide

#### Running via Apify Console

1. **Navigate to Actor**: Open [Facebook Comments Scraper](https://apify.com/haketa/facebook-comments-scraper) in your browser.
2. **Input Post URLs**: Paste target Facebook post links into the `postUrls` box (one per line).
3. **Set Depth & Limits**: Specify `maxComments` (e.g., 50 for quick checks, 1000 for full archival).
4. **Select Ranking**: Keep `RANKED_UNFILTERED` to capture all comments without algorithmic bias.
5. **Click Start**: Hit **Start** in the console. Watch live extraction metrics in the log console.
6. **Download Results**: Go to the **Dataset** tab and export your data as CSV, Excel, or JSON.

#### Running via Apify Scheduled Tasks

To monitor high-visibility posts continuously:

1. Save your input settings as an Apify **Task**.
2. Click **Schedules** in the sidebar and choose your interval (e.g., every 6 hours or daily).
3. Connect a **Webhook** to alert your Discord, Slack, or webhook endpoint whenever new comments are detected.

***

### 💼 High-Impact Business Use Cases

#### 1. B2B Sales Prospecting & Lead Generation

Target niche communities and software review posts on Facebook. Extract commenters actively complaining about competitor pricing or asking for alternatives. Enrich the output profile links via CRM tools for direct outreach.

#### 2. Brand Reputation & Crisis Management

Track public sentiment across critical corporate announcements. Automated runs trigger alerts when high-reaction negative comments appear, allowing PR teams to respond in real time.

#### 3. Competitor Ad Campaign Intelligence

Monitor public competitor posts and ad creatives. Analyze audience feedback to uncover what customers love or hate about rival offerings, informing your own value propositions.

#### 4. Market Research & Academic NLP

Download thousands of real-world comments to train machine learning models for sentiment classification, stance detection, entity extraction, and customer feedback clustering.

#### 5. Content Ideation & Audience Q\&A Mining

Analyze the exact questions and phrasing customers use in discussion threads. Use these authentic user inquiries to draft high-converting blog posts, FAQs, and product landing pages.

***

### 🔌 API & Integration Examples

#### Python API Integration

```python
from apify_client import ApifyClient

## Initialize the ApifyClient with your API token
client = ApifyClient("YOUR_APIFY_TOKEN")

## Prepare the Actor input
run_input = {
    "postUrls": [
        "https://www.facebook.com/cnn/posts/pfbid0V91q399yAUSE5EAUQapwc9CHzPRKZ2wsjnh8a48xbfUobU16RK3BNoo8jK2yaRK2l"
    ],
    "maxComments": 200,
    "includeReplies": True,
    "commentsSort": "RANKED_UNFILTERED"
}

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

## Fetch Actor results from the run's dataset
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(f"[{item['authorName']}] ({item['likeCount']} likes): {item['text'][:80]}")
```

#### Node.js API Integration

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

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

const input = {
    postUrls: [
        'https://www.facebook.com/cnn/posts/pfbid0V91q399yAUSE5EAUQapwc9CHzPRKZ2wsjnh8a48xbfUobU16RK3BNoo8jK2yaRK2l'
    ],
    maxComments: 200,
    includeReplies: true,
};

const run = await client.actor('haketa/facebook-comments-scraper').call(input);
const { items } = await client.dataset(run.defaultDatasetId).listItems();

console.log(`Fetched ${items.length} comments from Facebook!`);
```

#### Google Sheets / Make / Zapier Integration

Pipe live Facebook comments straight into your corporate spreadsheets:

1. Configure an Apify integration step in Make or Zapier.
2. Select trigger: **New Dataset Item** on `facebook-comments-scraper`.
3. Map fields: `authorName` → Name, `authorUrl` → Profile Link, `text` → Comment Body, `likeCount` → Reactions.
4. Update Google Sheets in real time to empower sales or support teams.

***

### 🗄️ SQL Schema & Data Warehouse Loading

For enterprise data engineering teams piping scraped Facebook comments into analytical warehouses (Snowflake, BigQuery, ClickHouse, PostgreSQL), here is the standard relational schema definition:

```sql
CREATE TABLE facebook_post_comments (
    comment_id VARCHAR(64) PRIMARY KEY,
    post_id VARCHAR(128) NOT NULL,
    post_url TEXT NOT NULL,
    post_total_comments INTEGER,
    author_name VARCHAR(255),
    author_id VARCHAR(128),
    author_url TEXT,
    comment_text TEXT,
    like_count INTEGER DEFAULT 0,
    nesting_depth INTEGER DEFAULT 0,
    is_reply BOOLEAN DEFAULT FALSE,
    created_time TIMESTAMP WITH TIME ZONE,
    scraped_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);

CREATE INDEX idx_fb_post_comments_post_id ON facebook_post_comments(post_id);
CREATE INDEX idx_fb_post_comments_author_id ON facebook_post_comments(author_id);
CREATE INDEX idx_fb_post_comments_created_time ON facebook_post_comments(created_time);
```

***

### 📥 Sample CSV Export Format

When exporting the Apify dataset directly to CSV or Excel for business analysts, columns are cleanly ordered:

```csv
postUrl,postId,postTotalComments,commentId,authorName,authorId,authorUrl,text,likeCount,depth,isReply,createdTime,scrapedAt
https://www.facebook.com/...,pfbid0V...,1318,3288600...,Billy W Thompson,1000019...,https://www.facebook.com/1000...,"Since she was previously part of the family...",160,0,false,2026-10-13T14:25:40.000Z,2026-11-10T15:30:00.000Z
```

***

### 💡 Best Practices & Performance Tips

- **Comment Ordering**: Use `RANKED_UNFILTERED` for maximum comment discovery. If you only need immediate public sentiment on breaking news, choose `RECENT`.
- **Filtering Replies**: If you only need top-level opinions, set `includeReplies` to `false` to reduce compute time and conserve proxy bandwidth.
- **Batching Multiple Posts**: Add up to several dozen URLs in `postUrls`. The scraper processes each post sequentially, labeling each comment row with its respective `postId`.
- **Proxy Geography**: Keep `proxyConfiguration` configured to Residential (US or EU) for consistent throughput and zero block rates.
- **Scheduled Monitoring**: Schedule the actor on Apify to run daily or weekly on brand pages to capture ongoing conversations automatically.

***

### ❓ Frequently Asked Questions (FAQ)

##### Do I need a Facebook account or API access token?

No. The scraper runs logged out by default. You do not need to register a Facebook Developer app, undergo Meta app review, or generate access tokens.

##### Can I scrape private posts or closed Facebook groups?

No. This actor extracts data exclusively from publicly accessible posts, reels, and video permalinks. Private profiles and secret groups are not accessible.

##### How fast does the scraper collect comments?

Because the actor communicates via pure HTTP protocols rather than headless browsers, extraction is extremely rapid. A typical batch of 50–100 comments completes in roughly 20–40 seconds.

##### How are replies structured in the output?

Nested replies are saved as individual records. They are linked to the parent thread with `isReply: true` and have a `depth` value of `1` or higher.

##### Can I integrate the output with Google Sheets or Airtable?

Yes. Use Apify’s native integrations, or connect your actor run to Make (Integromat) or Zapier via webhook notifications.

##### What export formats are supported?

You can export results in JSON, CSV, Excel (XLSX), XML, or access them programmatically via the Apify API.

##### Does this scraper produce duplicate comments?

No. Every comment is strictly de-duplicated by its unique Facebook Comment ID across the entire run.

##### How does it handle large threads with thousands of comments?

It pages through threads using cursor advancement and automatic residential session rotation, allowing you to reach 1,000+ comments when requested.

##### What happens if a post URL is invalid or deleted?

The actor logs a warning, reports the missing post in the status message, and continues processing the remaining URLs in your batch without aborting.

##### Can I filter comments by keyword or sentiment?

You can post-process the exported JSON or CSV with standard spreadsheet tools, Python Pandas, or feed the dataset directly into an Apify sentiment analysis integration.

##### Does it capture timestamps for comments?

Yes. Whenever exposed by Facebook's public feed, comments carry full ISO 8601 timestamps (`createdTime`).

##### Can I scrape Facebook Video or Reel comments?

Yes! Standard video permalink URLs (e.g. `facebook.com/watch/?v=...` or `facebook.com/reel/...`) that expose public comment feeds are fully supported.

***

### 🔗 Related Social Media Scrapers

- [YouTube Comments Scraper](https://apify.com/haketa/youtube-comments-scraper) — Extract comments, timestamps, author details, and replies from YouTube videos.
- [YouTube Channel Contact Scraper](https://apify.com/haketa/youtube-contact-scraper) — Extract business emails, social links, and channel metrics from YouTube creators.
- [Patreon Scraper](https://apify.com/haketa/patreon-scraper) — Extract creator profiles, membership tiers, patron counts, and community posts.
- [WeChat Official Account Scraper](https://apify.com/haketa/wechat-official-account-scraper) — Extract public articles and engagement metrics from WeChat accounts.

***

### 📋 Changelog

#### v1.2.0 (2026-11)

- **Deep Pagination Enhancement**: Unlocked 1,000+ comment pagination with expanded session thresholds and unlimited (`maxComments: 0`) support.
- **Enhanced Deduplication**: Implemented global cross-post deduplication engine to eliminate recirculated comment leaks.
- **Field Normalization**: Standardized `authorUrl`, `likeCount`, and ISO timestamp parsers for consistent downstream analytics.
- **Optimized Prefill Profile**: Tuned default input parameters to guarantee rapid `< 60s` prefill verification runs.

#### v1.1.0 (2026-10)

- Added dynamic `doc_id` resolution from live Facebook JS bundles to survive Meta script rotations.
- Introduced `commentsSort` selector for unfiltered, ranked, and recent comment ordering.
- Added optional `loginCookie` support for enterprise deep-thread harvesting.

#### v1.0.0 (2026-09)

- Initial public release of Facebook Comments Scraper with pure HTTP architecture and residential proxy integration.

# Changelog

This Actor's version history is a separate document: https://apify.com/haketa/facebook-comments-scraper/changelog.md

# Actor input Schema

## `postUrls` (type: `array`):

Public Facebook post URLs, e.g. <b>https://www.facebook.com/{page}/posts/{id}</b> or a <b>permalink/story</b> URL. Each post is scraped separately. Leave empty to run a demo on a public CNN post.

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

Maximum comments to collect per post (set 0 for unlimited). The actor pages through the comments until it reaches this number or Facebook runs out of logged-out comments for the post.

## `includeReplies` (type: `boolean`):

Include replies to comments (depth > 0), not just top-level comments.

## `commentsSort` (type: `string`):

How Facebook ranks the comments it returns. <b>Most relevant</b> (default), <b>All comments</b> (unfiltered), <b>Newest</b> or <b>Top-level only</b>.

## `loginCookie` (type: `string`):

Optional. Paste your own Facebook <b>Cookie</b> header (DevTools → Network → any facebook.com request → Cookie) to fetch posts with your session. Leave empty to run logged out. Treat it like a password.

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

<b>Residential proxy is required</b> — Facebook blocks datacenter IPs for this data. Defaults to Apify Residential (US).

## Actor input object example

```json
{
  "postUrls": [
    "https://www.facebook.com/cnn/posts/pfbid0V91q399yAUSE5EAUQapwc9CHzPRKZ2wsjnh8a48xbfUobU16RK3BNoo8jK2yaRK2l"
  ],
  "maxComments": 50,
  "includeReplies": true,
  "commentsSort": "RANKED_UNFILTERED",
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ],
    "apifyProxyCountry": "US"
  }
}
```

# Actor output Schema

## `datasetItems` (type: `string`):

All extracted comments for this run.

## `overviewTable` (type: `string`):

A clean table view of the comments.

# 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 = {
    "postUrls": [
        "https://www.facebook.com/cnn/posts/pfbid0V91q399yAUSE5EAUQapwc9CHzPRKZ2wsjnh8a48xbfUobU16RK3BNoo8jK2yaRK2l"
    ],
    "maxComments": 50,
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ],
        "apifyProxyCountry": "US"
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("haketa/facebook-comments-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 = {
    "postUrls": ["https://www.facebook.com/cnn/posts/pfbid0V91q399yAUSE5EAUQapwc9CHzPRKZ2wsjnh8a48xbfUobU16RK3BNoo8jK2yaRK2l"],
    "maxComments": 50,
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
        "apifyProxyCountry": "US",
    },
}

# Run the Actor and wait for it to finish
run = client.actor("haketa/facebook-comments-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 '{
  "postUrls": [
    "https://www.facebook.com/cnn/posts/pfbid0V91q399yAUSE5EAUQapwc9CHzPRKZ2wsjnh8a48xbfUobU16RK3BNoo8jK2yaRK2l"
  ],
  "maxComments": 50,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ],
    "apifyProxyCountry": "US"
  }
}' |
apify call haketa/facebook-comments-scraper --silent --output-dataset

```

## MCP server setup

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