# Facebook Profile Posts Scraper (`outspoken_strategy/facebook-profile-posts-scraper`) Actor

Paste a Facebook page or profile URL and get that account's posts for any period. Date filtering, multi-profile input, auto-pagination, self-renewing login session. Returns text, author, timestamp, reactions, comments, shares and media.

- **URL**: https://apify.com/outspoken\_strategy/facebook-profile-posts-scraper.md
- **Developed by:** [code craker](https://apify.com/outspoken_strategy) (community)
- **Categories:** Social media, News, Lead generation
- **Stats:** 1 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

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

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — 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 Profile Posts Scraper

Paste a Facebook page or profile URL and get that account's posts as structured data — text, author, publish time, reaction breakdown, comment and share counts, photos and videos. Supports several profiles per run, a date range with early-stop scrolling, and a self-renewing login session.

### Input

| Field | Description |
| --- | --- |
| `profileUrl` | One page/profile: `https://www.facebook.com/nasa`, a `profile.php?id=...` URL, a `/people/` URL, a bare vanity name or numeric id. Any post URL on the page resolves to its owner. Several profiles can be pasted one per line. |
| `profileUrls` | Several profiles as an array. `numberOfPosts` applies **per profile**. |
| `numberOfPosts` | Maximum posts to return per profile (default 25). |
| `scrapeAll` | Keep scrolling until the target count, the date boundary, or the end of the feed (default on). |
| `timeSince` / `timeUntil` | Inclusive date range (`yyyy-mm-dd`, UTC). Posts carry real timestamps; the actor stops scrolling once the feed passes below `timeSince`. |
| `cookies` / `fbEmail` + `fbPassword` | Session — see **Authentication**. |
| `proxySessionId` | Stable Apify proxy session id pinning ONE exit IP across runs (or the `FB_PROXY_SESSION` env var). |

### Authentication

Facebook login-walls most timelines for anonymous visitors, so the actor needs a session from a **throwaway account** (never a personal one):

- **Recommended**: set the `FB_EMAIL` + `FB_PASSWORD` secret environment variables (2FA disabled) — the actor logs in once, then keeps the session alive by itself: the refreshed cookies are written back to a persistent store after every run and the pinned proxy session (`FB_PROXY_SESSION`) keeps the account on one exit IP, which is what stops Facebook invalidating it.
- Or provide cookies directly: the `cookies` input or the `FB_COOKIES` secret env var (a Cookie-Editor JSON export, or a `name=value; name2=value2` string). These are only a **seed** — once adopted, the self-refreshing stored session takes priority.

### Output

One dataset item per post:

```json
{
    "post_id": "1234567890123456",
    "url": "https://www.facebook.com/NASA/posts/...",
    "message": "Full post text...",
    "text": "Full post text...",
    "timestamp": 1787568447,
    "createdTime": "2026-08-21T19:05:34.000Z",
    "reactions_count": 1809,
    "comments_count": 147,
    "reshare_count": 300,
    "reactions": { "like": 1500, "love": 200, "care": 30, "haha": 20, "wow": 40, "sad": 10, "angry": 9 },
    "author": { "id": "...", "name": "NASA", "url": "https://www.facebook.com/NASA", "username": "NASA" },
    "image": { "uri": "https://...", "width": 720, "height": 480 },
    "video": null,
    "attached_post": null,
    "profileHandle": "nasa",
    "profileUrl": "https://www.facebook.com/nasa"
}
```

### Tips

- An unavailable page (deleted, restricted, renamed) is skipped with a warning instead of failing the run.
- Public pages often serve their first posts even without a session, so a cookie-less run may still return the newest few posts — but a session is required for reliable, deep scraping.
- Check `DEBUG_SCREENSHOT` / `DEBUG_HTML` in the run's key-value store when a run returns nothing.

# Actor input Schema

## `profileUrl` (type: `string`):

The Facebook page or profile to scrape, e.g. https://www.facebook.com/nasa. Also accepted: profile.php?id=... URLs, /people/ URLs, a bare vanity name or a bare numeric id. Any post URL on the page resolves to its owner. You can paste several profiles, one per line. For a clean list use "profileUrls" below instead.

## `profileUrls` (type: `array`):

Several profiles/pages to scrape — each is scraped separately and the results are combined. "Number of posts" applies PER profile.

## `numberOfPosts` (type: `integer`):

Maximum number of posts to return per profile (after date filtering).

## `scrapeAll` (type: `boolean`):

Keep scrolling until the target count is reached, the date range is passed, or the feed runs dry. When unchecked only the posts on the initial page load are returned.

## `timeSince` (type: `string`):

Only return posts published on or after this date (format: yyyy-mm-dd). Inclusive.

## `timeUntil` (type: `string`):

Only return posts published on or before this date (format: yyyy-mm-dd). Inclusive.

## `cookies` (type: `array`):

Cookies of a logged-in Facebook session, exported with a browser extension such as Cookie-Editor (JSON array of {name, value, domain, ...}). The "c\_user" and "xs" cookies carry the session. Alternatively set the FB\_COOKIES secret environment variable on the actor. Use a throwaway account, never your personal one.

## `fbEmail` (type: `string`):

Email of a throwaway Facebook account. If set together with fbPassword (or via the FB\_EMAIL/FB\_PASSWORD secret env vars), the actor logs in itself and keeps the session alive across runs. The account must have 2FA disabled.

## `fbPassword` (type: `string`):

Password for the account in fbEmail. Stored encrypted. Prefer the FB\_PASSWORD secret environment variable instead of putting it in run input.

## `proxySessionId` (type: `string`):

A stable Apify proxy session id that keeps the account on ONE exit IP across runs — Facebook invalidates sessions that appear to hop IPs. Set it per account (or via the FB\_PROXY\_SESSION env var) and use the same value as your other Facebook actors running this account.

## `proxyConfiguration` (type: `object`):

Proxy to route traffic through. Residential proxies with a country set are strongly recommended — Facebook blocks datacenter IPs.

## `headless` (type: `boolean`):

Uncheck to run a headed browser (useful only for local debugging).

## Actor input object example

```json
{
  "profileUrl": "https://www.facebook.com/nasa",
  "profileUrls": [],
  "numberOfPosts": 25,
  "scrapeAll": true,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ],
    "apifyProxyCountry": "US"
  },
  "headless": true
}
```

# Actor output Schema

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

The scraped posts as dataset items — one item per post, with text, author, publish time, reactions, comments, shares and media.

# 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 = {
    "profileUrl": "https://www.facebook.com/nasa",
    "profileUrls": [],
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ],
        "apifyProxyCountry": "US"
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("outspoken_strategy/facebook-profile-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 = {
    "profileUrl": "https://www.facebook.com/nasa",
    "profileUrls": [],
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
        "apifyProxyCountry": "US",
    },
}

# Run the Actor and wait for it to finish
run = client.actor("outspoken_strategy/facebook-profile-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 '{
  "profileUrl": "https://www.facebook.com/nasa",
  "profileUrls": [],
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ],
    "apifyProxyCountry": "US"
  }
}' |
apify call outspoken_strategy/facebook-profile-posts-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,outspoken_strategy/facebook-profile-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/UeyNZDfcXy0i8zNgM/builds/8bOCNxbzi86ggexbI/openapi.json
