# Facebook Post Scraper (`amats-core/facebook-scraper`) Actor

Scrape Facebook posts by keyword search or profile username. Returns structured JSON with post content, author info, media, and engagement stats.

- **URL**: https://apify.com/amats-core/facebook-scraper.md
- **Developed by:** [Amats Core](https://apify.com/amats-core) (community)
- **Categories:** Social media, Automation, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

$1.40 / 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/platform/actors/running/actors-in-store#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

<p align="center">
  <img src="https://raw.githubusercontent.com/amats-core/assets/main/banner.png" alt="Amats Core" width="100%">
</p>

## Facebook Post Scraper

**by Amats Core**

Collect public Facebook posts in a few clicks. Search by keyword, or collect posts from a public personal profile. Results include text, author, photos, videos, likes, comments, and shares.

You do not need a Facebook login. Fill in the form and start the run.

***

### What you get

- **Search by keyword** — enter one or more topics. The actor collects posts until it reaches your limit.
- **Public personal profiles** — paste a username or Facebook profile URL. Facebook Pages (business/brand pages) are not supported.
- **Photos and videos** — image URLs and video thumbnails, including multi-photo posts.
- **Engagement** — likes, comments, and shares for each post.
- **Optional dates** — leave empty to take the latest posts, or set a range to keep only posts from those days.

***

### How to run

1. Choose **Search by keywords** or **Public profile**.
2. Enter keywords (search) or a profile username / link (profile).
3. Set how many posts you want.
4. Dates are optional. Leave them empty to collect the latest posts.
5. Click **Start**.

#### Search example

```json
{
  "mode": "search",
  "keywords": ["coffee", "travel"],
  "maxPosts": 20
}
```

#### Profile example

```json
{
  "mode": "profile",
  "username": "your.username",
  "maxPosts": 10
}
```

#### Date range example

```json
{
  "mode": "search",
  "keywords": ["coffee"],
  "maxPosts": 20,
  "startDate": "2024-01-01",
  "endDate": "2024-01-31"
}
```

***

### Input fields

| Field | What it means |
|---|---|
| **Mode** | Search by keywords, or collect posts from a public personal profile. |
| **Keywords** | Topics to search for. Used in search mode. |
| **Facebook username or URL** | Public personal profile only. Example: `your.username` or `https://www.facebook.com/your.username`. Facebook Pages are not supported. |
| **Number of posts** | Maximum posts to collect (1–5000). Default is 20. |
| **From date / To date** | Optional. Leave both empty to get the latest posts, with no date filter. |

***

### Output

Each post is one row in the dataset.

| Field | What it is |
|---|---|
| `id` | Post ID |
| `postUrl` | Link to the post |
| `text` | Post text |
| `publishedAt` | Publish time (ISO 8601) |
| `author.name` | Display name |
| `author.url` | Profile link |
| `author.avatarUrl` | Profile photo |
| `media` | Photos or video thumbnails |
| `media[].url` | Media URL |
| `media[].type` | `image` or `video` |
| `stats.likes` | Likes |
| `stats.comments` | Comments |
| `stats.shares` | Shares |

#### Sample result

```json
{
  "id": "1234567890123456",
  "postUrl": "https://www.facebook.com/your.username/posts/1234567890123456",
  "text": "Tried a new coffee spot this weekend.",
  "publishedAt": "2024-06-15T10:00:00.000Z",
  "author": {
    "name": "Jane Example",
    "url": "https://www.facebook.com/your.username",
    "avatarUrl": "https://example.com/avatar.jpg"
  },
  "media": [
    {
      "url": "https://example.com/photo.jpg",
      "type": "image"
    }
  ],
  "stats": {
    "likes": 42,
    "comments": 8,
    "shares": 3
  }
}
```

***

### Notes

- Only **public** posts are collected. Private profiles, closed groups, Facebook Pages, and login-walled content are not available.
- Video view counts are not included.
- If a post has 0 comments or shares, that is the public count, not a missing field.
- Very large runs (thousands of posts) can take longer. Start with 20–50 posts to confirm the results look right.

***

### Cost

This actor is **pay per result**. You pay a fixed price for each post collected — not for Apify compute.

Current store price: **$1.40 per 1,000 posts**. A 20-post run is charged for 20 results only. Runs that return 0 posts are not charged for results.

***

### Support

Questions or custom needs: contact **Amats Core** through the Apify platform.

# Actor input Schema

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

Search public posts by keyword, or collect posts from a public personal profile. Facebook Pages are not supported.

## `keywords` (type: `array`):

Topics to search for. Each keyword is searched in order until the post limit is reached. Example: coffee, travel.

## `username` (type: `string`):

Public personal profile only. Paste a username (your.username) or a full Facebook profile link. Used only for “Public profile”. Facebook Pages are not supported.

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

Maximum number of posts to collect. For search, this is the total across all keywords.

## `startDate` (type: `string`):

Optional. Only keep posts published on or after this day. Leave empty (together with To date) to collect the latest posts with no date filter.

## `endDate` (type: `string`):

Optional. Only keep posts published on or before this day. Leave empty if you do not want an end date.

## Actor input object example

```json
{
  "mode": "search",
  "keywords": [
    "coffee",
    "travel"
  ],
  "username": "your.username",
  "maxPosts": 20
}
```

# Actor output Schema

## `posts` (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 = {
    "keywords": [
        "coffee",
        "travel"
    ],
    "username": "your.username",
    "maxPosts": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("amats-core/facebook-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 = {
    "keywords": [
        "coffee",
        "travel",
    ],
    "username": "your.username",
    "maxPosts": 20,
}

# Run the Actor and wait for it to finish
run = client.actor("amats-core/facebook-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 '{
  "keywords": [
    "coffee",
    "travel"
  ],
  "username": "your.username",
  "maxPosts": 20
}' |
apify call amats-core/facebook-scraper --silent --output-dataset

```

## MCP server setup

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