Get public Facebook data as JSON without a Meta developer app, App Review or access token. The Facebook Scraper API returns Marketplace search results, category listings and item details, a Page's posts, single posts with their reaction breakdown and comment threads, public groups and their feeds, and the Ad Library: ads with their copy and run dates, advertiser Pages, and Page transparency such as owner, admin countries and ad spend. This repo has a runnable Python, Node.js and cURL example for the main endpoints and the real response each one returned.
A Facebook scraper collects public data from Facebook, such as Marketplace listings and prices, posts with reactions, shares and comments, and ads from the Ad Library, and returns it as structured data. Resellers use it to track Marketplace prices, marketers to follow competitors' posts and ads, and analysts to study engagement. With this API you send a keyword, Page name, post ID or ad ID and get JSON back.
- Quick start
- Endpoints
- Common parameters
- Examples by endpoint
- Example output
- Use it with AI agents (MCP)
- Use cases
- Pricing
- Errors
- FAQ
- Other languages
- Related scrapers
- Learn more
-
Create a free ScrapeBadger account. You get 1,000 free credits, no card needed.
-
Copy your API key from the dashboard and export it:
export SCRAPEBADGER_API_KEY="your_api_key"
-
Make your first request: search Marketplace.
cURL
curl -sS --max-time 120 -G "https://scrapebadger.com/v1/facebook/marketplace/search" \
-H "X-API-Key: $SCRAPEBADGER_API_KEY" \
--data-urlencode 'query=road bike' \
--data-urlencode 'location=nyc'Python (pip install requests)
import json
import os
import requests
API_KEY = os.environ["SCRAPEBADGER_API_KEY"]
response = requests.get(
"https://scrapebadger.com/v1/facebook/marketplace/search",
headers={"X-API-Key": API_KEY},
params={
"query": "road bike",
"location": "nyc",
},
timeout=120,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2, ensure_ascii=False))Node.js (18+, no dependencies)
const params = new URLSearchParams({
query: 'road bike',
location: 'nyc',
});
const response = await fetch(`https://scrapebadger.com/v1/facebook/marketplace/search?${params}`, {
headers: { 'X-API-Key': process.env.SCRAPEBADGER_API_KEY },
signal: AbortSignal.timeout(120000),
});
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${await response.text()}`);
}
console.log(JSON.stringify(await response.json(), null, 2));Every endpoint below has the same three versions in examples/, and the real response it returned is in output-samples/.
Base URL: https://scrapebadger.com. Authenticate with the X-API-Key header. Credits are charged only for successful requests.
| Endpoint | What it returns | Credits per request | Docs |
|---|---|---|---|
GET /v1/facebook/marketplace/search |
Search Marketplace | 10 | Docs |
GET /v1/facebook/marketplace/category/{category} |
Browse a Marketplace category | 10 | Docs |
GET /v1/facebook/marketplace/item/{item_id} |
Get a Marketplace item | 10 | Docs |
GET /v1/facebook/marketplace/locations |
List locations | Free | Docs |
GET /v1/facebook/marketplace/locations/resolve |
Resolve a town/postcode to a Marketplace location | Free | |
GET /v1/facebook/marketplace/categories |
List categories | Free | Docs |
GET /v1/facebook/groups/{group_id} |
Get group detail | 10 | Docs |
GET /v1/facebook/groups/{group_id}/posts |
Get group posts | 10 | |
GET /v1/facebook/posts/{post_id} |
Get post detail | 10 | Docs |
GET /v1/facebook/posts/{post_id}/comments |
Get post comments | 20 | Docs |
GET /v1/facebook/pages/{identifier} |
Get page detail | 10 | Docs |
GET /v1/facebook/pages/{identifier}/posts |
Get page posts | 10 | Docs |
GET /v1/facebook/profiles/{identifier} |
Get profile detail | 10 | |
GET /v1/facebook/profiles/{identifier}/posts |
Get profile posts | 10 | |
GET /v1/facebook/ads/search |
Search the Ad Library | 10 | Docs |
GET /v1/facebook/ads/pages/search |
Search advertiser pages | 10 | Docs |
GET /v1/facebook/ads/pages/{page_id} |
Get advertiser page info | 10 | |
GET /v1/facebook/ads/{ad_archive_id} |
Get an ad | 10 |
| Parameter | Description | Default |
|---|---|---|
after |
Cursor from the previous response (end_cursor), to get the next page while has_next_page is true. |
|
location |
Marketplace location slug such as nyc, la, london or sydney, or a numeric Facebook place ID. GET /v1/facebook/marketplace/locations lists common slugs. |
nyc |
country |
Ad Library country as a two-letter code, e.g. US, GB, DE. An EU country adds EU transparency data to ad lookups. |
US |
Each example prints the JSON response. The Python versions are below; Node.js and cURL versions are linked under each one.
Search Facebook Marketplace listings by keyword in a city, with price, age, condition and delivery filters. Results come in pages; follow end_cursor while has_next_page is true.
GET /v1/facebook/marketplace/search · Credits: 10 · Docs
| Parameter | Required | Type | Default | Description |
|---|---|---|---|---|
query |
Yes | string | Search keywords, or an advertiser name in the Ad Library | |
location |
string | nyc |
Marketplace location slug (nyc, la, london) or a numeric Facebook place ID. A town name such as Durham, UK is rejected; resolve it with GET /v1/facebook/marketplace/locations/resolve. |
|
min_price |
integer | Lowest price, in the location's currency | ||
max_price |
integer | Highest price, in the location's currency | ||
days_since_listed |
integer | Only listings posted in the last N days, 1 to 30 |
||
sort_by |
string | best_match, price_ascend, price_descend, distance_ascend or creation_time_descend |
||
item_condition |
string | Comma-separated, any of new, used_like_new, used_good, used_fair |
||
delivery_method |
string | local_pick_up or shipping |
||
radius |
integer | Radius around the location, 1 to 500 (always km with strict_filters=true) |
||
after |
string | Cursor from the previous response (end_cursor), to get the next page while has_next_page is true. |
||
strict_filters |
boolean | false |
Enforce radius, age and price bounds on every returned listing | |
include_details |
boolean | false |
Add full descriptions, photos and approximate coordinates to each listing |
import json
import os
import requests
API_KEY = os.environ["SCRAPEBADGER_API_KEY"]
response = requests.get(
"https://scrapebadger.com/v1/facebook/marketplace/search",
headers={"X-API-Key": API_KEY},
params={
"query": "road bike",
"location": "nyc",
},
timeout=120,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2, ensure_ascii=False))Node.js · cURL · Output sample (55 KB)
Browse Marketplace listings in a category (vehicles, electronics, ...).
GET /v1/facebook/marketplace/category/{category} · Credits: 10 · Docs
| Parameter | Required | Type | Default | Description |
|---|---|---|---|---|
category |
Yes | string | Marketplace category slug, e.g. vehicles, electronics, propertyrentals. GET /v1/facebook/marketplace/categories lists them. |
|
location |
string | nyc |
Marketplace location slug (nyc, la, london) or a numeric Facebook place ID. A town name such as Durham, UK is rejected; resolve it with GET /v1/facebook/marketplace/locations/resolve. |
|
min_price |
integer | Lowest price, in the location's currency | ||
max_price |
integer | Highest price, in the location's currency | ||
sort_by |
string | best_match, price_ascend, price_descend, distance_ascend or creation_time_descend |
||
radius |
integer | Radius around the location, 1 to 500 (always km with strict_filters=true) |
||
after |
string | Cursor from the previous response (end_cursor), to get the next page while has_next_page is true. |
import json
import os
import requests
API_KEY = os.environ["SCRAPEBADGER_API_KEY"]
category = "vehicles"
response = requests.get(
f"https://scrapebadger.com/v1/facebook/marketplace/category/{category}",
headers={"X-API-Key": API_KEY},
params={
"location": "la",
"min_price": 5000,
},
timeout=120,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2, ensure_ascii=False))Node.js · cURL · Output sample (88 KB)
Get a Facebook Page's timeline posts.
GET /v1/facebook/pages/{identifier}/posts · Credits: 10 · Docs
| Parameter | Required | Type | Default | Description |
|---|---|---|---|---|
identifier |
Yes | string | Page username or numeric Page ID, e.g. NASA |
|
after |
string | Cursor from the previous response (end_cursor), to get the next page while has_next_page is true. |
import json
import os
import requests
API_KEY = os.environ["SCRAPEBADGER_API_KEY"]
identifier = "NASA"
response = requests.get(
f"https://scrapebadger.com/v1/facebook/pages/{identifier}/posts",
headers={"X-API-Key": API_KEY},
timeout=120,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2, ensure_ascii=False))Node.js · cURL · Output sample (8 KB)
Get a Facebook post's detail: text, media, author, date and the reaction / comment / share counts. The comments themselves come from /posts/{post_id}/comments.
GET /v1/facebook/posts/{post_id} · Credits: 10 · Docs
| Parameter | Required | Type | Default | Description |
|---|---|---|---|---|
post_id |
Yes | string | Numeric post ID, e.g. 1703771617784874 (or pass the full post URL in url) |
|
url |
string | Full post permalink/reel URL — overrides post_id |
import json
import os
import requests
API_KEY = os.environ["SCRAPEBADGER_API_KEY"]
post_id = "1703771617784874"
response = requests.get(
f"https://scrapebadger.com/v1/facebook/posts/{post_id}",
headers={"X-API-Key": API_KEY},
timeout=120,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2, ensure_ascii=False))Node.js · cURL · Output sample (2 KB)
Get a Facebook post's comment thread, 10 per page.
GET /v1/facebook/posts/{post_id}/comments · Credits: 20 · Docs
| Parameter | Required | Type | Default | Description |
|---|---|---|---|---|
post_id |
Yes | string | Numeric post ID, e.g. 1703771617784874 (or pass the full post URL in url) |
|
url |
string | Full post permalink/reel URL — overrides post_id | ||
after |
string | Cursor from the previous response (end_cursor), to get the next page while has_next_page is true. |
||
sort |
string | relevance |
relevance | newest |
import json
import os
import requests
API_KEY = os.environ["SCRAPEBADGER_API_KEY"]
post_id = "1703771617784874"
response = requests.get(
f"https://scrapebadger.com/v1/facebook/posts/{post_id}/comments",
headers={"X-API-Key": API_KEY},
timeout=120,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2, ensure_ascii=False))Node.js · cURL · Output sample (6 KB)
Search the Facebook Ad Library.
GET /v1/facebook/ads/search · Credits: 10 · Docs
| Parameter | Required | Type | Default | Description |
|---|---|---|---|---|
query |
Yes | string | Search keywords, or an advertiser name in the Ad Library | |
country |
string | US |
Ad Library country as a two-letter code, e.g. US, GB, DE. An EU country adds EU transparency data to ad lookups. |
|
ad_type |
string | all |
all or political_and_issue_ads |
|
active_status |
string | active |
active, inactive or all |
|
after |
string | Cursor from the previous response (end_cursor), to get the next page while has_next_page is true. |
import json
import os
import requests
API_KEY = os.environ["SCRAPEBADGER_API_KEY"]
response = requests.get(
"https://scrapebadger.com/v1/facebook/ads/search",
headers={"X-API-Key": API_KEY},
params={
"query": "nike",
"country": "US",
},
timeout=120,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2, ensure_ascii=False))Node.js · cURL · Output sample (98 KB)
Search advertiser Pages in the Ad Library — returns page ids, categories, likes/followers, verification and Instagram handles.
GET /v1/facebook/ads/pages/search · Credits: 10 · Docs
| Parameter | Required | Type | Default | Description |
|---|---|---|---|---|
query |
Yes | string | Search keywords, or an advertiser name in the Ad Library | |
country |
string | US |
Ad Library country as a two-letter code, e.g. US, GB, DE. An EU country adds EU transparency data to ad lookups. |
import json
import os
import requests
API_KEY = os.environ["SCRAPEBADGER_API_KEY"]
response = requests.get(
"https://scrapebadger.com/v1/facebook/ads/pages/search",
headers={"X-API-Key": API_KEY},
params={
"query": "nike",
"country": "US",
},
timeout=120,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2, ensure_ascii=False))Node.js · cURL · Output sample (12 KB)
Get a single Ad Library ad by its archive id. For EU/UK-targeted ads the response also includes transparency insights (payer/beneficiary, total EU reach, and age/gender/country reach breakdowns).
GET /v1/facebook/ads/{ad_archive_id} · Credits: 10
| Parameter | Required | Type | Default | Description |
|---|---|---|---|---|
ad_archive_id |
Yes | string | Ad Library ID of the ad, the ad_archive_id on a search result |
|
country |
string | US |
Ad Library country as a two-letter code, e.g. US, GB, DE. An EU country adds EU transparency data to ad lookups. |
import json
import os
import requests
API_KEY = os.environ["SCRAPEBADGER_API_KEY"]
ad_archive_id = "2723246144798476"
response = requests.get(
f"https://scrapebadger.com/v1/facebook/ads/{ad_archive_id}",
headers={"X-API-Key": API_KEY},
params={
"country": "US",
},
timeout=120,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2, ensure_ascii=False))Node.js · cURL · Output sample (2 KB)
Get advertiser page info: category, followers, page transparency (creation date, name history, managing organization, admin-account locations), related pages, and ad spend (for political/issue advertisers).
GET /v1/facebook/ads/pages/{page_id} · Credits: 10
| Parameter | Required | Type | Default | Description |
|---|---|---|---|---|
page_id |
Yes | string | Numeric Page ID of the advertiser, the page_id on an ad or advertiser search result |
|
country |
string | US |
Ad Library country as a two-letter code, e.g. US, GB, DE. An EU country adds EU transparency data to ad lookups. |
import json
import os
import requests
API_KEY = os.environ["SCRAPEBADGER_API_KEY"]
page_id = "15087023444"
response = requests.get(
f"https://scrapebadger.com/v1/facebook/ads/pages/{page_id}",
headers={"X-API-Key": API_KEY},
params={
"country": "US",
},
timeout=120,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2, ensure_ascii=False))Node.js · cURL · Output sample (3 KB)
List Marketplace category slugs (free).
GET /v1/facebook/marketplace/categories · Credits: Free · Docs
import json
import os
import requests
API_KEY = os.environ["SCRAPEBADGER_API_KEY"]
response = requests.get(
"https://scrapebadger.com/v1/facebook/marketplace/categories",
headers={"X-API-Key": API_KEY},
timeout=120,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2, ensure_ascii=False))Node.js · cURL · Output sample (1 KB)
List common Marketplace location slugs (free).
GET /v1/facebook/marketplace/locations · Credits: Free · Docs
import json
import os
import requests
API_KEY = os.environ["SCRAPEBADGER_API_KEY"]
response = requests.get(
"https://scrapebadger.com/v1/facebook/marketplace/locations",
headers={"X-API-Key": API_KEY},
timeout=120,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2, ensure_ascii=False))Node.js · cURL · Output sample (1 KB)
A real response from GET /v1/facebook/marketplace/search, trimmed to the first items of each list. The full response is in output-samples/marketplace-search.json.
{
"listings": [
{
"id": "3790925127725162",
"title": "Kent RoadTech Road Bike",
"custom_title": null,
"url": "https://www.facebook.com/marketplace/item/3790925127725162/",
"price_formatted": "$40",
"price_amount": "40.00",
"amount_with_offset": "4000",
"strikethrough_price": "$60",
"min_price": null,
"max_price": null,
"currency": null,
"primary_photo": "https://scontent.fluk1-1.fna.fbcdn.net/v/t39.84726-6/857639733_1151437317239524_4152626250022365830_n.jpg?stp=c43.0.260.260a_dst-jpg_p261x260_tt6&_nc_cat=102&_nc_map=urlgen_bucketless&ccb=1-7&_nc_sid=92e707&_nc_ohc=RYV99…",
"photos": [
"https://scontent.fluk1-1.fna.fbcdn.net/v/t39.84726-6/857639733_1151437317239524_4152626250022365830_n.jpg?stp=c43.0.260.260a_dst-jpg_p261x260_tt6&_nc_cat=102&_nc_map=urlgen_bucketless&ccb=1-7&_nc_sid=92e707&_nc_ohc=RYV99…"
],
"creation_time_utc": 1792736164.0,
"created_at": "2026-10-23T06:16:04Z",
"location_text": "New York, New York",
"city": "Flushing",
"state": "NY",
"city_page_id": "108424279189115",
"latitude": null,
"longitude": null,
"category_id": "1658310421102081",
"subtitles": [],
"delivery_types": [
"IN_PERSON"
],
"is_sold": false,
"is_pending": false,
"is_live": true,
"is_hidden": false,
"seller": {
"id": "61556293995071",
"name": "Jamar Carter",
"url": null,
"profile_picture": null,
"is_verified": null,
"typename": "User"
},
"description": null,
"attributes": {},
"condition": null,
"condition_label": null,
"vehicle": null,
"category_slug": null,
"category_name": null,
"category_path": [],
"postal_code": null,
"country_code": null,
"media": [
{
"type": "photo",
"id": "1151437310572858",
"url": "https://scontent.fluk1-1.fna.fbcdn.net/v/t39.84726-6/857639733_1151437317239524_4152626250022365830_n.jpg?stp=c43.0.260.260a_dst-jpg_p261x260_tt6&_nc_cat=102&_nc_map=urlgen_bucketless&ccb=1-7&_nc_sid=92e707&_nc_ohc=RYV99…",
"hd_url": null,
"thumbnail_url": null,
…ScrapeBadger runs a hosted MCP server, so Claude, Cursor, ChatGPT and other agents can call the Facebook endpoints as tools, with no code.
- Claude (claude.ai or Claude Desktop): Settings → Connectors → Add custom connector →
https://mcp.scrapebadger.com/mcp, then sign in. No API key needed. - Cursor, VS Code, Windsurf and other clients: add this server to your MCP config:
{
"mcpServers": {
"scrapebadger": {
"url": "https://mcp.scrapebadger.com/mcp?apis=facebook",
"headers": { "Authorization": "Bearer YOUR_SCRAPEBADGER_API_KEY" }
}
}
}Then ask:
Find road bikes under $500 on Facebook Marketplace in New York and list the 10 cheapest with their links.
Setup guides for each client are in the MCP docs.
| Use case | What you collect | Endpoints |
|---|---|---|
| Marketplace price tracking | Listings for a keyword or category in a city, with price, location, photos and listing date | Search Marketplace, Browse a Marketplace category |
| Competitor content tracking | A brand's recent posts with reactions, comments and shares | Get a Page's posts, Get a post |
| Comment and sentiment analysis | The comment thread on any public post, with reactions and reply counts | Get a post's comments |
| Ad research | Ads a brand runs, their copy, call to action, run dates and platforms | Search the Ad Library, Get an ad, Search advertiser Pages |
| Advertiser due diligence | Who owns a Page, where its admins are, its name history and political ad spend | Get advertiser Page info |
- Each endpoint's credit cost is listed in the endpoints table.
- Only successful requests are billed. Blocked, empty and failed results cost nothing.
- New accounts get 1,000 free credits. After that, pay as you go or pick a monthly plan. Credits on pay-as-you-go never expire.
See ScrapeBadger pricing for the price per credit on each plan.
Errors come back as JSON with a detail field (and an error code on some).
| Status | Meaning | What to do |
|---|---|---|
400 / 422 |
A parameter is missing or invalid | Check the parameter table for the endpoint |
401 |
Missing, invalid or expired API key | Send the key in the X-API-Key header |
402 |
Out of credits | Top up or upgrade in the dashboard |
403 |
The key can't call this API, or the request came from an IP the key doesn't allow | Check the key's scopes and IP allowlist |
404 |
The item, page or profile doesn't exist (or is no longer public) | Check the ID; not billed |
429 |
Over your account's max concurrency | Wait Retry-After (1 s) and retry; run fewer calls in parallel (concurrency) |
502 / 503 / 504 |
The target site failed or timed out on this attempt | Not billed. Retry with backoff |
Long calls can run asynchronously: send Prefer: respond-async and poll the returned request_id (async requests).
Is it legal to scrape Facebook?
This API only returns public data: Marketplace listings, public Pages, groups and posts, and the public Ad Library. Collecting public data is generally lawful in most jurisdictions, but posts, comments and listings can contain personal data, so check the rules that apply to how you store and use them (for example GDPR), and ask a lawyer if you're unsure.
Do I need a Meta developer app or access token?
No. You only need a ScrapeBadger API key. There's no App Review, no OAuth token and no Page you have to own. Facebook's Graph API has no Marketplace data at all; this API returns it.
How much does it cost?
Each request costs a fixed number of credits, shown in the endpoints table, and only successful requests are billed. You get 1,000 free credits when you sign up, then pay as you go or pick a plan on the pricing page.
Which countries are supported?
Marketplace is searched by location: pass a city slug such as nyc, london, toronto or sydney, or resolve any town or postcode with GET /v1/facebook/marketplace/locations/resolve. The Ad Library takes any two-letter country code in country. Pages, groups and posts are global.
How fast is it, and are there rate limits?
Most calls answer in 3 to 5 seconds. There's no per-minute cap: you can run as many requests in parallel as your plan's max concurrency allows, and a request over it gets 429 without being billed.
These examples use plain HTTP. Official SDKs wrap every endpoint with types and retries:
| Language | Repository | Install |
|---|---|---|
| Python | scrape-badger/scrapebadger-python | pip install scrapebadger |
| Node.js / TypeScript | scrape-badger/scrapebadger-node | npm install scrapebadger |
| Go | scrape-badger/scrapebadger-go | |
| Java | scrape-badger/scrapebadger-java | |
| C# | scrape-badger/scrapebadger-csharp | |
| PHP | scrape-badger/scrapebadger-php | |
| Ruby | scrape-badger/scrapebadger-ruby | |
| Rust | scrape-badger/scrapebadger-rust | |
| Kotlin | scrape-badger/scrapebadger-kotlin | |
| Swift | scrape-badger/scrapebadger-swift | |
| Dart | scrape-badger/scrapebadger-dart | |
| C++ | scrape-badger/scrapebadger-cpp |
There is also a CLI (pip install scrapebadger-cli) and an n8n node.
- Instagram Scraper API: Public profiles, posts, reels, comments, hashtags and search
- TikTok Scraper API: Profiles, videos, comments, hashtags, sounds, search and TikTok Shop
- Twitter Scraper API: Tweets, advanced search, profiles, followers, lists, communities and trends
- LinkedIn Scraper API: Jobs, companies, schools, public profiles and posts
- Facebook Scraper API: features, pricing and a live playground
- Facebook API documentation
ScrapeBadger is an independent tool and is not affiliated with, endorsed by, or sponsored by Facebook or Meta Platforms, Inc. or any of its subsidiaries or affiliates. "Facebook" is a trademark of Meta Platforms, Inc., used here only to describe the platform this scraper works with. This repository only covers publicly available data. You are responsible for how you use the data you collect and for following the laws that apply to you.
MIT. The examples are free to copy into your own projects.
