# Facebook Comments Scraper (`api-ninja/facebook-comments-scraper`) Actor

💬 Scrapes Facebook post comments and nested replies from post URLs or IDs.

- **URL**: https://apify.com/api-ninja/facebook-comments-scraper.md
- **Developed by:** [API ninja](https://apify.com/api-ninja) (community)
- **Categories:** Social media, Developer tools
- **Stats:** 183 total users, 70 monthly users, 98.3% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.25 / 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?

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

### What does Facebook Comments Scraper do?

**Facebook Comments Scraper** extracts **Facebook post comments and nested replies** from public Facebook post URLs or post IDs. It is built for users who want a simple way to collect structured Facebook discussion data without building their own scraping workflow.

You can use it with direct post IDs, standard post URLs, and common Facebook group post links from [Facebook](https://www.facebook.com/). The Actor collects top-level comments, can optionally crawl reply threads, and returns the results as a clean dataset you can inspect in Apify Console or access through API.

Because it runs on **Apify**, you also get scheduling, monitoring, run logs, dataset export, API access, integrations, and scalable cloud execution in one workflow.

### Why use Facebook Comments Scraper?

Facebook comments often contain the most valuable signal around a post: opinions, objections, sentiment, FAQs, demand signals, and community engagement. This Actor helps you turn that unstructured discussion into data you can analyze.

Typical use cases:

- Track audience sentiment under brand or media posts
- Monitor comments in Facebook groups for research or lead discovery
- Collect public feedback around product launches, campaigns, or announcements
- Analyze reply threads and conversation depth
- Export comment datasets for AI pipelines, spreadsheets, or BI tools

This Actor is designed for both no-code users and developers. Non-technical users can run it from the Apify UI. Developers can trigger runs and download results programmatically through the Apify API.

### What can this Facebook scraper do?

- Accept **Facebook post URLs or raw post IDs**
- Parse common Facebook post URL formats automatically
- Scrape **top-level comments**
- Optionally scrape **nested replies**
- Paginate through comments until your requested limit is reached
- Scrape all available comments when full crawl mode is enabled
- Return structured data ready for export as **JSON, CSV, Excel, XML, or HTML**
- Run in the cloud with Apify scheduling, monitoring, and integrations

### What data can this Actor extract from Facebook comments?

The Actor stores raw comment objects and makes the most important fields visible in the dataset table.

| Field | Description |
| --- | --- |
| `legacy_comment_id` | Human-readable comment ID |
| `comment_id` | Internal comment token |
| `message` | Comment text |
| `depth` | Comment depth in the thread |
| `parent_comment_id` | Parent comment identifier for replies |
| `created_time` | Unix timestamp of comment creation |
| `author.name` | Comment author name |
| `author.id` | Author identifier |
| `author.url` | Author profile URL when available |
| `author.profile_image` | Author avatar image |
| `replies_count` | Number of replies reported for the comment |
| `reactions_count` | Number of reactions |
| `is_sticker` | Whether the comment contains a sticker |
| `sticker.*` | Sticker metadata when present |
| `is_gif` | Whether the comment contains a GIF |
| `gif`, `image`, `video` | Media payloads when present |

### How to scrape Facebook comments

Using the Actor is straightforward:

1. Open **Facebook Comments Scraper** on Apify.
2. In the **Input** tab, add one or more Facebook post URLs or raw post IDs.
3. Set how many top-level comments you want per post, or enable **Scrape All Comments**.
4. Turn on **Scrape Comment Replies** if you also want nested reply threads.
5. Start the run and wait for the dataset to be generated.
6. Open the **Output** tab to inspect results, or export the dataset in your preferred format.

This makes it suitable for one-off data collection as well as recurring monitoring jobs.

### Input

Facebook Comments Scraper accepts these main input options in the **Input** tab:

- `searchUrls`: A list of Facebook post URLs or raw post IDs
- `commentsPerUrl`: Maximum number of top-level comments to collect per post
- `scrapeAll`: Ignore the comment limit and continue until pagination ends
- `parseReplies`: Also scrape nested replies when available

Example input:

```json
{
  "searchUrls": [
    "https://www.facebook.com/humansofnewyork/posts/pfbid0BbKbkisExKGSKuhee9a7i86RwRuMKFC8NSkKStB7CsM3uXJuAAfZLrkcJMXxhH4Yl",
    "https://www.facebook.com/groups/834204990043792/?multi_permalinks=3830165153781079&hoisted_section_header_type=recently_seen",
    "3830165153781079"
  ],
  "commentsPerUrl": 100,
  "scrapeAll": false,
  "parseReplies": true
}
```

### Output

The Actor returns one dataset item per Facebook comment or reply. You can download the dataset in various formats such as **JSON, HTML, CSV, or Excel**.

Example output:

```json
[
  {
    "type": "comment",
    "comment_id": "Y29tbWVudDozODMwMTY1MTUzNzgxMDc5XzM4MzAzODg1MzcwOTIwNzQ=",
    "legacy_comment_id": "3830388537092074",
    "depth": 0,
    "parent_comment_id": null,
    "created_time": 1779536152,
    "message": "Sample top-level comment",
    "author": {
      "id": "100038997153874",
      "name": "Svitlana Butok",
      "gender": "FEMALE",
      "url": "https://www.facebook.com/svitlana.zhirnova",
      "profile_image": "https://example.com/avatar.jpg"
    },
    "replies_count": 2,
    "reactions_count": "1",
    "expansion_token": "token-value",
    "is_sticker": false,
    "sticker": null,
    "is_gif": false,
    "gif": null,
    "image": null,
    "video": null
  }
]
```

### How much does it cost to scrape Facebook comments?

The exact cost depends on how many posts you process, how many comments each post contains, and whether you enable reply scraping. In general, limiting `commentsPerUrl` is the easiest way to keep runs small and predictable.

For lightweight monitoring, start with a small comment limit and only enable full crawling for posts that matter. If you need large-scale recurring collection, Apify makes that easier with scheduling, monitoring, API access, and export options for downstream automation.

### Tips for better results

- Start with a few post URLs first to verify the format and expected output
- Use `commentsPerUrl` for quick sampling and cheaper test runs
- Enable `scrapeAll` only when you really need the full thread
- Enable `parseReplies` only when reply context matters, because it increases run size
- Use the dataset table in Apify Console to quickly inspect author, message, reactions, and thread depth

### Related Facebook Actors

If you also need other Facebook data, see these related Actors:

- [Facebook Posts Scraper](https://apify.com/api-ninja/facebook-posts-scraper)
- [Facebook Pages Scraper](https://apify.com/api-ninja/facebook-pages-scraper)
- [Facebook Groups Scraper](https://apify.com/api-ninja/facebook-groups-scraper)

These Actors work well together if you want to discover Facebook entities first and then collect comments from the posts that matter most.

### FAQ, disclaimers, and support

#### Is it legal to scrape Facebook comments?

This Actor is intended for scraping publicly accessible data. You are responsible for making sure your usage complies with applicable laws, platform terms, and privacy regulations in your jurisdiction. Do not use scraped data in ways that violate privacy, data protection, or other legal requirements.

#### Does this Actor scrape private Facebook comments?

No. The Actor is intended for public or otherwise accessible content only. If a post or comment thread is not available to the scraper, it cannot be extracted.

#### Why are some replies missing?

Reply availability depends on the structure of the thread and whether the data source exposes nested replies for that comment. The Actor follows available nested reply expansions, but inaccessible or unavailable thread branches cannot be recovered.

#### Where can I get help?

Use the **Issues** tab on the Actor page if you find a bug or want to request an improvement. If you need a custom Facebook data workflow, a specialized export format, or integration into your own system, custom work can be built on top of this Actor.

# Actor input Schema

## `searchUrls` (type: `array`):

Provide one or more Facebook post URLs or raw post IDs. Each entry is processed independently. Examples: `https://www.facebook.com/humansofnewyork/posts/pfbid0BbKbkisExKGSKuhee9a7i86RwRuMKFC8NSkKStB7CsM3uXJuAAfZLrkcJMXxhH4Yl`, `pfbid0BbKbkisExKGSKuhee9a7i86RwRuMKFC8NSkKStB7CsM3uXJuAAfZLrkcJMXxhH4Yl`.

## `commentsPerUrl` (type: `integer`):

Maximum number of top-level comments to collect from each post when full crawl mode is disabled.

## `scrapeAll` (type: `boolean`):

When enabled, collects all available top-level comments for each post and ignores the comment limit above.

## `parseReplies` (type: `boolean`):

When enabled, collects every available nested reply for each fetched top-level comment that has replies.

## Actor input object example

```json
{
  "searchUrls": [
    "https://www.facebook.com/humansofnewyork/posts/pfbid0BbKbkisExKGSKuhee9a7i86RwRuMKFC8NSkKStB7CsM3uXJuAAfZLrkcJMXxhH4Yl",
    "pfbid0BbKbkisExKGSKuhee9a7i86RwRuMKFC8NSkKStB7CsM3uXJuAAfZLrkcJMXxhH4Yl",
    "https://www.facebook.com/groups/834204990043792/?multi_permalinks=3830165153781079&hoisted_section_header_type=recently_seen",
    "3830165153781079"
  ],
  "commentsPerUrl": 100,
  "scrapeAll": false,
  "parseReplies": false
}
```

# Actor output Schema

## `dataset` (type: `string`):

No description

## `run` (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 = {
    "searchUrls": [
        "https://www.facebook.com/humansofnewyork/posts/pfbid0BbKbkisExKGSKuhee9a7i86RwRuMKFC8NSkKStB7CsM3uXJuAAfZLrkcJMXxhH4Yl",
        "pfbid0BbKbkisExKGSKuhee9a7i86RwRuMKFC8NSkKStB7CsM3uXJuAAfZLrkcJMXxhH4Yl",
        "https://www.facebook.com/groups/834204990043792/?multi_permalinks=3830165153781079&hoisted_section_header_type=recently_seen",
        "3830165153781079"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("api-ninja/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 = { "searchUrls": [
        "https://www.facebook.com/humansofnewyork/posts/pfbid0BbKbkisExKGSKuhee9a7i86RwRuMKFC8NSkKStB7CsM3uXJuAAfZLrkcJMXxhH4Yl",
        "pfbid0BbKbkisExKGSKuhee9a7i86RwRuMKFC8NSkKStB7CsM3uXJuAAfZLrkcJMXxhH4Yl",
        "https://www.facebook.com/groups/834204990043792/?multi_permalinks=3830165153781079&hoisted_section_header_type=recently_seen",
        "3830165153781079",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("api-ninja/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 '{
  "searchUrls": [
    "https://www.facebook.com/humansofnewyork/posts/pfbid0BbKbkisExKGSKuhee9a7i86RwRuMKFC8NSkKStB7CsM3uXJuAAfZLrkcJMXxhH4Yl",
    "pfbid0BbKbkisExKGSKuhee9a7i86RwRuMKFC8NSkKStB7CsM3uXJuAAfZLrkcJMXxhH4Yl",
    "https://www.facebook.com/groups/834204990043792/?multi_permalinks=3830165153781079&hoisted_section_header_type=recently_seen",
    "3830165153781079"
  ]
}' |
apify call api-ninja/facebook-comments-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,api-ninja/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/cQFZ5f1UUmToFdFei/builds/Ry8VcbtxXZDP4q0ew/openapi.json
