# Facebook Post Comments Scraper (`maximedupre/facebook-post-comments-scraper`) Actor

Get public comments from Facebook posts, reels, videos, Pages, and groups. Each row has the comment text, author, time, reactions, and replies, plus the parent post for context. No Facebook login is needed.

- **URL**: https://apify.com/maximedupre/facebook-post-comments-scraper.md
- **Developed by:** [Maxime Dupré](https://apify.com/maximedupre) (community)
- **Categories:** Social media, Marketing, Business
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 61.5% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.65 / 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.

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

### 💬 Read what people say under any public Facebook post

Facebook Post Comments Scraper is for marketers, researchers, and community teams who want the real comments under public Facebook posts. Give it post, reel, or video links, post IDs, Page URLs, or group URLs. You get each comment with its text, author, time, reactions, and replies, plus the parent post for context. No Facebook login is needed.

- Export every public comment on a brand post to a spreadsheet for review.
- Track what people say on the latest posts from many Facebook Pages in one run.
- Collect comments from public Facebook groups and filter posts by date or keyword.
- Study replies to see how a talk thread grows under one comment.
- Feed comment text in its original language into sentiment or topic analysis.

#### 📦 What comment data you get

Each dataset row is one public comment. It holds:

- The comment ID, direct link, and text as published
- The author name, ID, profile link, profile image, and Facebook's stated gender, verification, and subscription status, when available
- The time the comment was published
- Total reactions and counts by reaction type
- The reply count, and the public replies when you turn them on
- Photos and videos attached to the comment
- Israeli phone numbers written in the comment text
- The parent post: ID, link, text, author, time, reactions, comments, shares, media, and video views
- The public group, when the post is in a group

#### 🚀 How to collect Facebook comments

1. Pick how to find posts in **Find posts by**: Post URLs, Post IDs, Page URLs, or Group URLs.
2. Fill in the fields for that method. Fields for other methods are ignored.
3. Set the comment limits, the comment selection, and whether to include replies.
4. Start the run. Then open or download the comments in JSON, CSV, Excel, or other formats.

#### ⚙️ Input

**Input fields**

| Field | Type | What it does |
| --- | --- | --- |
| `discoveryMethod` | string | Required. How to find posts: `postUrls`, `postIds`, `pageUrls`, or `groupUrls`. The form prefills `postUrls`. |
| `postUrls` | array | Full public Facebook post, reel, or video URLs. Required for `postUrls`. |
| `postIds` | array | Exact Facebook post IDs, one per entry. Required for `postIds`. |
| `pageUrls` | array | Full public Facebook Page URLs. You can submit 100 or more Pages. Required for `pageUrls`. Later runs collect newly found posts and skip posts this Actor already delivered. |
| `pagePostsUntil` | string | For Page URLs, select posts published on or before this date (`YYYY-MM-DD`, UTC). Empty means no end date. |
| `groupUrls` | array | Full public Facebook group URLs. Required for `groupUrls`. Later runs continue to older posts and skip posts this Actor already delivered. |
| `groupPostKeyword` | string | For Group URLs, select posts whose text contains this keyword. Empty means no keyword filter. |
| `groupPostOrder` | string | For Group URLs, Facebook's post order: `newPosts` (default), `recentActivity`, or `topPosts`. |
| `maxPostsPerSource` | integer | For Page URLs and Group URLs, the most posts to select from each Page or group. Empty or 0 means all posts that match the filters. |
| `maxPosts` | integer | For Page URLs and Group URLs, the most posts to select across the run. Empty or 0 means all posts that match the filters. |
| `postsSince` | string | For Page URLs and Group URLs, select posts published on or after this date (`YYYY-MM-DD`, UTC). Empty means no start date. |
| `maxComments` | integer | The most comment rows across all posts. Replies do not count here. Empty or 0 means all available comments within the other limits. The form prefills 20. |
| `maxCommentsPerPost` | integer | The most comment rows from each post. Replies do not count here. Empty or 0 means all available comments from each post. |
| `commentOrder` | string | Facebook's comment selection: `allComments` (default), `newestFirst`, or `topComments`. |
| `includeReplies` | boolean | Save public replies inside each comment row. Default `false`. When off, no replies are collected. |
| `maxRepliesPerComment` | integer | When replies are on, the most replies saved in each comment row. Default 10. Use 0 for all available replies. |

The prefilled values only fill the form. They are not schema defaults, so an API call that leaves out `maxComments` collects all available comments.

**Example input**

```json
{
  "maxComments": 20,
  "discoveryMethod": "postUrls",
  "postUrls": [
    {
      "url": "https://www.facebook.com/100063521621753/posts/1128544229272954"
    }
  ],
  "groupPostOrder": "newPosts",
  "commentOrder": "allComments",
  "includeReplies": false,
  "maxRepliesPerComment": 10
}
```

#### 🧾 Output

**Output fields**

Fields that Facebook does not provide are left out of the row.

| Field | Type | What it does |
| --- | --- | --- |
| `id` | string | The Facebook comment ID. |
| `url` | string | The direct Facebook link to the comment. |
| `text` | string | The comment text as published, in its original language. |
| `author.id` | string | The Facebook author ID. |
| `author.name` | string | The name shown for the author. |
| `author.url` | string | The Facebook profile or Page link. |
| `author.profileImageUrl` | string | The author profile image link. |
| `author.gender` | string | The author gender stated by Facebook. |
| `author.isVerified` | boolean | Whether Facebook marks the author as verified. |
| `author.canSubscribe` | boolean | Whether Facebook says users can subscribe to the author. |
| `publishedAt` | string | The time the comment was published (ISO date-time). |
| `reactionCount` | integer | Total reactions on the comment. |
| `reactions[].type` | string | The reaction name, such as Like or Haha. |
| `reactions[].count` | integer | The count for that reaction type. |
| `replyCount` | integer | The reply count Facebook reports. It can be higher than the replies collected. |
| `photos[].downloadUrl` | string | Link to download a photo attached to the comment. |
| `videos[].downloadUrl` | string | Link to download a video attached to the comment. |
| `videos[].url` | string | The Facebook page for the video. |
| `videos[].previewImageUrl` | string | The video preview image link. |
| `videos[].durationSeconds` | number | The video length in seconds. |
| `phoneNumbers` | array | Israeli phone numbers written in the comment, in international format. |
| `replies[].id` | string | The reply ID. |
| `replies[].url` | string | The direct link to the reply. |
| `replies[].text` | string | The reply text as published. |
| `replies[].author.*` | object | The reply author, with the same fields as `author`. |
| `replies[].publishedAt` | string | The time the reply was published. |
| `replies[].reactionCount` | integer | Total reactions on the reply. |
| `replies[].reactions[]` | array | Reaction `type` and `count` pairs for the reply. |
| `replies[].replyCount` | integer | The reply count Facebook reports for the reply. |
| `replies[].photos[].downloadUrl` | string | Link to download a photo attached to the reply. |
| `replies[].phoneNumbers` | array | Israeli phone numbers written in the reply. |
| `replies[].parentCommentId` | string | The ID of the comment this reply answers. |
| `post.id` | string | The Facebook post ID. Use it to group comments by post. |
| `post.url` | string | The Facebook post link. |
| `post.text` | string | The post text as published. |
| `post.author.*` | object | The post author, with the same fields as `author`. |
| `post.publishedAt` | string | The time the post was published. |
| `post.reactionCount` | integer | Total post reactions. |
| `post.commentCount` | integer | Total post comments Facebook reports. |
| `post.shareCount` | integer | Total post shares. |
| `post.reactions[]` | array | Reaction `type` and `count` pairs for the post. |
| `post.photos[].downloadUrl` | string | Link to download a photo attached to the post. |
| `post.videos[]` | array | Post videos with `downloadUrl`, `url`, `previewImageUrl`, and `durationSeconds`. |
| `post.videoViewCount` | integer | The video view count Facebook reports. |
| `group.id` | string | The Facebook group ID, when the post is in a public group. |
| `group.name` | string | The Facebook group name. |
| `group.url` | string | The Facebook group link. |

**Example comment row**

```json
{
  "id": "1420197262273551",
  "url": "https://www.facebook.com/guglielmomossuto/videos/1634353697501463/?comment_id=1420197262273551",
  "text": "Una donna che dice la verità alla Fiorentina….. Brava purtroppo è la realtà",
  "author": {
    "id": "100000965618892",
    "name": "Enza Mangiagli",
    "profileImageUrl": "https://scontent-dfw6-1.xx.fbcdn.net/v/t39.30808-1/460841850_26872013299080827_5880988803096544563_n.jpg?stp=cp0_dst-jpg_tt6&cstp=mx651x651&ctp=s32x32&_nc_cat=101&ccb=1-7&_nc_sid=1d2534&_nc_ohc=AIGSwU3lbloQ7kNvwGTyA3q&_nc_oc=AdpLlyE8o_Wiz4KBDURaj7IjwMEIR8GdCGsPlM1kvh4aMSRKTF18XUMc18O2frsGTJI&_nc_zt=24&_nc_ht=scontent-dfw6-1.xx&_nc_gid=MtR23AAI8YVQLAxRbveH3w&_nc_ss=70180&oh=00_AQSBgKun9BhyMvBcGLtpDg4_yQ9SuytKWM0tDeKznd2HbA&oe=6AF6C5CC",
    "gender": "FEMALE",
    "isVerified": false,
    "canSubscribe": false
  },
  "publishedAt": "2024-12-06T21:18:26.000Z",
  "replyCount": 1,
  "reactions": [
    {
      "type": "Like",
      "count": 21
    },
    {
      "type": "Care",
      "count": 1
    },
    {
      "type": "Sad",
      "count": 1
    }
  ],
  "reactionCount": 23,
  "replies": [
    {
      "id": "512075341488094",
      "url": "https://www.facebook.com/guglielmomossuto/videos/1634353697501463/?comment_id=1420197262273551&reply_comment_id=512075341488094",
      "text": "Enza Mangiagli signò mi passa a prendere lei da casa? Grazie.",
      "author": {
        "id": "pfbid09KV3s6CmXfpJRTuZxHcraoucoYtGcnkfZ6XHpXih7XoAm3QEqWbdMXjSuWxWyqMDl",
        "name": "Francesco Jeffrey Palazzolo",
        "profileImageUrl": "https://scontent-dfw5-1.xx.fbcdn.net/v/t39.30808-1/327045875_512649000857644_6609305492880835937_n.jpg?stp=cp6_dst-jpg_tt6&cstp=mx2048x2048&ctp=s32x32&_nc_cat=105&ccb=1-7&_nc_sid=e99d92&_nc_ohc=OOTBaf4tgQAQ7kNvwEe9nUA&_nc_oc=AdqEzGRgbkIYqWNcDSFFDETZmnXdlqAg6jI58pokZMAeDBhiP2Eb8lhKBx1qwzRRAY8&_nc_zt=24&_nc_ht=scontent-dfw5-1.xx&_nc_gid=u7m4einbZxaWg09lvjT_dQ&_nc_ss=70180&oh=00_AQRY_z0534i3Ahlxmpqj4n05INbmtT6KzdxkOxrclwFjgQ&oe=6AF6D975",
        "gender": "MALE",
        "isVerified": false,
        "canSubscribe": false
      },
      "publishedAt": "2025-02-12T00:36:28.000Z",
      "replyCount": 0,
      "reactionCount": 0,
      "parentCommentId": "1420197262273551"
    }
  ],
  "post": {
    "id": "1128544229272954",
    "url": "https://www.facebook.com/guglielmomossuto/videos/1634353697501463/",
    "text": "La Tramvia a Firenze !",
    "author": {
      "id": "100063521621753",
      "name": "Guglielmo Mossuto",
      "url": "https://www.facebook.com/guglielmomossuto",
      "profileImageUrl": "https://scontent-dfw6-1.xx.fbcdn.net/v/t39.30808-1/893181527_1756268803167157_3527062355635554002_n.avif?stp=cp0_dst-avif&cstp=mx1080x1064&ctp=s50x50&_nc_cat=101&ccb=1-7&_nc_sid=2d3e12&_nc_ohc=f67x1992HEcQ7kNvwFgSwoQ&_nc_oc=AdoWraOWIkJHWU5fB3pgjhk8b4wHdcwDmrDQ3JSQdx0GGtliMuXVHawN9BfD6hm6Cyg&_nc_zt=24&_nc_ht=scontent-dfw6-1.xx&_nc_gid=Yb0FurPC50Izv05mtjWzDg&_nc_ss=70289&oh=00_AQTX60zGw4Cqyo-Dyxum9c-gpsbiLw_6e9ia-CneaJ2KFQ&oe=6AF6B545",
      "gender": "MALE",
      "isVerified": true,
      "canSubscribe": false
    },
    "publishedAt": "2024-12-06T09:20:50.000Z",
    "reactionCount": 137089,
    "commentCount": 5815,
    "shareCount": 19294,
    "reactions": [
      {
        "type": "Like",
        "count": 114712
      },
      {
        "type": "Haha",
        "count": 20822
      },
      {
        "type": "Love",
        "count": 1135
      },
      {
        "type": "Wow",
        "count": 188
      },
      {
        "type": "Care",
        "count": 175
      },
      {
        "type": "Angry",
        "count": 38
      },
      {
        "type": "Sad",
        "count": 19
      }
    ],
    "videos": [
      {
        "downloadUrl": "https://video-dfw5-1.xx.fbcdn.net/o1/v/t2/f2/m366/AQO82RKsau9SFdM2_WvxnmkTWCx2kyCI8Lky-sChkQnj6hKpils8oRnu0xW5H-aDQw-4N08a5BqHUoaVNurp1ffWLsCHatEpX5qTZSdWCGZkHw.mp4?_nc_cat=111&_nc_sid=5e9851&_nc_ht=video-dfw5-1.xx.fbcdn.net&_nc_ohc=YTXVhG1tOOUQ7kNvwE5C3dv&efg=eyJ2ZW5jb2RlX3RhZyI6Inhwdl9wcm9ncmVzc2l2ZS5GQUNFQk9PSy4uQzMuNTc2LmRhc2hfaDI2NC1iYXNpYy1nZW4yXzcyMHAiLCJ4cHZfYXNzZXRfaWQiOjEwOTY4MDU1NDUwODY1NTksImFzc2V0X2FnZV9kYXlzIjo3MDIsInZpX3VzZWNhc2VfaWQiOjEwMTIyLCJkdXJhdGlvbl9zIjoyMiwidXJsZ2VuX3NvdXJjZSI6Ind3dyJ9&ccb=17-1&vs=a66b63e2d389ec06&_nc_vs=HBksFQIYRWZiX2VwaGVtZXJhbC9GNzQ3MDQ1QUNDNTVGOTJFNEY1NzAyMEM0QUVFNzk5OF9tdF8xX3ZpZGVvX2Rhc2hpbml0Lm1wNBUAAsgBEgAVAhg0ZmJfcGVybWFuZW50Lzk0MTM5NTk2MDY1ODM2Ml8yNzIyNTkyMTY0ODE0MDQ1NTMzLm1wNBUCAsgBEgAoABgAGwKIB3VzZV9vaWwBMRJwcm9ncmVzc2l2ZV9yZWNpcGUBMRUAACa-ubiOvuLyAxUCKAJDMywXQDYzMzMzMzMYGWRhc2hfaDI2NC1iYXNpYy1nZW4yXzcyMHARAHUCZZSeAQA&_nc_gid=Yb0FurPC50Izv05mtjWzDg&_nc_ss=70289&_nc_zt=28&oh=00_AQR-3o72ZGM39G8ixzG91zyxAhJF8Ss82_KfU-TTgEFoVA&oe=6AF6C071&bitrate=976672&tag=dash_h264-basic-gen2_720p",
        "url": "https://www.facebook.com/guglielmomossuto/videos/1634353697501463/",
        "previewImageUrl": "https://scontent-dfw5-1.xx.fbcdn.net/v/t15.5256-10/894516813_1606612030772572_904148815877503351_n.avif?stp=dst-jpg_tt6&cstp=mx576x1024&ctp=s960x960&_nc_cat=111&ccb=1-7&_nc_sid=50ce42&_nc_ohc=xh49RPZLzwsQ7kNvwGIgwBs&_nc_oc=AdrorxelLVkm3a-hatLPjmajJPXYmId0XHcHEGzunEy4pe3smEbhS70Wt9kmVuktT1Y&_nc_zt=23&_nc_ht=scontent-dfw5-1.xx&_nc_gid=Yb0FurPC50Izv05mtjWzDg&_nc_ss=70289&oh=00_AQT5JD0Vtr6I3la4omSW0nhOWosjzpwohTCOJvu6d-Lkkg&oe=6AF6DBC9",
        "durationSeconds": 22.265
      }
    ],
    "videoViewCount": 5288239
  }
}
```

#### 💳 Pricing

This Actor uses pay-per-event pricing. You pay only for what is saved:

| Event | Price | When it is charged |
| --- | --- | --- |
| Comment | $0.00265 ($2.65 per 1,000) | One public comment saved to your dataset, with its post details. |
| Reply | $0.0005 ($0.50 per 1,000) | One public reply saved inside its parent comment row. |

Replies are charged only when **Include replies** is on. Use the comment, post, and reply limits to control the cost of a run. A run that saves no comments has no comment or reply charges.

#### 🔌 Integrations

You can connect this Actor to Make, Zapier, Google Sheets, Slack, webhooks, and other tools through the Apify platform. You can also start runs and read the dataset with the Apify API. This video shows how integrations work:

https://www.youtube.com/watch?v=bNACk1_S_6w\&list=PLObrtcm1Kw6MUrlLNDbK9QRg8VDJg0gOW\&index=4

#### ❓ FAQ

##### Do I need a Facebook account, cookies, or a Meta Graph API token?

No. The Actor reads public Facebook posts without a login, cookies, or Graph API access. It cannot read private posts or groups you must join to see.

##### Are replies to comments included?

Only when you turn on **Include replies**. Replies are saved inside their comment row, and each reply has `parentCommentId` so you can see which comment it answers. Use **Maximum replies per comment** to set how many to keep.

##### Why is `replyCount` higher than the number of replies I got?

`replyCount` is the number Facebook reports. Some replies can be hidden, deleted, or private, and your reply limit can also stop collection early.

##### Can I get comments from reels and videos?

Yes. Add the reel or video URL under **Post URLs**, the same way as a normal post link.

##### What happens when I run the same Pages or groups again?

For Page URLs, later runs collect newly found posts and skip posts this Actor already delivered. For Group URLs, later runs continue to older posts and skip posts already delivered.

##### Which comments are collected first?

That depends on **Comment selection**. All comments selects available public comments, Newest first starts with the newest, and Top comments uses Facebook's ranking.

##### Why does the `phoneNumbers` field only show Israeli numbers?

The Actor looks for Israeli phone numbers written in the comment text and saves them in international format. Other numbers are not added to this field, but they stay in the comment `text`.

##### Can I download the data as CSV or Excel?

Yes. Open the run's dataset and export it as JSON, CSV, Excel, XML, or other formats.

### 📝 Changelog

**v0.0** (08-11-2026)

- Initial release.

### 🆘 Support

For issues, questions, or feature requests, [file a ticket](https://console.apify.com/actors/maximedupre~facebook-post-comments-scraper/issues) and I'll fix or implement it in less than 24h 🫡

### 🔗 Related Actors

- [Facebook Reactions Scraper](https://apify.com/maximedupre/facebook-reactions-scraper): see who reacted to the same public posts and how.
- [Facebook User Posts Scraper](https://apify.com/maximedupre/facebook-user-posts-scraper): collect the posts from profiles and Pages before you read their comments.
- [Facebook Posts Search Scraper](https://apify.com/maximedupre/facebook-posts-search-scraper): find public posts by keyword or hashtag to study their talk.
- [Facebook Hashtag Scraper](https://apify.com/maximedupre/facebook-hashtag-scraper): gather public posts on a hashtag and then pull their comments.
- [Facebook Groups Search Scraper](https://apify.com/maximedupre/facebook-groups-search-scraper): find public groups by keyword to use as Group URLs here.

**Made with ❤️ by Maxime Dupré**

# Actor input Schema

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

Stop after this many comment rows across all posts. Replies are saved inside their comment row and do not count here. Leave empty or use 0 to collect all available comments within the other selected limits.

## `discoveryMethod` (type: `string`):

Choose Post URLs for posts, reels, or videos. Choose Post IDs for Facebook post IDs. Page URLs and Group URLs find posts and collect their comments.

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

Add one or more full public Facebook post, reel, or video URLs. Required when Find posts by is Post URLs.

## `postIds` (type: `array`):

Add one or more exact Facebook post IDs, one per entry. Required when Find posts by is Post IDs.

## `pageUrls` (type: `array`):

Add full public Facebook Page URLs. You can submit 100 or more Pages. Required when Find posts by is Page URLs. Later runs collect newly found posts and skip posts already delivered by this Actor.

## `pagePostsUntil` (type: `string`):

For Page URLs, select posts published on or before this date. Leave empty for no end date. Dates use UTC.

## `groupUrls` (type: `array`):

Add one or more full public Facebook group URLs. Required when Find posts by is Group URLs. Later runs continue to older posts and skip posts already delivered by this Actor.

## `groupPostKeyword` (type: `string`):

For Group URLs, select posts whose text contains this keyword. Leave empty to apply no keyword filter.

## `groupPostOrder` (type: `string`):

For Group URLs, choose Facebook's post order. New posts orders by post time. Recent activity uses the latest activity. Top posts uses Facebook's ranking.

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

Limit comment rows from each post. Replies inside a comment row do not count here. Leave empty or use 0 for all available comments from each post. Maximum comments per run still applies.

## `commentOrder` (type: `string`):

Choose Facebook's comment selection for all discovery methods. All comments selects available public comments. Newest first selects the newest comments first. Top comments uses Facebook's ranking. Hidden, deleted, and private comments are not available.

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

Save public replies inside each comment row. Each saved reply is charged. When this is off, no replies are collected.

## `maxRepliesPerComment` (type: `integer`):

When Include replies is on, save up to this many replies in each comment row, where available. Use 0 for all available replies.

## `maxPostsPerSource` (type: `integer`):

For Page URLs and Group URLs, select up to this many posts from each Page or group. Leave empty or use 0 for all available posts that match the filters.

## `maxPosts` (type: `integer`):

For Page URLs and Group URLs, select up to this many posts across the run. Leave empty or use 0 for all available posts that match the filters. The comment limits still apply.

## `postsSince` (type: `string`):

For Page URLs and Group URLs, select posts published on or after this date. Leave empty for no start date. Dates use UTC.

## Actor input object example

```json
{
  "maxComments": 20,
  "discoveryMethod": "postUrls",
  "postUrls": [
    {
      "url": "https://www.facebook.com/100063521621753/posts/1128544229272954"
    }
  ],
  "groupPostOrder": "newPosts",
  "commentOrder": "allComments",
  "includeReplies": false,
  "maxRepliesPerComment": 10
}
```

# Actor output Schema

## `comments` (type: `string`):

Open and download the collected comment data.

# 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 = {
    "maxComments": 20,
    "discoveryMethod": "postUrls",
    "postUrls": [
        {
            "url": "https://www.facebook.com/100063521621753/posts/1128544229272954"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("maximedupre/facebook-post-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 = {
    "maxComments": 20,
    "discoveryMethod": "postUrls",
    "postUrls": [{ "url": "https://www.facebook.com/100063521621753/posts/1128544229272954" }],
}

# Run the Actor and wait for it to finish
run = client.actor("maximedupre/facebook-post-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 '{
  "maxComments": 20,
  "discoveryMethod": "postUrls",
  "postUrls": [
    {
      "url": "https://www.facebook.com/100063521621753/posts/1128544229272954"
    }
  ]
}' |
apify call maximedupre/facebook-post-comments-scraper --silent --output-dataset

```

## MCP server setup

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