# Facebook Posts Scraper (`calm_builder/facebook-posts-scraper`) Actor

Collect public Facebook posts from pages, groups and profiles into clean JSON for analysis or export. Supports multiple URLs, optional comments and nested replies, media extraction.

- **URL**: https://apify.com/calm\_builder/facebook-posts-scraper.md
- **Developed by:** [Coder](https://apify.com/calm_builder) (community)
- **Categories:** Social media, Developer tools, Automation
- **Stats:** 3 total users, 2 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.50 / 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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use 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

## Facebook Posts Scraper

Collect public Facebook posts from pages, groups, and profiles in a clean, structured format.

This actor is built for research, monitoring, reporting, and dataset creation. You can run multiple URLs in one run, optionally include comments, and export results for analytics or automation.

### What This Actor Does

- Collects posts from public Facebook pages, groups, and profiles
- Supports multiple input URLs in one run
- Extracts core post details such as text, author, publish time, engagement, and media
- Optionally collects comments and replies
- Returns structured output ready for JSON, CSV, Excel, or API workflows

### Best For

- Social listening and brand monitoring
- Competitor and topic research
- Content performance tracking
- Public content archiving
- Preparing datasets for BI, NLP, or AI workflows

### Input

Provide one or more public Facebook URLs and set how much content to collect.

#### Main input fields

- `startUrls`
  Add one or more public page, group, or profile URLs.
- `maxPosts`
  Maximum number of posts to collect per input URL.
- `includeComments`
  Enable when you want comment threads in output.
- `maxComments`
  Maximum number of top-level comments per post when comments are enabled.
- `replyDepth`
  Depth of nested replies when replies are available.

#### Example input

```json
{
  "startUrls": [
    { "url": "https://www.facebook.com/Cristiano" },
    { "url": "https://www.facebook.com/groups/1312198885800812/" }
  ],
  "maxPosts": 50,
  "includeComments": false
}
````

### Output

Each dataset item represents one Facebook post.

Common fields include:

- `post`: post identity and URL details
- `publishedAt`: normalized publish timestamp
- `author`: author name and profile data
- `content`: post text and related metadata
- `engagement`: reactions, comments, and shares counts
- `media`: media items and metadata when available
- `inputUrl`: source URL that produced the item
- `comments`: nested comment data when enabled

#### Example output shape

```json
{
  "recordType": "facebook_post",
  "post": {
    "id": "1234567890",
    "url": "https://www.facebook.com/example/posts/1234567890",
    "type": "text"
  },
  "publishedAt": {
    "iso": "2026-04-28T13:56:03.000Z"
  },
  "author": {
    "name": "Example Author",
    "profileUrl": "https://www.facebook.com/example"
  },
  "content": {
    "text": "Example post content"
  },
  "engagement": {
    "reactions": 120,
    "comments": 14,
    "shares": 9
  },
  "media": {
    "count": 1
  },
  "inputUrl": "https://www.facebook.com/example",
  "comments": {
    "items": []
  }
}
```

### How To Use

1. Add one or more public Facebook URLs to `startUrls`.
2. Set `maxPosts` based on how much data you need.
3. Enable comments only when required to keep runs faster and lighter.
4. Run the actor and open the dataset after completion.
5. Export data or access it through the Apify API.

### Best Practices

- Start with a small `maxPosts` value to validate output quickly.
- Use specific and publicly accessible URLs for more predictable results.
- Enable comments only for runs that need conversation context.
- Use JSON export when you need full nested structure for media/comments.

### FAQ

#### Why is no data returned for some URLs?

The URL is likely private, restricted, unavailable, or not publicly accessible at the time of collection.

#### Can I collect media links?

Yes. When media is publicly available on a post, media URLs and metadata are included in output.

#### Can I run multiple URLs in one run?

Yes. Add multiple entries in `startUrls`, and the actor will process them in one run.

#### How long does a run take?

Runtime depends mainly on number of input URLs, `maxPosts`, and whether comments are enabled.

### Responsible Use

Use this actor only for publicly available content and ensure your use complies with applicable laws, regulations, and platform terms.

### Troubleshooting

- Verify each input URL in a browser before running.
- Test with a small `maxPosts` value first.
- If results are limited, try another known-public URL to confirm expected behavior.

# Actor input Schema

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

Add one or more public Facebook page, group, or profile links to scrape.

## `scrapeAllPhotos` (type: `boolean`):

Include all available photos for each post; when enabled the Actor will attempt to fetch HD images where available.

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

Limit how many posts to collect from each input link. Use smaller values for quick checks or larger values for full harvests.

## `includeComments` (type: `boolean`):

Collect comments and replies for each post (optional).

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

Maximum number of top-level comments to collect for each post. Use lower values to reduce runtime and cost.

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

Also collect replies to top-level comments (nested replies). May increase runtime and output size.

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

Choose reply nesting depth to capture. Level 1 collects direct replies; Level 2 includes replies-to-replies (more thorough but slower).

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

Limit how many replies are collected per comment at each reply level. Controls output size and cost.

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

Choose the ordering for comment collection. If you use a date range filter, the Actor will prioritize newest comments.

## `commentsDateRange` (type: `string`):

Optional publish-time filter for comments (absolute YYYY-MM-DD or relative like '7 days', '2 weeks'). Leave empty to collect all comments.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://www.facebook.com/Cristiano"
    },
    {
      "url": "https://www.facebook.com/groups/310009379049940"
    }
  ],
  "scrapeAllPhotos": false,
  "maxPosts": 5,
  "includeComments": false,
  "maxComments": 10,
  "includeReplies": false,
  "replyDepth": "1",
  "maxRepliesPerLevel": 2,
  "commentsSortBy": "all_comments",
  "commentsDateRange": ""
}
```

# Actor output Schema

## `results` (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/Cristiano"
        },
        {
            "url": "https://www.facebook.com/groups/310009379049940"
        }
    ]
};

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

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

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).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/Cristiano"
    },
    {
      "url": "https://www.facebook.com/groups/310009379049940"
    }
  ]
}' |
apify call calm_builder/facebook-posts-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=calm_builder/facebook-posts-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Facebook Posts Scraper",
        "description": "Collect public Facebook posts from pages, groups and profiles into clean JSON for analysis or export. Supports multiple URLs, optional comments and nested replies, media extraction.",
        "version": "0.0",
        "x-build-id": "QqlsVm6sN1LkGYG4t"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/calm_builder~facebook-posts-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-calm_builder-facebook-posts-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/calm_builder~facebook-posts-scraper/runs": {
            "post": {
                "operationId": "runs-sync-calm_builder-facebook-posts-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/calm_builder~facebook-posts-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-calm_builder-facebook-posts-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "startUrls",
                    "maxPosts",
                    "includeComments",
                    "maxComments",
                    "includeReplies",
                    "replyDepth",
                    "maxRepliesPerLevel",
                    "commentsSortBy"
                ],
                "properties": {
                    "startUrls": {
                        "title": "Facebook page, group, or profile links",
                        "minItems": 1,
                        "type": "array",
                        "description": "Add one or more public Facebook page, group, or profile links to scrape.",
                        "items": {
                            "type": "object",
                            "required": [
                                "url"
                            ],
                            "properties": {
                                "url": {
                                    "type": "string",
                                    "title": "URL of a web page",
                                    "format": "uri"
                                }
                            }
                        }
                    },
                    "scrapeAllPhotos": {
                        "title": "Scrape all photos",
                        "type": "boolean",
                        "description": "Include all available photos for each post; when enabled the Actor will attempt to fetch HD images where available.",
                        "default": false
                    },
                    "maxPosts": {
                        "title": "Maximum posts per link",
                        "minimum": 1,
                        "maximum": 1000,
                        "type": "integer",
                        "description": "Limit how many posts to collect from each input link. Use smaller values for quick checks or larger values for full harvests.",
                        "default": 5
                    },
                    "includeComments": {
                        "title": "Add comments and replies",
                        "type": "boolean",
                        "description": "Collect comments and replies for each post (optional).",
                        "default": false
                    },
                    "maxComments": {
                        "title": "Maximum comments per post",
                        "minimum": 1,
                        "maximum": 5000,
                        "type": "integer",
                        "description": "Maximum number of top-level comments to collect for each post. Use lower values to reduce runtime and cost.",
                        "default": 10
                    },
                    "includeReplies": {
                        "title": "Include replies",
                        "type": "boolean",
                        "description": "Also collect replies to top-level comments (nested replies). May increase runtime and output size.",
                        "default": false
                    },
                    "replyDepth": {
                        "title": "Reply depth",
                        "enum": [
                            "1",
                            "2"
                        ],
                        "type": "string",
                        "description": "Choose reply nesting depth to capture. Level 1 collects direct replies; Level 2 includes replies-to-replies (more thorough but slower).",
                        "default": "1"
                    },
                    "maxRepliesPerLevel": {
                        "title": "Maximum replies per level",
                        "minimum": 1,
                        "maximum": 1000,
                        "type": "integer",
                        "description": "Limit how many replies are collected per comment at each reply level. Controls output size and cost.",
                        "default": 2
                    },
                    "commentsSortBy": {
                        "title": "Comments sorting",
                        "enum": [
                            "all_comments",
                            "most_relevant",
                            "newest"
                        ],
                        "type": "string",
                        "description": "Choose the ordering for comment collection. If you use a date range filter, the Actor will prioritize newest comments.",
                        "default": "all_comments"
                    },
                    "commentsDateRange": {
                        "title": "Date range for comments",
                        "pattern": "^$|^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])$|^(\\d+)\\s*(day|week|month|year)s?$",
                        "type": "string",
                        "description": "Optional publish-time filter for comments (absolute YYYY-MM-DD or relative like '7 days', '2 weeks'). Leave empty to collect all comments.",
                        "default": ""
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
