# Facebook Marketplace 🛍️ Listings & Prices — Only $3/1K 💰 (`viralanalyzer/facebook-marketplace-scraper`) Actor

Extract Facebook Marketplace listings with title, price, location, images, and optional full details (description, seller, condition, category). No API key needed.

- **URL**: https://apify.com/viralanalyzer/facebook-marketplace-scraper.md
- **Developed by:** [viralanalyzer](https://apify.com/viralanalyzer) (community)
- **Categories:** E-commerce, Lead generation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 listing scrapeds

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — 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 Scraper 🛍️ Listings & Prices — Only $3/1K 💰

Extract Facebook Marketplace listings with title, price, location, images — and optional full details (description, seller, condition, category). No API key needed.

> ⚠️ **Honest login notice**: Facebook Marketplace shows **full search results only when logged in**. Without a session, guest results are often **zero or heavily limited**. For reliable runs, paste cookies from a logged-in `facebook.com` session into the `cookies` input (JSON array) and use **RESIDENTIAL** proxy groups. The actor handles login walls gracefully: it returns a diagnostic item instead of failing silently (never charges for it).

***

### Input

| Field | Type | Default | Description |
|---|---|---|---|
| `searchQueries` | string\[] | `["iPhone"]` | **Required.** Keywords to search. One search per keyword. |
| `locations` | string\[] | `[]` | Optional cities/areas (e.g. `"Sao Paulo, Brazil"`). One search per query × location. |
| `maxListings` | int | `10` | Max listings per run (1–50). Free-tier non-owner runs are capped at **5**. |
| `fetchDetails` | bool | `false` | Open each listing to extract description, seller, condition, category, posted date. Slower. Forced OFF on free-tier. |
| `cookies` | JSON array | `[]` | Session cookies from a logged-in `facebook.com` session. **Recommended for full results.** |
| `proxyConfig` | proxy editor | Apify proxy ON | Use **RESIDENTIAL** groups if datacenter IPs get blocked. |

#### Example input

```json
{
  "searchQueries": ["iPhone 13", "bicicleta aro 29"],
  "locations": ["Sao Paulo, Brazil"],
  "maxListings": 20,
  "fetchDetails": true,
  "cookies": [],
  "proxyConfig": { "useApifyProxy": true, "groups": ["RESIDENTIAL"] }
}
```

***

### Output

Each dataset item:

| Field | Type | Notes |
|---|---|---|
| `url` | string | Listing URL (`/marketplace/item/{id}/`). **Contract-required.** |
| `title` | string | Listing title. **Contract-required.** |
| `price` | number | Parsed numeric price (e.g. `1499.0`). `null` when not visible. |
| `formatted_price` | string | Raw price text (e.g. `"R$ 1.499"`). |
| `currency` | string | `BRL` / `USD` / ... inferred from the formatted price. |
| `location` | string | City/area. |
| `image_urls` | string\[] | Image URLs. |
| `listing_id` | string | Marketplace listing ID. |
| `category` | string | Category (details mode). |
| `posted_at` | string | ISO date (API mode) or relative text (DOM mode). |
| `seller_name` | string | Seller name (details mode). |
| `condition` | string | New/Used/... (details mode). |
| `description` | string | Full description (details mode). |
| `searchQuery` / `inputLocation` | string | Which query/location produced the item. |
| `scrapedAt` | string | UTC ISO timestamp of collection. |
| `_dataQuality` | string | `full` (GraphQL), `dom_only` (DOM fallback), `full_details` (details enriched), `diagnostic` (guard item). |

> Invisible fields are `null` — the actor never fabricates data.

***

### Pricing 💰

- **Pay-per-event**: event `listing-scraped` — **$3 per 1,000 listings** ($0.003 each).
- Charged **only** for valid items (contract: `url` + `title` present).
- **Never** charged for diagnostic/guard runs (login wall, blocked, region unsupported).
- **Free tier**: non-owner, non-paying runs are capped at **5 listings** and `fetchDetails` is forced OFF.

***

### Anti-bot & reliability

- **Strategy cascade**: GraphQL API interception (`/api/graphql/`, strips the `for (;;);` prefix) → embedded JSON → DOM fallback.
- **Login wall / checkpoint / region block** detection routes to a diagnostic item (`setup_status: "DIAGNOSTIC_GUIDE"`) + `SUCCEEDED`, with actionable remediations.
- **Residential proxy retry**: if the first attempt yields zero items, the actor retries once with `RESIDENTIAL`.
- **Debug artifacts** (screenshot + HTML) are saved to the KV Store whenever a search returns zero items.
- Idempotent by design: re-running the same input produces the same items (no external state).

***

### 🇧🇷 Português

Coleta anúncios do Facebook Marketplace por palavra-chave (e opcionalmente por local). Campos: título, preço (número + texto formatado), moeda, localização, imagens, ID do anúncio, categoria, data de publicação e — com `fetchDetails` — descrição, vendedor, condição e categoria detalhada.

**Aviso honesto**: o Marketplace mostra resultados completos **apenas logado**. Para resultados confiáveis, cole cookies de uma sessão logada no campo `cookies` e use proxy **RESIDENTIAL**. Quando há bloqueio/muro de login, o actor devolve um item diagnóstico (nunca cobra por ele).

**Preço**: evento `listing-scraped` — **US$ 3 por 1.000 anúncios** (US$ 0,003 cada), cobrado só por itens válidos. Tier grátis (não-dono): máximo 5 anúncios por execução, `fetchDetails` forçado OFF.

***

*Built for the ViralAnalyzer ecosystem · `OWNER_USER_ID` runs skip charges (test mode).*

# Actor input Schema

## `searchQueries` (type: `array`):

Keywords to search on Facebook Marketplace. One search is executed per keyword. Required.

## `locations` (type: `array`):

Optional cities/areas to scope the search (e.g. 'Sao Paulo, Brazil'). One search is executed per query × location. Leave empty to use the default marketplace area.

## `maxListings` (type: `integer`):

Maximum number of listings to collect per run. Free-tier non-owner runs are capped at 5.

## `fetchDetails` (type: `boolean`):

Open each listing page to extract description, seller\_name, condition, category, posted date, price and location. Slower (1 page load per listing). Forced OFF on free-tier non-owner runs.

## `cookies` (type: `array`):

JSON array of cookies from a logged-in facebook.com session (name, value, domain, path). Marketplace shows full results only when logged in — paste cookies from your browser (EditThisCookie / DevTools) to bypass the login wall. If empty, the actor seeds base session cookies via the homepage, which may yield guest-limited results.

## `proxyConfig` (type: `object`):

Apify Proxy configuration. Use RESIDENTIAL groups when datacenter IPs get blocked by Facebook.

## Actor input object example

```json
{
  "searchQueries": [
    "iPhone"
  ],
  "locations": [],
  "maxListings": 10,
  "fetchDetails": false,
  "cookies": [],
  "proxyConfig": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

## `results` (type: `string`):

View and export the scraped listings in the Dataset tab.

# 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 = {
    "searchQueries": [
        "iPhone"
    ],
    "locations": [],
    "cookies": [],
    "proxyConfig": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("viralanalyzer/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 = {
    "searchQueries": ["iPhone"],
    "locations": [],
    "cookies": [],
    "proxyConfig": { "useApifyProxy": True },
}

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

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

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

```

## CLI example

```bash
echo '{
  "searchQueries": [
    "iPhone"
  ],
  "locations": [],
  "cookies": [],
  "proxyConfig": {
    "useApifyProxy": true
  }
}' |
apify call viralanalyzer/facebook-marketplace-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,viralanalyzer/facebook-marketplace-scraper"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/yaeCGlM5sqUf1sEkr/builds/i394F9upccYKHkY9X/openapi.json
