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

Collect public Facebook page and direct posts with text, dates, reactions, comments, shares, albums and video links. Use UTC date filters, available captions and explicit coverage.

- **URL**: https://apify.com/headofactors/facebook-posts-scraper.md
- **Developed by:** [HeadOfActors](https://apify.com/headofactors) (community)
- **Categories:** Social media
- **Features:** Limited permissions
- **Stats:** 3 total users, 2 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$1.50 / 1,000 facebook posts

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

## Facebook Posts Scraper

Facebook posts scraper collects public Facebook page posts and direct posts, including text, publication dates, engagement, albums, video links and available captions. Supply public Facebook URLs and choose a per-page result limit or a UTC publication window. The output keeps familiar Facebook field names alongside consistent post identifiers and explicit collection coverage.

### What the Facebook posts scraper collects

Each dataset row represents one public post. Photo albums stay together as one post with multiple media entries. A shared post keeps its own identity and engagement, with the attached post under `sharedPost`. Video attachments remain attached to their parent post and include the media information Facebook actually exposes.

Use the results to follow public announcements, compare public posting activity, collect posts for research, or connect public content to your existing records. Save `post_id` as the stable join key and `post_url` as the source reference. Engagement is a snapshot at collection time and may change between runs.

### Input

The five main input names match the established Facebook posts workflow:

| Field | Meaning |
|---|---|
| `startUrls` | Required list of public Facebook page or direct post/video URLs. Each entry can contain a `url` property. |
| `resultsLimit` | Positive integer limiting posts per page. Direct post URLs return their matching post. |
| `captionText` | Retrieve a real available video caption track. The default is false. |
| `onlyPostsNewerThan` | Inclusive lower UTC publication boundary. |
| `onlyPostsOlderThan` | Inclusive upper UTC publication boundary. |

For example, this input requests twenty posts from the public NASA page:

```json
{"startUrls":[{"url":"https://www.facebook.com/NASA/"}],"resultsLimit":20}
```

The limit applies separately to each requested page. Repeated posts across overlapping targets are deduplicated. Leave `resultsLimit` out to continue until the public source ends or the collection reports a partial stop. Omitting a limit does not guarantee access to every historical post.

Date filters accept `YYYY-MM-DD`, an ISO UTC timestamp with minutes and optional seconds, or a non-negative relative value such as `7 days`, `2 months` or `1 year`. A date without a time means midnight UTC. Both boundaries include their exact timestamp. Use a full upper timestamp when you want the end of a calendar day. Months and years follow the UTC calendar and clamp to the last valid day when necessary. Relative dates are resolved once and retained throughout continuation.

Direct video URLs use the measured `/<page>/videos/<id>` form. `/reel/<id>` and `/watch?v=<id>` URLs are currently rejected as invalid input; video and reel attachments from supported page and post URLs are retained.

A `cursor` is an optional continuation token for an unfinished collection. Keep the other input values identical when resuming. The Actor follows continuation automatically within its run budget; API clients can also use the returned `next_cursor`. Treat the token as an opaque value.

### Output

Results appear in the default dataset. You can export them with the dataset formats supported by Apify, including JSON and CSV. Nested media and shared-post objects are easiest to inspect in JSON.

Every row contains `source`, `platform`, `fetched_at`, `post_id` and `post_url`. The compatible fields `postId` and `url` contain the same post identity and permalink. Available text is preserved with its original line breaks. Publication time is supplied as `posted_at` and `time`, with Unix seconds in `timestamp`.

Available engagement includes `likes`, `comments`, `comments_count` and `shares`. Here `likes` means the total number of reactions. Individual reaction categories use names such as `reactionLikeCount` and `reactionLoveCount`. Missing source counts are omitted; a real zero remains zero. Video views are included only when exposed by the source.

The `user` object describes the parent post's author. Media entries keep `__typename`, available URLs, thumbnails and source identifiers. Caption enrichment adds `captionText`, `captionFormat` and `captionsUrl` to the relevant media entry. Captions are not generated from audio. Temporary media links can expire, so save the required information promptly.

The `OUTPUT` and `summary` records describe coverage, resolved date boundaries, partial completion, warnings and delivered counts. The separate `coverage`, `filter_window`, `errors` and `billing` records make those details accessible directly. Coverage distinguishes a requested limit from a demonstrated source ending. A `chunk_boundary` stop means collection continues in the next chunk, including targets deferred after a successful target. A `budget` stop means the time or request budget was reached. Both include a continuation token. A partial stop can indicate a source restriction, interrupted continuation, unavailable caption track or a collection budget being reached. Inspect these records before treating the dataset as complete historical coverage.

### Pricing and free usage

The Actor's current Pricing tab is the authority for live charges. The intended result event counts delivered unique dataset posts once. Captions and date filters do not introduce separate result events in this implementation. Empty collections have zero delivered posts. Actual Apify run costs and the applicable account tier should be included when comparing cost per thousand results.

Free usage is limited to ten delivered posts in total per run across all targets. Caption enrichment is disabled for free runs. The run summary reports the applied free usage cap. A paid run retains the requested per-page limits; reaching a requested limit does not mean that Facebook has no older posts.

### FAQ

#### Do I need a Facebook account?

This Actor reads public content without customer login credentials or cookies. Private, removed, restricted or otherwise unavailable content may not be accessible. Supplying a URL does not change its visibility.

#### Why did I get fewer posts than requested?

Facebook may expose fewer public posts than the requested limit, restrict a particular target, or stop advancing its public feed. The summary reports incomplete coverage and source errors with the original input URL. An empty response is checked for recognizable public content rather than assumed to be a successful empty feed.

#### Does it include comments and transcripts?

It returns available comment counts and any public comment selection actually present in the source. It does not promise complete comment history. Caption text requires `captionText: true` and a publicly available track; missing or failed tracks are reported while retaining the post.

#### Are albums counted as several results?

An album is one post with several media entries. Attached shared posts and caption tracks also remain nested. Billing counts the delivered main post once.

#### Can I compare repeat runs?

Join by `post_id` and retain `fetched_at` to distinguish observations. Posting time and collection time serve different purposes. A change in engagement between observations reflects the snapshots received during those runs.

# Actor input Schema

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

Public Facebook page or direct post/video URLs. Direct videos use /<page>/videos/<id>; /reel/<id> and /watch?v=<id> are not supported. No login or cookies are needed.

## `resultsLimit` (type: `integer`):

Maximum unique posts per page; direct URLs return their own post. Omit to continue until the source ends or coverage is reported incomplete.

## `captionText` (type: `boolean`):

Fetch a real public caption track where available. A missing track is reported; no transcript is invented.

## `onlyPostsNewerThan` (type: `string`):

Inclusive lower UTC publication boundary: YYYY-MM-DD, an ISO UTC timestamp, or a non-negative number of minute/hour/day/week/month/year units ago.

## `onlyPostsOlderThan` (type: `string`):

Inclusive upper UTC publication boundary. Date-only values mean midnight UTC. Relative values are resolved once per run.

## `cursor` (type: `string`):

Signed continuation from a previous response for exactly the same input. Do not modify it.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://www.facebook.com/humansofnewyork/"
    }
  ],
  "resultsLimit": 20,
  "captionText": false
}
```

# Actor output Schema

## `posts` (type: `string`):

No description

## `summary` (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/humansofnewyork/"
        }
    ],
    "resultsLimit": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("headofactors/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/humansofnewyork/" }],
    "resultsLimit": 20,
}

# Run the Actor and wait for it to finish
run = client.actor("headofactors/facebook-posts-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/humansofnewyork/"
    }
  ],
  "resultsLimit": 20
}' |
apify call headofactors/facebook-posts-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,headofactors/facebook-posts-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/eyKeDGgVz4WcNKdTq/builds/06ffMpVTVeycC8oqu/openapi.json
