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

Scrape comments and replies from public Facebook posts, reels and videos. Replies stay nested under their comment, just like on Facebook. Sorting, date filter, reply limits. No login needed.

- **URL**: https://apify.com/calm_builder/facebook-comments-scraper.md
- **Developed by:** [Coder](https://apify.com/calm_builder) (community)
- **Categories:** Automation, Social media, Developer tools
- **Features:** Limited permissions
- **Stats:** 70 total users, 4 monthly users, 100.0% runs succeeded, 2 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.35 / 1,000 comments

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

Collect the comments of public Facebook posts, reels and videos - with replies **nested under the
comment they answer, exactly like on Facebook**. No login, no cookies, no browser.

### Why this one

- **Readable threads.** One row per post. Each comment has its `replies`, and each reply has its own
  `replies` (replies to replies). No flat "type: reply" rows to stitch back together.
- **Clear limits.** Set comments per post and replies per level: 5 comments with 2 per level gives
  each comment up to 2 replies, and each of those up to 2 replies of its own.
- **Reels and videos too** - including reel comments Facebook hides from logged-out visitors.
- **Post data on request.** Add the post itself (author, text, date, reactions by type, comment and
  share counts, media) to each row.

### Input

| Field | What it does |
|---|---|
| Facebook post links | Post, reel, video and group post links (pfbid links work) |
| Comments per post | Top-level comments per post (default 10) |
| Comment order | All comments (widest set), Most relevant, Newest first |
| Only comments newer than | A date or a period like `7 days`; comments are then read newest first |
| Include replies | Nest replies under their comments |
| Reply depth | Replies, or replies and replies to replies |
| Replies per level | Replies kept under each comment and each reply (default 2) |
| Include post data | Add the post's own fields to each row |

Input names from other Facebook comment scrapers also work (`startUrls`, `postUrls`, `resultsLimit`,
`includeNestedComments`, `viewOption`, `onlyCommentsNewerThan`, `commentsDateRange`, ...).

### Output

```json
{
  "inputUrl": "https://www.facebook.com/NASA/posts/1637283811100322",
  "postUrl": "https://www.facebook.com/NASA/posts/pfbid0G298eA3...",
  "postId": "1637283811100322",
  "commentsCollected": 5,
  "repliesCollected": 6,
  "sortedBy": "all",
  "comments": [
    {
      "commentId": "1621614019364769",
      "commentUrl": "https://www.facebook.com/...?comment_id=1621614019364769",
      "depth": 0,
      "text": "The weapons in space should be given over...",
      "createdAt": "2026-09-28T14:02:11Z",
      "authorName": "...",
      "authorUrl": "https://www.facebook.com/...",
      "reactions": 12,
      "replyCount": 3,
      "replies": [
        {
          "commentId": "4473153959589875",
          "depth": 1,
          "text": "There's a reason we have...",
          "replies": [
            { "commentId": "4586229838289508", "depth": 2, "text": "USSF. Only really covers...", "replies": [] }
          ]
        }
      ]
    }
  ]
}
```

Each comment and reply has: `commentId`, `commentUrl`, `depth`, `text`, `createdAt`, `authorName`,
`authorId`, `authorUrl`, `authorVerified`, `isTopFan`, `reactions` (total and by type), `replyCount`,
`mentions`, `imageUrls`, `language`, `replies`.

Like on Facebook, threads go two reply levels deep. When someone answers a reply-to-a-reply, Facebook
shows the answer beside it; so does the Actor, with `replyToCommentId` naming the reply it answers.

With **Include post data** on, each row also carries the post fields (`authorName`, `text`,
`publishedAt`, `reactions` by type, `commentCount`, `shares`, `views`, media, ...).

A post with a very large number of comments is split into several rows (`part` 1 of `parts`) so
no row passes Apify's item size limit. Threads are never cut between parts.

### Good to know

- **Fewer comments than the post's count?** Facebook hides some comments from public view (spam
  filtering, "View hidden replies"), and serves replies of long threads in small batches - a thread
  showing "12 replies" may give only a few, even to logged-in users. The Actor collects everything
  Facebook serves.
- Private posts and posts that no longer exist are listed in the log and not charged.

### Pricing

Pay per result: each comment or reply is one `comment` event; post data (when turned on) is one
`post` event per post. The free plan can try every option, with up to 3 links, 10 comments per post
and 3 replies per level.

### Related Actors

- [Facebook Posts Scraper](https://apify.com/calm_builder/facebook-posts-scraper) - posts from pages, profiles and groups
- [Facebook Pages Scraper](https://apify.com/calm_builder/facebook-pages-scraper) - page details, contact info, posts

# Actor input Schema

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

Public post, reel or video links, including group posts. You can also upload a file of links.

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

Maximum number of comments collected from each post. Replies are counted separately (below).

## `commentsSortBy` (type: `string`):

Which comments come first. 'All comments' returns the widest set Facebook shows.

## `onlyCommentsNewerThan` (type: `string`):

Pick a date, or a period back from now (for example 7 days). Comments are then read newest first. Leave empty for no limit.

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

Also collect replies to comments. Facebook shows only some replies of long threads, even to logged-in users.

## `replyDepth` (type: `string`):

Replies only, or replies and the replies to those replies.

## `maxRepliesPerLevel` (type: `integer`):

Maximum replies kept under each comment, and under each reply when replies to replies are on. Example: 5 comments and 2 per level = each comment with up to 2 replies, each reply with up to 2 of its own.

## `includePostData` (type: `boolean`):

Add the post itself to each row: author, text, date, reactions by type, comment and share counts, media (charged per post).

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://www.facebook.com/NASA/posts/1637283811100322"
    }
  ],
  "maxComments": 10,
  "commentsSortBy": "all",
  "includeReplies": false,
  "replyDepth": "1",
  "maxRepliesPerLevel": 2,
  "includePostData": false
}
```

# Actor output Schema

## `comments` (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 = {
    "startUrls": [
        {
            "url": "https://www.facebook.com/NASA/posts/1637283811100322"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("calm_builder/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 = { "startUrls": [{ "url": "https://www.facebook.com/NASA/posts/1637283811100322" }] }

# Run the Actor and wait for it to finish
run = client.actor("calm_builder/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 '{
  "startUrls": [
    {
      "url": "https://www.facebook.com/NASA/posts/1637283811100322"
    }
  ]
}' |
apify call calm_builder/facebook-comments-scraper --silent --output-dataset

```

## MCP server setup

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