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

Search public Facebook page, profile, and group posts by keyword. Returns only posts whose text or author matches your terms, with author, timestamp, engagement counts, media, and the matched terms. Cookieless, no login. MCP-ready.

- **URL**: https://apify.com/khadinakbar/facebook-post-search-scraper.md
- **Developed by:** [Khadin Akbar](https://apify.com/khadinakbar) (community)
- **Categories:** Social media, Lead generation, MCP servers
- **Stats:** 3 total users, 0 monthly users, 80.6% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $6.00 / 1,000 matching post returneds

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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

## Facebook Post Search Scraper

Search public Facebook posts by keyword across the pages, profiles, and groups you choose — and get back **only the posts that match your terms**, as clean structured JSON. Cookieless, no login, MCP-ready.

### What it does

Give the actor (1) a list of **search terms** and (2) a list of **public Facebook sources** (page, profile, or group URLs). It scans the recent posts of each source, keyword-matches every post against your terms, and returns just the matches — with author, timestamp, engagement counts, media, outbound links, and the exact `matchedTerms` that triggered each hit.

This is **search within the sources you specify**. Facebook's own global search bar (`facebook.com/search/posts`) is login-walled and cannot be scraped reliably without an account; no cookieless tool can do it honestly. Instead, this actor lets you point at the pages and groups that matter to you (competitors, communities, news pages, your own page) and pull every post mentioning a keyword.

### When to use it

- **Brand & keyword monitoring** — track every post mentioning your brand, product, or campaign across a set of pages and groups.
- **Competitor watch** — find competitor posts about launches, promos, or hiring.
- **Community research** — surface posts about a topic inside public groups.
- **Lead & opportunity mining** — find "looking for", "recommend", "hiring", or buying-intent posts in niche communities.
- **AI agents** — a clean tool call: terms + sources in, matching posts out.

**Do not use it for:** scraping ALL posts from a page regardless of keyword (use the companion **Facebook Posts Scraper**), Facebook Ads (use **Facebook Ad Library Scraper**), Marketplace, comments, or private/login-only content.

### Output

One dataset record per matching post:

| Field | Description |
|---|---|
| `postUrl` | Canonical Facebook post URL |
| `text` | Post caption/body text |
| `matchedTerms` | The search terms this post matched |
| `matchedFields` | Which fields matched (`text`, `author`) |
| `authorName` / `authorUrl` | Author or page that posted |
| `timestamp` | ISO 8601 publish time (when available) |
| `reactionsCount` / `commentsCount` / `sharesCount` | Engagement counts |
| `media` | Image/video URLs on the post |
| `externalLinks` | Outbound non-Facebook links in the post |
| `sourceUrl` | The source URL that produced the post |
| `scrapeSource` | Provider that returned the post |

### Input

| Field | Required | Description |
|---|---|---|
| `searchTerms` | ✅ | Keywords/phrases to look for (e.g. `["hiring", "remote"]`). |
| `startUrls` | ✅ | Public page/profile/group (or post) URLs to search within. |
| `matchMode` | | `any` (OR, default) or `all` (AND) across terms. |
| `matchFields` | | Search `text`, `author`, or both. Default: `text`. |
| `caseSensitive` | | Exact-case matching. Default: off. |
| `useRegex` | | Treat terms as JS regular expressions. Invalid patterns fall back to literal. |
| `resultsLimit` | | Max matching posts returned (cost cap). Default: 50. |
| `maxPostsScannedPerSource` | | How many recent posts to scan per source. Default: 150. |
| `onlyPostsNewerThan` / `onlyPostsOlderThan` | | Optional ISO date filters. |

#### Example input

```json
{
  "searchTerms": ["mars", "moon"],
  "startUrls": [{ "url": "https://www.facebook.com/NASA" }],
  "matchMode": "any",
  "matchFields": ["text"],
  "resultsLimit": 50,
  "maxPostsScannedPerSource": 150
}
```

### How search works

For each source, the actor pulls recent posts (paginating up to `maxPostsScannedPerSource`) through a managed data provider, then applies your matcher locally:

- **`any`** — a post is returned if it matches at least one term.
- **`all`** — a post is returned only if it matches every term.
- Matching is case-insensitive substring by default; enable `caseSensitive` or `useRegex` for finer control.

`maxPostsScannedPerSource` controls how deep the search reads each source. Rare keywords need a higher value to find matches; common keywords need less. `resultsLimit` caps how many matches you pay for.

### Pricing

Pay-per-event (and pay-per-usage):

- **Actor start** — $0.00005
- **Source searched** — $0.02 per page/profile/group scanned
- **Matching post returned** — $0.006 per matched post

A run searching 5 sources and returning 40 matches costs about **$0.34**. You only pay the per-match fee for posts that actually match your terms.

### Reliability

- Cookieless and login-free — backed by managed providers (ScrapeCreators primary, SociaVault fallback), so there are no cookies to expire.
- **Public data only.** Private, deleted, age-gated, or login-only sources return no posts and are reported in the run summary — they don't crash the run.
- A zero-match run is a normal, successful result (no posts contained your terms). A run where every source was blocked or empty fails honestly so you're never silently billed for nothing.

### Use with AI agents (MCP)

Exposed via Apify MCP as `apify--facebook-post-search-scraper`. Call it with `searchTerms` + `startUrls`; it returns matching posts as structured JSON for downstream reasoning.

### Related actors

- **Facebook Posts Scraper** — all posts from a page/profile/group (no keyword filter).
- **Facebook Ad Library Scraper** — Meta ad creatives by keyword/advertiser.
- **Facebook Groups Scraper**, **Facebook Marketplace Scraper**, **Facebook Page Scraper**.

### Legal

This actor collects only publicly available Facebook data. You are responsible for complying with Facebook's Terms of Service, applicable data-protection laws (GDPR/CCPA), and for using scraped data lawfully. It does not access private content, bypass authentication, or collect data behind a login.

# Actor input Schema

## `searchTerms` (type: `array`):

Keywords or phrases to search for in each post (e.g. \["hiring", "product launch"]). A post is returned when it matches per the Match mode below. By default matching is case-insensitive substring on post text. NOT a Facebook search-bar query — Facebook's own keyword search is login-only; this searches within the sources you provide.

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

Public Facebook page, profile, or group URLs whose posts will be scanned for your search terms. Direct post URLs are also accepted (each counts as one source). Example: https://www.facebook.com/NASA. Private, deleted, age-gated, or login-only sources return no posts.

## `matchMode` (type: `string`):

How multiple search terms combine. 'any' returns a post if it matches at least one term (OR). 'all' returns a post only if it matches every term (AND). Defaults to 'any'.

## `matchFields` (type: `array`):

Which fields each term is tested against: post text and/or author name. Defaults to post text only. Select both to also match posts by the author/page name.

## `caseSensitive` (type: `boolean`):

When enabled, terms must match the exact letter case. Default is case-insensitive (e.g. 'Mars' matches 'mars').

## `useRegex` (type: `boolean`):

When enabled, each search term is compiled as a JavaScript regular expression (e.g. 'hir\w+'). An invalid pattern falls back to a literal substring match. Leave off for plain keyword search.

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

Maximum number of matching posts to return across all sources. This is your primary cost cap; each returned match charges the post-matched event. Defaults to 50.

## `maxPostsScannedPerSource` (type: `integer`):

How many recent posts to scan per source while looking for matches. Higher values find more matches for rare keywords but scan more posts and take longer. Defaults to 60. This bounds how deep the search reads each page/group; it is not the number of results returned.

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

Optional date filter. Accepts ISO dates such as 2026-01-01 or natural date strings. Posts with no parseable date are kept rather than silently dropped.

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

Optional upper date filter. Accepts ISO dates such as 2026-06-01 or natural date strings. Posts with no parseable date are kept rather than silently dropped.

## `fallbackProvider` (type: `string`):

Which managed data provider supplies the posts. 'auto' uses ScrapeCreators first and SociaVault second (recommended). Provider keys are configured by the actor owner; you do not supply them.

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

Proxy settings. Posts are fetched through managed providers, so proxy is optional; defaults to Apify Proxy.

## Actor input object example

```json
{
  "searchTerms": [
    "hiring",
    "remote"
  ],
  "startUrls": [
    {
      "url": "https://www.facebook.com/NASA"
    },
    {
      "url": "https://www.facebook.com/groups/yourgroupid"
    }
  ],
  "matchMode": "any",
  "matchFields": [
    "text"
  ],
  "caseSensitive": false,
  "useRegex": false,
  "resultsLimit": 100,
  "maxPostsScannedPerSource": 300,
  "onlyPostsNewerThan": "2026-01-01",
  "onlyPostsOlderThan": "2026-06-01",
  "fallbackProvider": "auto",
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

## `dataset` (type: `string`):

No description

## `summary` (type: `string`):

No description

## `runSummary` (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 = {
    "searchTerms": [
        "mars",
        "moon"
    ],
    "startUrls": [
        {
            "url": "https://www.facebook.com/NASA"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("khadinakbar/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 = {
    "searchTerms": [
        "mars",
        "moon",
    ],
    "startUrls": [{ "url": "https://www.facebook.com/NASA" }],
}

# Run the Actor and wait for it to finish
run = client.actor("khadinakbar/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 '{
  "searchTerms": [
    "mars",
    "moon"
  ],
  "startUrls": [
    {
      "url": "https://www.facebook.com/NASA"
    }
  ]
}' |
apify call khadinakbar/facebook-post-search-scraper --silent --output-dataset

```

## MCP server setup

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