# Facebook Post Search Scraper (`powerai/facebook-post-search-scraper`) Actor

Extract Facebook posts by keyword with advanced filters, supporting auto-pagination and up to 5000 results per run. Ideal for social media research and content analysis.

- **URL**: https://apify.com/powerai/facebook-post-search-scraper.md
- **Developed by:** [PowerAI](https://apify.com/powerai) (community)
- **Categories:** Social media, Lead generation
- **Stats:** 7,865 total users, 240 monthly users, 99.6% runs succeeded, 42 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $9.99 / 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?

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 Post Search Scraper

This actor allows you to search and extract Facebook posts based on keywords, with support for advanced filters and automatic pagination. It leverages the latest Facebook Post Search API, ensuring robust and up-to-date results.

### Features

- **Keyword Search:** Find posts by any keyword or phrase.
- **Recent Posts:** Optionally restrict results to only recent posts.
- **Location Filter:** Filter posts by a specific location UID.
- **Date Range:** Specify a start and end date to narrow down results.
- **Auto Pagination:** Automatically fetches multiple pages using the API cursor until the desired number of results (`maxResults`) is reached.
- **Structured Output:** Returns a structured list of post objects with detailed metadata.

### Input Parameters

| Field          | Type      | Required | Description                                                      |
| -------------- | --------- | -------- | ---------------------------------------------------------------- |
| `query`        | string    | Yes      | Keywords to search for Facebook posts.                          |
| `recent_posts` | boolean   | No       | Whether to only search for recent posts.                        |
| `location_uid` | string    | No       | Location unique identifier for filtering posts.                 |
| `start_date`   | string    | No       | Start date for filtering posts (format: yyyy-mm-dd).            |
| `end_date`     | string    | No       | End date for filtering posts (format: yyyy-mm-dd).              |
| `maxResults`   | integer   | No       | Maximum number of posts to fetch (default: 5, max: 5000).       |

### Output

The output is a list of post objects, each containing:

- `post_id`: Post ID
- `type`: Post type
- `url`: Post URL
- `message`: Post content
- `timestamp`: Post timestamp
- `comments_count`: Number of comments
- `reactions_count`: Number of reactions
- `reshare_count`: Number of reshares
- `reactions`: Detailed reaction counts (like, love, haha, wow, sad, angry, care)
- `author`: Author information (id, name, url, profile_picture_url)
- `image`: Post image URL (if any)
- `video`: Post video URL (if any)
- `video_thumbnail`: Video thumbnail URL (if any)
- `external_url`: External link URL (if any)

Example output:

```json
[
  {
    "post_id": "1239493390061723",
    "type": "post",
    "url": "https://www.facebook.com/groups/1134408680570195/posts/1239493390061723/",
    "message": "ကျွန်​တော် လက်ရှိ ဖုန်းနဲ့သုံး​နေတဲ့ ai​တွေပါ။\n\nChatGPT\nhttps://chat.openai.com/\n\nGoogle Bard\nhttps://bard.google.com/chat/\n\nBing Ai\nhttps://www.bing.com/?/ai\n\nအ​ပေါ်က၃ခုက သိချင်တာ​မေးဖို့ဖြစ်ပြီး ​အောက်က၁ခုက​တော့ qr codeလှလှ​လေး​တွေ လုပ်ဖို့ပါ။\n\nQuick QR Art\nhttps://quickqr.art/\n\nတစ်ခြား သုံးလို့​ကောင်းတဲ့ ai​လေး​တွေသိရင်လည်း လင်းပါအုံးခင်ဗျ။😁",
    "timestamp": 1697095987,
    "comments_count": 18,
    "reactions_count": 437,
    "reshare_count": 256,
    "reactions": {
      "angry": 0,
      "care": 2,
      "haha": 0,
      "like": 388,
      "love": 47,
      "sad": 0,
      "wow": 0
    },
    "author": {
      "id": "pfbid02prAFBpEg3jQ9iDjBW7noasS3ufXWx32aXuBpnugMCGzMGoAVP9WsqqaZanqaD7AWl",
      "name": "SK Naing",
      "url": "https://www.facebook.com/sknaing29",
      "profile_picture_url": "https://scontent.fsgn8-4.fna.fbcdn.net/v/t39.30808-1/392872297_360573559788889_2181586812231600155_n.jpg?stp=cp0_dst-jpg_p48x48_tt6&_nc_cat=103&ccb=1-7&_nc_sid=e99d92&_nc_ohc=JAdu48yDlVIQ7kNvwFSAPAY&_nc_oc=AdmsDv46TWxR0aJJ0INluXH7s6VgSOD2iTTOiGuXjcDR5oPnIgZCEG4PQeq9-hIFv-w&_nc_zt=24&_nc_ht=scontent.fsgn8-4.fna&_nc_gid=aTRTybJoeuZryp5dbsgmbQ&oh=00_AfLobla_FUp1EW9zKnmXRLdR1qaG3zZLjdlgbC86lkMSvA&oe=683B3748"
    },
    "image": null,
    "video": null,
    "album_preview": null,
    "video_files": null,
    "video_thumbnail": null,
    "external_url": null,
    "attached_event": null,
    "attached_post": null,
    "attached_post_url": null,
    "scrapedAt": "2025-05-27T09:01:38.204Z"
  },
  ...
]
```

### Use Cases

- Social media research and analytics
- Content discovery and trend analysis
- Academic and marketing studies
- Brand monitoring and sentiment analysis

### Notes

- The actor will automatically paginate using the API cursor until the `maxResults` limit is reached or no more results are available.
- Make sure your query is specific enough to get relevant results.
- The API may have rate limits, so consider using appropriate delays between requests.

***

**Enjoy fast and reliable Facebook post data extraction!**

# Actor input Schema

## `query` (type: `string`):

Keywords to search for Facebook posts.

## `recent_posts` (type: `boolean`):

Whether to only search for recent posts.

## `location_uid` (type: `string`):

Location unique identifier for filtering posts.

## `start_date` (type: `string`):

Start date for filtering posts (format: yyyy-mm-dd).

## `end_date` (type: `string`):

End date for filtering posts (format: yyyy-mm-dd).

## `maxResults` (type: `integer`):

Maximum number of posts to fetch.

## Actor input object example

```json
{
  "query": "ai",
  "maxResults": 10
}
```

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("powerai/facebook-post-search-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 = {}

# Run the Actor and wait for it to finish
run = client.actor("powerai/facebook-post-search-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 '{}' |
apify call powerai/facebook-post-search-scraper --silent --output-dataset

```

## MCP server setup

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