# Facebook Posts Scraper

Scrape Facebook Posts with one tool - pay-as-you-go, no monthly subscription. Collect profile posts, get profile details by page URL or ID, or get a profile ID from a URL.

## Actor Statistics

- Total users: 1
- Monthly users: 1
- Runs succeeded: 0.00%
- Categories: Social media, Automation, Developer tools

## Pricing

$6.00 / 1,000 results

## Input Schema

- **endpoint** (type: string): Choose what to fetch.
- **urls\_text** (type: string): Use for: Profile posts by URL, Profile details by URL, Profile ID by URL. Paste one URL/username per line.
- **ids\_text** (type: string): Use for: Profile posts by ID, Profile details by ID. Paste one profile\_id per line.
- **max\_posts** (type: integer): Optional. Limit how many posts to collect per profile. Set 0 (default) to fetch all available.
- **start\_date** (type: string): Optional filter for Profile posts.
- **end\_date** (type: string): Optional filter for Profile posts.

## API example

## Facebook Posts Scraper

- **OpenAPI Version:** `3.1.1`
- **API Version:** `0.0`

Scrape Facebook Posts with one tool - pay-as-you-go, no monthly subscription. Collect profile posts, get profile details by page URL or ID, or get a profile ID from a URL.

### Servers

- **URL:** `https://api.apify.com/v2`

### Operations

#### Executes an Actor, waits for its completion, and returns Actor's dataset items in response.

- **Method:** `POST`
- **Path:** `/acts/cleansyntax~facebook-posts-scraper/run-sync-get-dataset-items`
- **Tags:** Run Actor

##### Request Body

###### Content-Type: application/json

- **`endpoint` (required)**

  `string`, possible values: `"profile_posts_by_url", "profile_posts", "details_by_id", "details_by_url", "profile_id_by_url"` — Choose what to fetch.

- **`end_date`**

  `string` — Optional filter for Profile posts.

- **`ids_text`**

  `string` — Use for: Profile posts by ID, Profile details by ID. Paste one profile\_id per line.

- **`max_posts`**

  `integer` — Optional. Limit how many posts to collect per profile. Set 0 (default) to fetch all available.

- **`start_date`**

  `string` — Optional filter for Profile posts.

- **`urls_text`**

  `string` — Use for: Profile posts by URL, Profile details by URL, Profile ID by URL. Paste one URL/username per line.

**Example:**

```
{
  "endpoint": "profile_posts_by_url",
  "urls_text": "",
  "ids_text": "",
  "max_posts": 1,
  "start_date": "",
  "end_date": ""
}
```

##### Responses

###### Status: 200 OK

#### Executes an Actor and returns information about the initiated run in response.

- **Method:** `POST`
- **Path:** `/acts/cleansyntax~facebook-posts-scraper/runs`
- **Tags:** Run Actor

##### Request Body

###### Content-Type: application/json

- **`endpoint` (required)**

  `string`, possible values: `"profile_posts_by_url", "profile_posts", "details_by_id", "details_by_url", "profile_id_by_url"` — Choose what to fetch.

- **`end_date`**

  `string` — Optional filter for Profile posts.

- **`ids_text`**

  `string` — Use for: Profile posts by ID, Profile details by ID. Paste one profile\_id per line.

- **`max_posts`**

  `integer` — Optional. Limit how many posts to collect per profile. Set 0 (default) to fetch all available.

- **`start_date`**

  `string` — Optional filter for Profile posts.

- **`urls_text`**

  `string` — Use for: Profile posts by URL, Profile details by URL, Profile ID by URL. Paste one URL/username per line.

**Example:**

```
{
  "endpoint": "profile_posts_by_url",
  "urls_text": "",
  "ids_text": "",
  "max_posts": 1,
  "start_date": "",
  "end_date": ""
}
```

##### Responses

###### Status: 200 OK

\####### Content-Type: application/json

- **`data`**

  `object`

  - **`actId`**

    `string`

  - **`buildId`**

    `string`

  - **`buildNumber`**

    `string`

  - **`containerUrl`**

    `string`

  - **`defaultDatasetId`**

    `string`

  - **`defaultKeyValueStoreId`**

    `string`

  - **`defaultRequestQueueId`**

    `string`

  - **`finishedAt`**

    `string`, format: `date-time`

  - **`id`**

    `string`

  - **`meta`**

    `object`

    - **`origin`**

      `string`

    - **`userAgent`**

      `string`

  - **`options`**

    `object`

    - **`build`**

      `string`

    - **`diskMbytes`**

      `integer`

    - **`memoryMbytes`**

      `integer`

    - **`timeoutSecs`**

      `integer`

  - **`startedAt`**

    `string`, format: `date-time`

  - **`stats`**

    `object`

    - **`computeUnits`**

      `integer`

    - **`inputBodyLen`**

      `integer`

    - **`rebootCount`**

      `integer`

    - **`restartCount`**

      `integer`

    - **`resurrectCount`**

      `integer`

  - **`status`**

    `string`

  - **`usage`**

    `object`

    - **`ACTOR_COMPUTE_UNITS`**

      `integer`

    - **`DATA_TRANSFER_EXTERNAL_GBYTES`**

      `integer`

    - **`DATA_TRANSFER_INTERNAL_GBYTES`**

      `integer`

    - **`DATASET_READS`**

      `integer`

    - **`DATASET_WRITES`**

      `integer`

    - **`KEY_VALUE_STORE_LISTS`**

      `integer`

    - **`KEY_VALUE_STORE_READS`**

      `integer`

    - **`KEY_VALUE_STORE_WRITES`**

      `integer`

    - **`PROXY_RESIDENTIAL_TRANSFER_GBYTES`**

      `integer`

    - **`PROXY_SERPS`**

      `integer`

    - **`REQUEST_QUEUE_READS`**

      `integer`

    - **`REQUEST_QUEUE_WRITES`**

      `integer`

  - **`usageTotalUsd`**

    `number`

  - **`usageUsd`**

    `object`

    - **`ACTOR_COMPUTE_UNITS`**

      `integer`

    - **`DATA_TRANSFER_EXTERNAL_GBYTES`**

      `integer`

    - **`DATA_TRANSFER_INTERNAL_GBYTES`**

      `integer`

    - **`DATASET_READS`**

      `integer`

    - **`DATASET_WRITES`**

      `integer`

    - **`KEY_VALUE_STORE_LISTS`**

      `integer`

    - **`KEY_VALUE_STORE_READS`**

      `integer`

    - **`KEY_VALUE_STORE_WRITES`**

      `number`

    - **`PROXY_RESIDENTIAL_TRANSFER_GBYTES`**

      `integer`

    - **`PROXY_SERPS`**

      `integer`

    - **`REQUEST_QUEUE_READS`**

      `integer`

    - **`REQUEST_QUEUE_WRITES`**

      `integer`

  - **`userId`**

    `string`

**Example:**

```
{
  "data": {
    "id": "",
    "actId": "",
    "userId": "",
    "startedAt": "2025-01-08T00:00:00.000Z",
    "finishedAt": "2025-01-08T00:00:00.000Z",
    "status": "READY",
    "meta": {
      "origin": "API",
      "userAgent": ""
    },
    "stats": {
      "inputBodyLen": 2000,
      "rebootCount": 0,
      "restartCount": 0,
      "resurrectCount": 0,
      "computeUnits": 0
    },
    "options": {
      "build": "latest",
      "timeoutSecs": 300,
      "memoryMbytes": 1024,
      "diskMbytes": 2048
    },
    "buildId": "",
    "defaultKeyValueStoreId": "",
    "defaultDatasetId": "",
    "defaultRequestQueueId": "",
    "buildNumber": "1.0.0",
    "containerUrl": "",
    "usage": {
      "ACTOR_COMPUTE_UNITS": 0,
      "DATASET_READS": 0,
      "DATASET_WRITES": 0,
      "KEY_VALUE_STORE_READS": 0,
      "KEY_VALUE_STORE_WRITES": 1,
      "KEY_VALUE_STORE_LISTS": 0,
      "REQUEST_QUEUE_READS": 0,
      "REQUEST_QUEUE_WRITES": 0,
      "DATA_TRANSFER_INTERNAL_GBYTES": 0,
      "DATA_TRANSFER_EXTERNAL_GBYTES": 0,
      "PROXY_RESIDENTIAL_TRANSFER_GBYTES": 0,
      "PROXY_SERPS": 0
    },
    "usageTotalUsd": 0.00005,
    "usageUsd": {
      "ACTOR_COMPUTE_UNITS": 0,
      "DATASET_READS": 0,
      "DATASET_WRITES": 0,
      "KEY_VALUE_STORE_READS": 0,
      "KEY_VALUE_STORE_WRITES": 0.00005,
      "KEY_VALUE_STORE_LISTS": 0,
      "REQUEST_QUEUE_READS": 0,
      "REQUEST_QUEUE_WRITES": 0,
      "DATA_TRANSFER_INTERNAL_GBYTES": 0,
      "DATA_TRANSFER_EXTERNAL_GBYTES": 0,
      "PROXY_RESIDENTIAL_TRANSFER_GBYTES": 0,
      "PROXY_SERPS": 0
    }
  }
}
```

#### Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.

- **Method:** `POST`
- **Path:** `/acts/cleansyntax~facebook-posts-scraper/run-sync`
- **Tags:** Run Actor

##### Request Body

###### Content-Type: application/json

- **`endpoint` (required)**

  `string`, possible values: `"profile_posts_by_url", "profile_posts", "details_by_id", "details_by_url", "profile_id_by_url"` — Choose what to fetch.

- **`end_date`**

  `string` — Optional filter for Profile posts.

- **`ids_text`**

  `string` — Use for: Profile posts by ID, Profile details by ID. Paste one profile\_id per line.

- **`max_posts`**

  `integer` — Optional. Limit how many posts to collect per profile. Set 0 (default) to fetch all available.

- **`start_date`**

  `string` — Optional filter for Profile posts.

- **`urls_text`**

  `string` — Use for: Profile posts by URL, Profile details by URL, Profile ID by URL. Paste one URL/username per line.

**Example:**

```
{
  "endpoint": "profile_posts_by_url",
  "urls_text": "",
  "ids_text": "",
  "max_posts": 1,
  "start_date": "",
  "end_date": ""
}
```

##### Responses

###### Status: 200 OK

### Schemas

#### inputSchema

- **Type:**`object`

* **`endpoint` (required)**

  `string`, possible values: `"profile_posts_by_url", "profile_posts", "details_by_id", "details_by_url", "profile_id_by_url"` — Choose what to fetch.

* **`end_date`**

  `string` — Optional filter for Profile posts.

* **`ids_text`**

  `string` — Use for: Profile posts by ID, Profile details by ID. Paste one profile\_id per line.

* **`max_posts`**

  `integer` — Optional. Limit how many posts to collect per profile. Set 0 (default) to fetch all available.

* **`start_date`**

  `string` — Optional filter for Profile posts.

* **`urls_text`**

  `string` — Use for: Profile posts by URL, Profile details by URL, Profile ID by URL. Paste one URL/username per line.

**Example:**

```
{
  "endpoint": "profile_posts_by_url",
  "urls_text": "",
  "ids_text": "",
  "max_posts": 1,
  "start_date": "",
  "end_date": ""
}
```

#### runsResponseSchema

- **Type:**`object`

* **`data`**

  `object`

  - **`actId`**

    `string`

  - **`buildId`**

    `string`

  - **`buildNumber`**

    `string`

  - **`containerUrl`**

    `string`

  - **`defaultDatasetId`**

    `string`

  - **`defaultKeyValueStoreId`**

    `string`

  - **`defaultRequestQueueId`**

    `string`

  - **`finishedAt`**

    `string`, format: `date-time`

  - **`id`**

    `string`

  - **`meta`**

    `object`

    - **`origin`**

      `string`

    - **`userAgent`**

      `string`

  - **`options`**

    `object`

    - **`build`**

      `string`

    - **`diskMbytes`**

      `integer`

    - **`memoryMbytes`**

      `integer`

    - **`timeoutSecs`**

      `integer`

  - **`startedAt`**

    `string`, format: `date-time`

  - **`stats`**

    `object`

    - **`computeUnits`**

      `integer`

    - **`inputBodyLen`**

      `integer`

    - **`rebootCount`**

      `integer`

    - **`restartCount`**

      `integer`

    - **`resurrectCount`**

      `integer`

  - **`status`**

    `string`

  - **`usage`**

    `object`

    - **`ACTOR_COMPUTE_UNITS`**

      `integer`

    - **`DATA_TRANSFER_EXTERNAL_GBYTES`**

      `integer`

    - **`DATA_TRANSFER_INTERNAL_GBYTES`**

      `integer`

    - **`DATASET_READS`**

      `integer`

    - **`DATASET_WRITES`**

      `integer`

    - **`KEY_VALUE_STORE_LISTS`**

      `integer`

    - **`KEY_VALUE_STORE_READS`**

      `integer`

    - **`KEY_VALUE_STORE_WRITES`**

      `integer`

    - **`PROXY_RESIDENTIAL_TRANSFER_GBYTES`**

      `integer`

    - **`PROXY_SERPS`**

      `integer`

    - **`REQUEST_QUEUE_READS`**

      `integer`

    - **`REQUEST_QUEUE_WRITES`**

      `integer`

  - **`usageTotalUsd`**

    `number`

  - **`usageUsd`**

    `object`

    - **`ACTOR_COMPUTE_UNITS`**

      `integer`

    - **`DATA_TRANSFER_EXTERNAL_GBYTES`**

      `integer`

    - **`DATA_TRANSFER_INTERNAL_GBYTES`**

      `integer`

    - **`DATASET_READS`**

      `integer`

    - **`DATASET_WRITES`**

      `integer`

    - **`KEY_VALUE_STORE_LISTS`**

      `integer`

    - **`KEY_VALUE_STORE_READS`**

      `integer`

    - **`KEY_VALUE_STORE_WRITES`**

      `number`

    - **`PROXY_RESIDENTIAL_TRANSFER_GBYTES`**

      `integer`

    - **`PROXY_SERPS`**

      `integer`

    - **`REQUEST_QUEUE_READS`**

      `integer`

    - **`REQUEST_QUEUE_WRITES`**

      `integer`

  - **`userId`**

    `string`

**Example:**

```
{
  "data": {
    "id": "",
    "actId": "",
    "userId": "",
    "startedAt": "2025-01-08T00:00:00.000Z",
    "finishedAt": "2025-01-08T00:00:00.000Z",
    "status": "READY",
    "meta": {
      "origin": "API",
      "userAgent": ""
    },
    "stats": {
      "inputBodyLen": 2000,
      "rebootCount": 0,
      "restartCount": 0,
      "resurrectCount": 0,
      "computeUnits": 0
    },
    "options": {
      "build": "latest",
      "timeoutSecs": 300,
      "memoryMbytes": 1024,
      "diskMbytes": 2048
    },
    "buildId": "",
    "defaultKeyValueStoreId": "",
    "defaultDatasetId": "",
    "defaultRequestQueueId": "",
    "buildNumber": "1.0.0",
    "containerUrl": "",
    "usage": {
      "ACTOR_COMPUTE_UNITS": 0,
      "DATASET_READS": 0,
      "DATASET_WRITES": 0,
      "KEY_VALUE_STORE_READS": 0,
      "KEY_VALUE_STORE_WRITES": 1,
      "KEY_VALUE_STORE_LISTS": 0,
      "REQUEST_QUEUE_READS": 0,
      "REQUEST_QUEUE_WRITES": 0,
      "DATA_TRANSFER_INTERNAL_GBYTES": 0,
      "DATA_TRANSFER_EXTERNAL_GBYTES": 0,
      "PROXY_RESIDENTIAL_TRANSFER_GBYTES": 0,
      "PROXY_SERPS": 0
    },
    "usageTotalUsd": 0.00005,
    "usageUsd": {
      "ACTOR_COMPUTE_UNITS": 0,
      "DATASET_READS": 0,
      "DATASET_WRITES": 0,
      "KEY_VALUE_STORE_READS": 0,
      "KEY_VALUE_STORE_WRITES": 0.00005,
      "KEY_VALUE_STORE_LISTS": 0,
      "REQUEST_QUEUE_READS": 0,
      "REQUEST_QUEUE_WRITES": 0,
      "DATA_TRANSFER_INTERNAL_GBYTES": 0,
      "DATA_TRANSFER_EXTERNAL_GBYTES": 0,
      "PROXY_RESIDENTIAL_TRANSFER_GBYTES": 0,
      "PROXY_SERPS": 0
    }
  }
}
```

## 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 = {
    "endpoint": "profile_posts_by_url",
    "urls_text": "https://www.facebook.com/TaylorSwift",
    "max_posts": 0
};

// Run the Actor and wait for it to finish
const run = await client.actor("cleansyntax/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 = {
    "endpoint": "profile_posts_by_url",
    "urls_text": "https://www.facebook.com/TaylorSwift",
    "max_posts": 0,
}

# Run the Actor and wait for it to finish
run = client.actor("cleansyntax/facebook-posts-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "endpoint": "profile_posts_by_url",
  "urls_text": "https://www.facebook.com/TaylorSwift",
  "max_posts": 0
}' |
apify call cleansyntax/facebook-posts-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?actors=cleansyntax/facebook-posts-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

**📘 Facebook Posts Scraper**

Scrape Facebook Posts — recent **profile posts**, **profile details** (by ID or URL), and **profile ID lookup** — powered by our **Facebook Scraper**.

***

### ✨ Features

- **Profile posts**: Fetch public profile posts **by ID** or **by URL**.
- **Profile details**: Retrieve rich profile metadata **by ID** or **by URL**.
- **Profile ID lookup**: Resolve a profile **ID** from a URL

### 🧭 Endpoints

Choose one endpoint per run:

1. **`profile_posts_by_url`**
   `GET /profile/posts?profile_url=...&start_date=YYYY-MM-DD&end_date=YYYY-MM-DD`

2. **`profile_posts_by_id`**
   `GET /profile/posts?profile_id=...&start_date=YYYY-MM-DD&end_date=YYYY-MM-DD`

3. **`details_by_id`**
   `GET /profile/details_id?profile_id=...`

4. **`details_by_url`**
   `GET /profile/details_url?url=...`

5. **`profile_id_by_url`**
   `GET /profile/profile_id?url=...`

***

### 🚀 How It Works

1. Pick the **endpoint** in the Actor input (dropdown).
2. Fill only the parameter(s) required for that endpoint.
3. Run the Actor.

   - For **Profile posts**, the Actor:

     - Calls `GET /profile/posts?profile_url/id=...` (+ optional `start_date`, `end_date`),
     - Pushes posts to the dataset,
     - Continues with `GET /profile/posts?profile_url/id=...` until finished.

All results are stored in the **default Apify Dataset**, ready to export as **CSV**, **XLSX**, or **JSON**.

***

### 🧾 Input

#### Fields

- **`endpoint`** *(required)* — one of:

  - `profile_posts_by_id`
  - `profile_posts_by_url`
  - `details_by_id`
  - `details_by_url`
  - `profile_id_by_url`
- **`profile_id`** *(string)* — required for `profile_posts`, `details_by_id`
- **`profile_url`** *(string)* — required for `profile_posts`, `details_by_url`
- **`url`** *(string)* — required for `details_by_url`, `profile_id_by_url`
- **`start_date`** *(YYYY-MM-DD, optional)* — filter for `profile_posts`
- **`end_date`** *(YYYY-MM-DD, optional)* — filter for `profile_posts`

### 📦 Output

All results are saved as items in the **default Apify Dataset**.

#### Profile posts

Each dataset item is a **post** object from the API, plus helper fields:

- `profile_url or profile_id (search term)` — the URL or ID you queried

Common fields (may vary):
`post_id`, `type`, `url`, `message`, `timestamp`, `comments_count`, `reactions_count`, `reshare_count`, `reactions` (object), `author` (object), media (`image`, `video`, `video_files`, `video_thumbnail`, `album_preview`, `external_url`).

#### Profile details (by ID / by URL)

Single record with profile metadata (structure depends on API). We push `results` if present, otherwise the raw payload, plus:

- `profile_id (search term)` **or** `url (search term)`

#### Profile ID by URL

Single record containing the resolved **profile ID**, plus:

- `url (search term)`

> Export via **Dataset → Export** in the Apify UI (CSV, XLSX, JSON).

### 🧠 Reliability & Pagination

- **Pagination**: Automatically keeps requesting until the API stops returning profile posts.
- **Retries**: 3 attempts with a 5s backoff for transient failures (e.g., 429/5xx).
- **Polite delay**: A short delay between requests helps reduce rate-limit hits.
- **Minimal logs**: Progress lines look like:

  ```
  total posts collected 3
  total posts collected 6
  ```

***

### 🛡️ Best Practices

- Use realistic workloads; although the Actor retries on 429/503, excessive calling can still be throttled.
- For very large profiles, consider narrowing **date filters** or splitting runs.
- Profiles must be **public** for data to be returned by the API.

***

### 🔧 Troubleshooting

- **422 `Field required: profile_id`**
  The API requires `profile_id` even when using a `cursor`. This Actor always includes it; ensure your input has `profile_id` filled.

- **429 Rate limited**
  The Actor retries up to 3 times with a 5s delay. If it persists, slow down or split the job.

- **No posts returned**
  The profile may be private, there may be no posts, or your date range excludes available posts.

- **Empty details/ID**
  Double-check the URL/ID. Some profiles or URLs may not resolve or be supported.

### 📈 SEO Keywords

facebook post scraper, scrape facebook posts, facebook profile details api, facebook profile id lookup, apify actor facebook, facebook cursor pagination, export facebook posts csv, facebook profile details by url, facebook profile details by id, automate facebook scraping
