# Facebook Post Scraper (`pratikdani/facebook-post-scraper`) Actor

The Facebook Post Scraper Actor is a powerful tool designed to extract detailed information from Facebook posts using valid Facebook Post URLs. It provides comprehensive data about posts, including user information, engagement metrics, media attachments, and more.

- **URL**: https://apify.com/pratikdani/facebook-post-scraper.md
- **Developed by:** [Pratik Dani](https://apify.com/pratikdani) (community)
- **Categories:** Social media, Developer tools, Lead generation
- **Stats:** 605 total users, 51 monthly users, 96.8% runs succeeded, 21 bookmarks
- **User rating**: 4.91 out of 5 stars

## Pricing

from $15.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.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use 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 Scraper

### Overview
The Facebook Post Scraper Actor is a powerful tool designed to extract detailed information from Facebook posts using valid Facebook Post URLs. It provides comprehensive data about posts, including user information, engagement metrics, media attachments, and more.
Interested in using this scraper? Get it here: [Facebook Post Scraper](https://apify.com/pratikdani/facebook-post-scraper).

### Features
- Extracts complete post metadata and content
- Captures engagement metrics (likes, comments, shares)
- Retrieves user profile information
- Supports various post types (text, video, images)
- Extracts hashtags and external links
- Provides detailed attachment information
- Tracks engagement metrics with reaction types
- Captures video-specific metrics (view count, play count)

### Output Fields

| Field Name | Type | Description |
|------------|------|-------------|
| url | String | The complete URL of the Facebook post |
| post_id | String | Unique identifier of the post |
| user_url | String | URL of the post author's profile |
| user_username_raw | String | Display name of the post author |
| content | String | Text content of the post |
| date_posted | ISO Date | Timestamp of when the post was published |
| hashtags | Array[String] | List of hashtags used in the post |
| num_comments | Number | Total number of comments on the post |
| num_shares | Number | Total number of times the post was shared |
| num_likes_type | Array[Object] | Breakdown of reactions by type (Like, Love, Care, etc.) |
| profile_id | String | Unique identifier of the author's profile |
| page_logo | String | URL of the page's logo image |
| page_likes | Number | Total number of page likes |
| page_followers | Number | Total number of page followers |
| page_is_verified | Boolean | Verification status of the page |
| attachments | Array[Object] | List of media attachments (videos, images) |
| post_external_link | String | External URL shared in the post |
| post_external_title | String | Title of the shared external content |
| video_view_count | Number | Number of views for video content |
| likes | Number | Total number of likes on the post |
| post_type | String | Type of the post (Post, Video, Photo, etc.) |
| play_count | Number | Number of times video content was played |


### Example Output

```json
[
  {
    "url": "https://www.facebook.com/arian.n.180/videos/524608810606709/",
    "post_id": "524608810606709",
    "user_url": "https://www.facebook.com/arian.n.180",
    "user_username_raw": "Arian N",
    "content": "#MLBB",
    "date_posted": "2024-12-28T17:39:18.000Z",
    "hashtags": [
      "mlbb"
    ],
    "num_comments": 0,
    "num_shares": null,
    "num_likes_type": [
      {
        "num": 2,
        "type": "Love"
      },
      {
        "num": 1,
        "type": "Like"
      },
      {
        "num": 1,
        "type": "Care"
      }
    ],
    "profile_id": "pfbid02U2fJN3vcuHmK2FTTixTyjW1jiPHMJR6BCQtDUbHnnxGUkMrtZkprpFwWZPQZuZnMl",
    "page_logo": "https://scontent.fagc3-1.fna.fbcdn.net/v/t39.30808-1/469937812_1074943467695755_4772604338151325423_n.jpg?stp=c0.512.1536.1536a_dst-jpg_s200x200_tt6&_nc_cat=110&ccb=1-7&_nc_sid=e99d92&_nc_ohc=2PDFwe3GhJUQ7kNvgHA0hdv&_nc_zt=24&_nc_ht=scontent.fagc3-1.fna&_nc_gid=AezP--yKNlC9P3HVrQ_G4MF&oh=00_AYBtoMjLbBUUoDOC13fbeldrUnPksVB1g2xi2-25OzNpdQ&oe=67915D4D",
    "page_likes": null,
    "page_followers": null,
    "page_is_verified": false,
    "original_post": {
      "attachments": null,
      "content": null,
      "date": null,
      "hashtags": null,
      "post_external_link": null,
      "post_external_title": null,
      "post_id": null,
      "post_url": null,
      "user_id": null,
      "user_name": null,
      "user_url": null
    },
    "attachments": [
      {
        "attachment_url": null,
        "id": "524608810606709",
        "source_type": null,
        "type": "Video",
        "url": "https://www.facebook.com/arian.n.180/videos/524608810606709/",
        "video_length": "39845"
      }
    ],
    "post_external_link": null,
    "post_external_title": null,
    "page_url": "https://www.facebook.com/arian.n.180",
    "header_image": "https://www.facebook.com/photo/?fbid=642117680978338&set=a.642117830978323",
    "avatar_image_url": "https://scontent-mia3-3.xx.fbcdn.net/v/t39.30808-1/469937812_1074943467695755_4772604338151325423_n.jpg?stp=c0.512.1536.1536a_cp0_dst-jpg_s40x40_tt6&_nc_cat=110&ccb=1-7&_nc_sid=e99d92&_nc_ohc=2PDFwe3GhJUQ7kNvgHcXhPs&_nc_zt=24&_nc_ht=scontent-mia3-3.xx&_nc_gid=AiKRgoofCpUox8ZZZ5AMvxy&oh=00_AYANe4ldWO7y4KgucJ08iyVBMoQHiMOJFkgAEVbAJ1jAIA&oe=67915D4D",
    "profile_handle": "arian.n.180",
    "has_handshake": null,
    "is_sponsored": false,
    "sponsor_name": null,
    "shortcode": "524608810606709",
    "video_view_count": 31,
    "likes": 1,
    "post_image": null,
    "post_type": "Post",
    "user_handle": "arian.n.180",
    "play_count": 73
  }
]
````

# Actor input Schema

## `url` (type: `string`):

URL of the Facebook Post

## Actor input object example

```json
{
  "url": "https://www.facebook.com/share/p/gep5QPJZNa81fYdu/"
}
```

# 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 = {
    "url": "https://www.facebook.com/share/p/gep5QPJZNa81fYdu/"
};

// Run the Actor and wait for it to finish
const run = await client.actor("pratikdani/facebook-post-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 = { "url": "https://www.facebook.com/share/p/gep5QPJZNa81fYdu/" }

# Run the Actor and wait for it to finish
run = client.actor("pratikdani/facebook-post-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 '{
  "url": "https://www.facebook.com/share/p/gep5QPJZNa81fYdu/"
}' |
apify call pratikdani/facebook-post-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Facebook Post Scraper",
        "description": "The Facebook Post Scraper Actor is a powerful tool designed to extract detailed information from Facebook posts using valid Facebook Post URLs. It provides comprehensive data about posts, including user information, engagement metrics, media attachments, and more.",
        "version": "0.0",
        "x-build-id": "MUIxgzHQ94KarVX4P"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/pratikdani~facebook-post-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-pratikdani-facebook-post-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/pratikdani~facebook-post-scraper/runs": {
            "post": {
                "operationId": "runs-sync-pratikdani-facebook-post-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/pratikdani~facebook-post-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-pratikdani-facebook-post-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "url"
                ],
                "properties": {
                    "url": {
                        "title": "Facebook Post Scraper",
                        "type": "string",
                        "description": "URL of the Facebook Post"
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
