Facebook Posts API and Posts Scraper
Send the link of a Facebook post, a permalink, a photo or a share link and get the post as JSON: its text, publication time, author, the photos and videos attached to it, the shared link card and the reaction, comment and share counts.
Request
GET /v1/facebook/posts ·
2 credits per successful call
curl "https://api.igramapi.com/v1/facebook/posts?url=https%3A%2F%2Fwww.facebook.com%2Fexamplestudio%2Fposts%2Fpfbid02ExampleToken" \
-H "Authorization: Bearer YOUR_API_KEY" import requests
response = requests.get(
"https://api.igramapi.com/v1/facebook/posts?url=https%3A%2F%2Fwww.facebook.com%2Fexamplestudio%2Fposts%2Fpfbid02ExampleToken",
headers={"Authorization": "Bearer YOUR_API_KEY"},
timeout=30,
)
response.raise_for_status()
print(response.json()) const response = await fetch("https://api.igramapi.com/v1/facebook/posts?url=https%3A%2F%2Fwww.facebook.com%2Fexamplestudio%2Fposts%2Fpfbid02ExampleToken", {
method: "GET",
headers: {
Authorization: "Bearer YOUR_API_KEY",
},
});
if (!response.ok) throw new Error((await response.json()).error.message);
console.log(await response.json()); <?php
$ch = curl_init("https://api.igramapi.com/v1/facebook/posts?url=https%3A%2F%2Fwww.facebook.com%2Fexamplestudio%2Fposts%2Fpfbid02ExampleToken");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer YOUR_API_KEY",
],
]);
$data = json_decode(curl_exec($ch), true);
print_r($data); Response
{
"id": "3456789012345678",
"url": "https://www.facebook.com/examplestudio/posts/pfbid02ExampleToken",
"message": "Doors open on Saturday. Come and say hello!",
"created_at": 1761700000,
"author": {
"id": "100012345678901",
"name": "Example Studio",
"url": "https://www.facebook.com/examplestudio",
"avatar_url": "https://scontent.xx.fbcdn.net/v/example/avatar.jpg",
"is_verified": true
},
"media": [
{
"id": "4567890123456789",
"type": "photo",
"url": "https://scontent.xx.fbcdn.net/v/example/photo.jpg",
"width": 960,
"height": 540,
"alt_text": "The studio entrance with a welcome banner"
}
],
"link_preview": null,
"stats": {
"likes": 372,
"comments": 40,
"shares": 46,
"views_str": null
},
"cached": false
} All values above are made-up examples. Media links are temporary Facebook CDN addresses.
Parameters
| Name | In | Description |
|---|---|---|
urlrequired | query | The post's link: a /posts/ URL, a permalink.php or photo.php link, or a facebook.com/share/p/ link. |
Response fields
| Field | Type | Description |
|---|---|---|
id / url | string | Post id (or pfbid token) and its canonical link. |
message / created_at | string | null / integer | null | Post text and the Unix time it was published. |
author | object | id, name, url, avatar_url and is_verified of the page or person. |
media[] | object[] | Attached photos and videos: id, type, url, video_url (MP4, videos only), width, height, alt_text. |
link_preview | object | null | Shared link card: title, url, source and thumbnail_url. |
stats | object | likes (all reactions), comments, shares, and views_str for videos. |
cached | boolean | True when served from the short-lived cache. |
Every kind of link
Post URLs, permalink.php, photo links and share links all work, so you can pass whatever your users paste.
Text, media and link card
The message, every attached photo or video with a direct CDN link, and the link card of a shared page in one response.
Public counters
Reactions, comments and shares as integers, null when Facebook hides them.
The author included
The page or person that posted, with id, name, link, avatar and the verified flag.
What the Facebook post endpoint returns
The response describes one post. message is the text, created_at is the Unix time it was published, and author identifies the page or person. media[] lists the photos and videos attached to it, each with a direct CDN link, its size and the alt text, when Facebook provides one. For a video, url is the preview image and video_url is the MP4 file.
stats.likes counts all reactions on the post, not only likes. stats.views_str is only filled for video posts and is a formatted string such as 1.5M, not an integer.
Links and temporary files
Facebook identifies newer posts with long pfbid tokens in the link. They are part of the URL you send and need no special handling.
Links to media in the response are temporary CDN addresses. They work for a while and then expire, so do not store them as permanent references. Fetch the file soon after the call if you need a copy.
One post at a time
The endpoint reads the single post you link to. To list a page's posts with pagination, use the Facebook Profile Posts API, and to read comments under a post, use the Facebook Comments API.
Frequently asked questions
Is this a Facebook posts scraper?
It returns what a Facebook posts scraper collects (text, time, author, attached photos and videos, link card and engagement counts for a public post) as JSON from one link, so you do not run or maintain a scraper yourself.
Which Facebook links does the post endpoint accept?
Post links, permalink.php?story_fbid=, photo.php?fbid=, /photos/ links and facebook.com/share/p/ share links.
Can I read the comments of a post?
This endpoint returns the total comment count in stats.comments. To list the comments themselves, use the Facebook Comments API.
Which posts are not available?
Posts that were deleted, are not public or need a login return HTTP 404 with the code post_not_found.
Can it read group posts?
No. Group posts are not available.
How fresh are the numbers?
They come from Facebook at request time. A post's data may be served from a cache of up to 30 minutes, and cached tells you when.
Our errors cost nothing. Failures on our side (status 500 or above) and invalid requests (400, 422) are refunded, and every error has the same shape. See error handling and credits and rate limits.
Try the Facebook Post API free
Create a key and make your first request in minutes. 100 free credits every month.