# Facebook Marketplace Scraper (`drlacheheb/facebook-marketplace-scraper`) Actor

Self-healing, enterprise-grade scraper for Facebook Marketplace. Supports keyword search, direct URL scraping, and category discovery. Resilient to platform changes.

- **URL**: https://apify.com/drlacheheb/facebook-marketplace-scraper.md
- **Developed by:** [Ahmed Yacin](https://apify.com/drlacheheb) (community)
- **Categories:** E-commerce, Social media, Real estate
- **Stats:** 2 total users, 1 monthly users, 0.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.50 / 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.

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 Marketplace Premium Scraper

**Enterprise-Grade, Lightning-Fast Real-Time Data Extraction for Facebook Marketplace**

---

### ⚡ Overview
Welcome to the most resilient and powerful Facebook Marketplace scraper on the Apify Store. Built for real estate investors, car dealerships, dropshippers, and market analysts, this Actor delivers clean, real-time structured JSON data directly from Facebook Marketplace **without requiring logins, cookies, or browser automation**.

Powered by a custom high-performance asynchronous HTTP engine and dynamic GraphQL schema discovery, our self-healing architecture guarantees maximum uptime even when Facebook updates their internal API structures.

---

### 🔥 Why Choose This Scraper?
* 🛡️ **Zero Account Risk:** Completely anonymous scraping. You do not need to provide Facebook accounts, passwords, or cookies.
* ⚡ **Ultra-Low Latency:** Bypasses heavy browser automation overhead using proprietary network optimization. Runs up to 10x faster than traditional headless scrapers.
* 🔄 **Self-Healing Engine:** Automatically resolves dynamic GraphQL operation IDs to prevent scraper downtime during platform updates.
* 📊 **Bespoke UI Views:** Features dedicated UI tabs in the Apify Console so you can seamlessly toggle between **🛍️ Product Listings** and **🗂️ Category Tree** perspectives.

---

### 🎯 What Data Can You Extract?
When scraping marketplace listings or direct URLs, you receive rich structured records containing:
* 🆔 **Listing ID & Direct URL**
* 🏷️ **Product Title & Full Description**
* 💰 **Price (Formatted & Numeric for easy filtering)**
* 📍 **Seller City, State, & Precise GPS Coordinates (Lat/Long)**
* 🖼️ **Primary Thumbnail Preview & Full High-Res Gallery Array**
* 📦 **Delivery Method (Local Pickup vs Shipping)**
* 👤 **Seller ID & Name**
* 🔖 **Custom Listing Attributes (Brand, Model, Condition, Mileage)**

---

### 🛠️ Scraping Modes & Usage

This Actor provides three distinct operating modes selectable right from the Apify UI input form:

#### 1. 🔍 Keyword Search (`mode: search`)
Enter search terms (e.g., `"iPhone 15 Pro"`, `"Honda Civic"`, `"Office Chair"`), specify the target city (`"New York"`), set your price filters, radius, and sorting preference. The scraper will extract all top matching inventory in real time.

#### 2. 🔗 Direct Listing URLs (`mode: urls`)
Already have a list of specific Facebook Marketplace items? Paste up to 50 URLs directly into the input array to execute deep metadata extraction across all items simultaneously.

#### 3. 🗂️ Category Discovery (`mode: categories`)
Need to explore Facebook's active marketplace taxonomy? Run this mode to extract the complete category hierarchy and SEO slugs instantly.

---

### 📥 Input Configuration Preview

Here is an example of the configuration parameters you can set via the Apify UI or API:
```json
{
  "mode": "search",
  "query": "MacBook Pro M3",
  "location": "San Francisco",
  "radius_km": 50,
  "min_price": 800,
  "max_price": 2500,
  "sort_by": "creation_time_descend",
  "fetch_details": true
}
````

***

### 📤 Sample Output Preview

```json
[
  {
    "id": "123456789012345",
    "title": "MacBook Pro M3 Max 36GB RAM Flawless Condition",
    "price_formatted": "$2,200",
    "price_amount": 2200.0,
    "city": "San Francisco",
    "state": "CA",
    "listing_url": "https://www.facebook.com/marketplace/item/123456789012345/",
    "image_url": "https://scontent-sfo3-1.xx.fbcdn.net/v/t45.5328-4/...",
    "all_images": [
      "https://scontent-sfo3-1.xx.fbcdn.net/v/t45.5328-4/img1.jpg",
      "https://scontent-sfo3-1.xx.fbcdn.net/v/t45.5328-4/img2.jpg"
    ],
    "is_pending": false,
    "is_sold": false,
    "delivery_type": "LOCAL_PICKUP",
    "description": "Mint condition MacBook Pro M3 Max. Comes with AppleCare+ and original charger.",
    "seller_id": "9876543210",
    "seller_name": "Sarah Connor",
    "latitude": 37.7749,
    "longitude": -122.4194,
    "attributes": {
      "Condition": "Used - Like New",
      "Brand": "Apple",
      "Model": "MacBook Pro"
    }
  }
]
```

***

### 💲 Pricing & Monetization

This Actor operates on a highly cost-effective **Pay-per-Result** model:

- You only pay for successful items extracted (**$3.50 per 1,000 listings**).
- Zero wasted proxy bandwidth or execution fees on empty searches.

***

### ❓ Frequently Asked Questions

**Q: Do I need to provide Facebook accounts or cookies?**
A: **No.** Our scraper uses a proprietary request engine to query Facebook publicly and anonymously. Your personal accounts remain 100% safe.

**Q: Do I need to supply proxies?**
A: When running on the Apify Store, the Actor is fully integrated with Apify's Residential Proxy network. Just keep the default proxy setting enabled.

**Q: How fast does it scrape?**
A: Because our scraper uses highly optimized asynchronous network queries rather than resource-heavy headless browsers, standard searches and deep extractions complete in seconds rather than minutes.

# Actor input Schema

## `mode` (type: `string`):

What to scrape. 'search' runs a keyword search, 'urls' scrapes specific listing URLs, 'categories' returns the category tree.

## `fetch_details` (type: `boolean`):

If true, performs a second request per listing to retrieve description, GPS, seller info, and all images. Slower but more complete.

## `query` (type: `string`):

The keyword(s) to search for.

## `location` (type: `string`):

City or region to search in (e.g. 'New York', 'London', 'Toronto').

## `max_pages` (type: `integer`):

Number of result pages to scrape (1–5). Each page yields ~24 listings.

## `min_price` (type: `integer`):

Minimum listing price filter in USD.

## `max_price` (type: `integer`):

Maximum listing price filter in USD.

## `radius_km` (type: `integer`):

Search radius from the specified location in kilometres.

## `sort_by` (type: `string`):

Sorting order for search results.

## `category_id` (type: `string`):

Optional. Restrict search to a specific category. Get IDs from 'categories' mode.

## `urls` (type: `array`):

List of direct Facebook Marketplace listing URLs to scrape.

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

Select proxies to be used by your scraper. Residential proxies are recommended for Facebook.

## Actor input object example

```json
{
  "mode": "search",
  "fetch_details": true,
  "query": "laptop",
  "location": "New York",
  "max_pages": 1,
  "min_price": 0,
  "max_price": 1000000,
  "radius_km": 65,
  "sort_by": "best_match",
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

## `products` (type: `string`):

Clean tabular view of scraped marketplace product listings and deep URL extracts.

## `categories` (type: `string`):

Clean tabular view of scraped marketplace category hierarchy and taxonomy slugs.

# 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 = {
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("drlacheheb/facebook-marketplace-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 = { "proxyConfiguration": { "useApifyProxy": True } }

# Run the Actor and wait for it to finish
run = client.actor("drlacheheb/facebook-marketplace-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 '{
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}' |
apify call drlacheheb/facebook-marketplace-scraper --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Facebook Marketplace Scraper",
        "description": "Self-healing, enterprise-grade scraper for Facebook Marketplace. Supports keyword search, direct URL scraping, and category discovery. Resilient to platform changes.",
        "version": "1.0",
        "x-build-id": "65limPwNrmEK9EiiR"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/drlacheheb~facebook-marketplace-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-drlacheheb-facebook-marketplace-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/drlacheheb~facebook-marketplace-scraper/runs": {
            "post": {
                "operationId": "runs-sync-drlacheheb-facebook-marketplace-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/drlacheheb~facebook-marketplace-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-drlacheheb-facebook-marketplace-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",
                "properties": {
                    "mode": {
                        "title": "Scraping Mode",
                        "enum": [
                            "search",
                            "urls",
                            "categories"
                        ],
                        "type": "string",
                        "description": "What to scrape. 'search' runs a keyword search, 'urls' scrapes specific listing URLs, 'categories' returns the category tree.",
                        "default": "search"
                    },
                    "fetch_details": {
                        "title": "Fetch Full Details",
                        "type": "boolean",
                        "description": "If true, performs a second request per listing to retrieve description, GPS, seller info, and all images. Slower but more complete.",
                        "default": true
                    },
                    "query": {
                        "title": "Search Query",
                        "type": "string",
                        "description": "The keyword(s) to search for.",
                        "default": "laptop"
                    },
                    "location": {
                        "title": "Location",
                        "type": "string",
                        "description": "City or region to search in (e.g. 'New York', 'London', 'Toronto').",
                        "default": "New York"
                    },
                    "max_pages": {
                        "title": "Max Pages",
                        "minimum": 1,
                        "maximum": 5,
                        "type": "integer",
                        "description": "Number of result pages to scrape (1–5). Each page yields ~24 listings.",
                        "default": 1
                    },
                    "min_price": {
                        "title": "Min Price ($)",
                        "minimum": 0,
                        "type": "integer",
                        "description": "Minimum listing price filter in USD.",
                        "default": 0
                    },
                    "max_price": {
                        "title": "Max Price ($)",
                        "minimum": 0,
                        "type": "integer",
                        "description": "Maximum listing price filter in USD.",
                        "default": 1000000
                    },
                    "radius_km": {
                        "title": "Search Radius (km)",
                        "minimum": 1,
                        "maximum": 500,
                        "type": "integer",
                        "description": "Search radius from the specified location in kilometres.",
                        "default": 65
                    },
                    "sort_by": {
                        "title": "Sort By",
                        "enum": [
                            "best_match",
                            "price_low_to_high",
                            "price_high_to_low",
                            "distance_ascend",
                            "creation_time_descend"
                        ],
                        "type": "string",
                        "description": "Sorting order for search results.",
                        "default": "best_match"
                    },
                    "category_id": {
                        "title": "Category ID",
                        "type": "string",
                        "description": "Optional. Restrict search to a specific category. Get IDs from 'categories' mode."
                    },
                    "urls": {
                        "title": "Listing URLs",
                        "type": "array",
                        "description": "List of direct Facebook Marketplace listing URLs to scrape.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "proxyConfiguration": {
                        "title": "Proxy configuration",
                        "type": "object",
                        "description": "Select proxies to be used by your scraper. Residential proxies are recommended for Facebook."
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
