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

Facebook comments scraper for public Page posts: comment text, reactions, reply count, language and time, optional replies and newest-first order. No login. Monitor mode returns only new comments. No commenter names, profiles, avatars or ids are collected.

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

## Pricing

from $1.36 / 1,000 result items

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
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

Facebook Comments Scraper reads the comments under public posts of Facebook business Pages and returns one row per comment with its text, reaction count, reply count, language and posting time. You do not need a Facebook account, cookies or an API key, and nothing about the people who wrote the comments is collected.

**Try it:** the prefilled example returns 20 rows in about 11 seconds and costs about $0.03. Results cost $1.70 per 1,000.

### What you get

Real rows from the example dataset:

| text | reactionCount | replyCount | language | createdAt | isReply |
|---|---|---|---|---|---|
| "Alright aliens, Don't even think about invading Earth" | `322` | `6` | `en` | `2026-10-30` | `false` |
| "Sắp có VinX đối trọng SpaceX trong tương lai" | `295` | `0` | `vi` | `2026-10-30` | `false` |
| "Bro, can those shoes be put in the water?" | `20` | `0` | `en` | `2025-12-06` | `false` |

Full row: `id`, `commentId`, `url`, `postUrl`, `postId`, `text`, `mentionCount`, `createdAt`, `reactionCount`, `replyCount`, `isReply`, `parentCommentId`, `depth`, `language`, `hasAttachment`, `postCommentCount`, `postReactionCount`, `query`, `scrapedAt`.

**No commenter data, ever.** Facebook sends the name, profile link and photo of every commenter. The actor never copies any of it into a row, so there is no commenter name, id, profile URL or avatar anywhere in the output. People named inside a comment are masked too: tagged profiles, the name Facebook puts at the start of a reply, a comment that is only a friend's name and every `@name` become `@user`, and e-mail addresses and phone numbers are removed from the text.

### Related actors

- [Facebook Pages Search](https://apify.com/datahamster/facebook-pages-search) finds business Pages by keyword, with their public contacts and follower counts.
- [Facebook Groups Search](https://apify.com/datahamster/facebook-groups-search) finds public groups by keyword with member counts.
- [Facebook Reels Scraper](https://apify.com/datahamster/facebook-reels-videos) gives view and reaction counts of a Page's reels.
- [YouTube Comments Scraper](https://apify.com/datahamster/youtube-comments) returns the same text and counters for YouTube videos.

### Use cases

- Read what people say under your own Page's posts or a competitor's, as a spreadsheet.
- Feed comment text into sentiment analysis, topic clustering or a moderation queue.
- Get an alert with every new comment under a campaign post (monitor mode).

### Monitor mode

Save the input as a task, set **Mode** to `monitor`, set **Order** to `Newest first` and put it on a schedule (for example every hour). Each run returns only comments whose id was not seen before. Reaction changes on old comments do not count as new. If Facebook refuses the newest-first order for a post, that post returns no rows in that run (the actor does not fall back to "most relevant", which would hide new comments) and the log says so.

### Input

| Field | Meaning | Default |
|---|---|---|
| `postUrls` | Links to public Page posts (`https://www.facebook.com/<page>/posts/<id>`, `permalink.php?story_fbid=...&id=...`, Page reels) | two example posts |
| `maxCommentsPerPost` | Stop reading one post after this many comments, replies included | `100` |
| `sortBy` | `relevant` (Facebook's default view), `newest` or `all` | `relevant` |
| `includeReplies` | Also read the replies under each comment | `false` |
| `maxItems` | Stop the whole run after this many comment rows | `20` |
| `mode` | `scrape` or `monitor` (only new comments) | `scrape` |
| `monitorStateId`, `webhookUrl`, `telegramBotToken`, `telegramChatId` | Monitor state key and alert targets | empty |

### Pricing

| Event | Price |
|---|---|
| result | $0.0017 per comment ($1.70 per 1,000) |
| monitor-check | $0.005 per monitor run |
| change | $0.0017 per new comment in monitor mode |

Apify Store discounts: SILVER -10%, GOLD and higher -20% on every event.

You pay only for comment rows that are pushed. A removed post, a private post or a post of a personal profile produces no rows and no charge. Proxy traffic (Apify datacenter proxy) is billed by Apify on top.

**Found it useful?** A short review on the Store page helps other people find this actor and tells us what to improve. If something is wrong, open an issue on the actor page.

### How it works

1. Each link is opened once as a logged-out visitor. The post page already holds the first comments, about 10.
2. The next comments come from the same comment list Facebook's web page loads when you click "View more comments", 10 per request, until your limit or the end of the list.
3. With **Include replies** on, the replies under each comment are read the same way, right after their comment.
4. A post that answers with a login page is retried once. When every post of a run is walled, the run stops with a "blocked" reason instead of returning an empty dataset.

### Limits

- **Business Pages only.** Links to personal profiles (`profile.php`, `/people/`), groups and posts of personal profiles are skipped with a note in the log.
- **Facebook's order and filtering.** "Most relevant" is the order a visitor sees first, and Facebook leaves out some comments in it: a post showing 31 comments served 18 in our test. Use `all` or `newest` for an unfiltered list.
- **Reaction counts of 1,000 and more are rounded** by Facebook ("1.2K" becomes 1200).
- **Mentions are masked.** Every tagged person, reply name and `@name` is replaced with `@user`, and so is a comment that is nothing but a two or three word name (people tag friends that way). `mentionCount` says how many there were. Tagged Pages, hashtags and links stay.
- **Facebook changes its internal request ids from time to time.** The actor reads the new ones from Facebook's own scripts; if that fails, a run returns only the first ~10 comments of each post and says so in the log.

### FAQ

**Do I need a Facebook account?** No. Every request is made as a logged-out visitor.

**Why is there no commenter name or profile?** By design. The actor collects comment content and counters only, never the identity of the people who wrote them.

**Can I scrape comments of a personal profile or a group?** No. Only posts of business Pages are read.

### Changelog

- 0.1: first release with comment text, reactions, reply count, language, optional replies, three sort orders and a monitor mode for new comments.

# Actor input Schema

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

Links to public posts of Facebook business Pages, such as https://www.facebook.com/NASA/posts/pfbid02hw... or https://www.facebook.com/permalink.php?story_fbid=...\&id=..., one per line. Personal profiles and groups are not supported.

## `maxCommentsPerPost` (type: `integer`):

Stop reading one post after this many comments (replies included), e.g. 100.

## `sortBy` (type: `string`):

Comment order. 'Most relevant' is what a visitor sees first and Facebook may filter some comments out; 'Newest first' is best for monitoring; 'All comments' is unfiltered.

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

Also read the replies under each comment (one extra request per comment that has replies). Replies count toward the per-post limit.

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

Stop after this many comment rows (you are charged only for pushed rows)

## `mode` (type: `string`):

scrape = full results; monitor = only new/changed items since the previous run of this task

## `monitorStateId` (type: `string`):

Optional state id when not running as a saved task (monitor mode)

## `webhookUrl` (type: `string`):

POST a change summary here in monitor mode

## `telegramBotToken` (type: `string`):

Optional: bot token for monitor-mode change summaries

## `telegramChatId` (type: `string`):

Optional: chat id that receives monitor-mode summaries

## Actor input object example

```json
{
  "postUrls": [
    "https://www.facebook.com/NASA/posts/pfbid02hwYX8jh1hsV5ZbU2uVKQvqvyT74Dp9MxXVA6qyobt9nzEdhWEpK5KfNfW8mDDTYLl",
    "https://www.facebook.com/nike/posts/1393461115481927"
  ],
  "maxCommentsPerPost": 10,
  "sortBy": "relevant",
  "includeReplies": false,
  "maxItems": 20,
  "mode": "scrape"
}
```

# Actor output Schema

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

All pushed rows (dataset, JSON)

## `resultsTable` (type: `string`):

Dataset in the Console viewer

## `runSummary` (type: `string`):

RUN_SUMMARY record

# 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/NASA/posts/pfbid02hwYX8jh1hsV5ZbU2uVKQvqvyT74Dp9MxXVA6qyobt9nzEdhWEpK5KfNfW8mDDTYLl",
        "https://www.facebook.com/nike/posts/1393461115481927"
    ],
    "maxCommentsPerPost": 10,
    "maxItems": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("datahamster/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/NASA/posts/pfbid02hwYX8jh1hsV5ZbU2uVKQvqvyT74Dp9MxXVA6qyobt9nzEdhWEpK5KfNfW8mDDTYLl",
        "https://www.facebook.com/nike/posts/1393461115481927",
    ],
    "maxCommentsPerPost": 10,
    "maxItems": 20,
}

# Run the Actor and wait for it to finish
run = client.actor("datahamster/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/NASA/posts/pfbid02hwYX8jh1hsV5ZbU2uVKQvqvyT74Dp9MxXVA6qyobt9nzEdhWEpK5KfNfW8mDDTYLl",
    "https://www.facebook.com/nike/posts/1393461115481927"
  ],
  "maxCommentsPerPost": 10,
  "maxItems": 20
}' |
apify call datahamster/facebook-comments-scraper --silent --output-dataset

```

## MCP server setup

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