Blog / API guides

Facebook Marketplace API: Listings as JSON

A Facebook Marketplace API call returns public Marketplace listings as JSON without a browser or a parser. Three endpoints cover it: marketplace-search takes a query and a location, marketplace-browse takes a location, and marketplace-item takes a listing_id. Each successful call costs 1 credit, and failed calls cost nothing. This post covers the parameters, a cURL request, a weekly price-research job in Python and what that job costs.

Which endpoints return Marketplace listings?

Three of the 21 endpoints on the Facebook API deal with Marketplace, and they split the job by how you start. Search starts from what you want to find, browse starts from where you are, and item starts from a listing you already know. All three are GET, all three cost 1 credit per successful call, and all three return JSON.

Endpoint Starts from Required Optional Credits
GET /v1/facebook/marketplace-search A search term and a place none query, location 1
GET /v1/facebook/marketplace-browse A place none location 1
GET /v1/facebook/marketplace-item One listing listing_id none 1

The other Facebook endpoints cover pages, groups, events, posts and profiles. This post leaves them out: a price-research job needs listings, and nothing about the people who post them.

Which parameters do the Marketplace endpoints take?

The parameter list is short, and the reference documents types and lengths only. Every parameter is a string. Nothing else is documented about them, such as defaults, page sizes or how a location string is matched, so test the exact location values you plan to use in the playground before you schedule a job around them.

Endpoint Parameter Type Required Limit
marketplace-search query string no up to 200 characters
marketplace-search location string no up to 120 characters
marketplace-browse location string no up to 120 characters
marketplace-item listing_id string yes none stated

A request that breaks these rules, such as a query longer than 200 characters, comes back as invalid_parameters (422) and costs nothing. Values in a query string need URL encoding: a space becomes + or %20. The requests and responses docs cover the general request format.

How do you search Marketplace listings with cURL?

Send a GET request to the search endpoint with your key in the X-API-Key header. The request below asks for bike listings in San Francisco. Keys start with sk_live_, and you can also pass the key as the api_key query parameter where you can't set headers, as the authentication docs describe.

curl "https://api.perceptlayer.com/v1/facebook/marketplace-search?query=bike&location=San+Francisco" \
  -H "X-API-Key: $API_KEY"

To see what's listed in an area without a search term, call browse with just a location:

curl "https://api.perceptlayer.com/v1/facebook/marketplace-browse?location=San+Francisco" \
  -H "X-API-Key: $API_KEY"

And to fetch one listing, pass its ID:

curl "https://api.perceptlayer.com/v1/facebook/marketplace-item?listing_id=$LISTING_ID" \
  -H "X-API-Key: $API_KEY"

We don't have a recorded response for these endpoints yet, so this post doesn't show one. Run the search in the playground on the Facebook API page to see the response shape for your query and location before you write code that reads specific fields. Check there, too, whether search results carry an ID in the form marketplace-item expects.

What comes back on every call?

Whatever the body holds, the headers are documented. A successful response carries X-Credits-Used, the credits that call cost, and X-Credits-Remaining, your balance after it. Rate headers come with it: RateLimit-Limit, RateLimit-Remaining and RateLimit-Reset. Errors return an HTTP status and a JSON body with error.code, error.message and error.request_id.

What does a price-research job look like?

A price-research job asks the same questions every week and keeps every answer. Pick a fixed set of product queries and locations, run marketplace-search for each pair on a schedule, and store each raw response with the query, the location, the date and the credits it used. Fixed inputs matter more than volume: the same query in the same place, week after week, is what makes asking prices comparable over time.

Store the raw JSON rather than parsed fields. With no recorded response to build against, the safe first version keeps everything and decides what to extract later, once you've looked at real responses in the playground. That also means a change in the response shape never loses data: you still have the full body to re-read.

A weekly collector in Python

This script uses requests and the standard library. It runs each query in each location once, saves the response body and the credit headers to SQLite, and waits out a 429 using Retry-After. It reads no fields from the body, so it works whatever the listings look like.

import json
import os
import sqlite3
import time
from datetime import date

import requests

API = "https://api.perceptlayer.com/v1/facebook/marketplace-search"
HEADERS = {"X-API-Key": os.environ["API_KEY"]}

QUERIES = ["road bike", "standing desk", "espresso machine", "iphone 15"]
LOCATIONS = ["San Francisco", "Oakland", "San Jose"]

db = sqlite3.connect("marketplace.db")
db.execute(
    """CREATE TABLE IF NOT EXISTS runs (
        run_date TEXT, query TEXT, location TEXT,
        status INTEGER, credits_used TEXT, body TEXT,
        PRIMARY KEY (run_date, query, location)
    )"""
)


def search(query, location):
    params = {"query": query, "location": location}
    while True:
        resp = requests.get(API, headers=HEADERS, params=params, timeout=60)
        if resp.status_code == 429:
            time.sleep(int(resp.headers.get("Retry-After", "1")))
            continue
        return resp


today = date.today().isoformat()
for query in QUERIES:
    for location in LOCATIONS:
        resp = search(query, location)
        if resp.ok:
            body = json.dumps(resp.json())
        else:
            body = json.dumps(resp.json().get("error", {}))
        db.execute(
            "INSERT OR REPLACE INTO runs VALUES (?, ?, ?, ?, ?, ?)",
            (today, query, location, resp.status_code,
             resp.headers.get("X-Credits-Used"), body),
        )
        db.commit()
        time.sleep(1)  # stays inside the free tier's 1 request a second

print(db.execute(
    "SELECT status, COUNT(*) FROM runs WHERE run_date = ? GROUP BY status",
    (today,),
).fetchall())

The primary key on date, query and location means a rerun on the same day overwrites rather than duplicates. Failed rows keep the error body, so you can see which pairs failed and why, and they cost nothing. The errors docs list every code the job might store.

What should the job do with errors?

Treat each error code as an instruction. invalid_parameters (422) means a query or location breaks the documented limits, so fix the input. source_error (502) and temporarily_unavailable (503) are worth one retry later; a 503 carries Retry-After. insufficient_credits (402) means the balance is empty, and the job should stop rather than loop. restricted_endpoint (403) means the terms haven't been accepted on that account yet.

What does the weekly job cost?

Cost follows calls, and each search is 1 credit. The script above runs 4 queries × 3 locations = 12 calls a week, so 12 credits a week and 624 credits a year. A larger set of 10 queries in 4 locations is 40 calls × 1 credit = 40 credits a week, or 40 × 52 = 2,080 credits a year. The 100 free credits on signup cover the first 8 weeks of the smaller job and the first 2 weeks of the larger one. After that both need purchased credits, and the Starter pack's 10,000 covers either for a year.

Job Calls a week Credits a week Credits a year
4 queries × 3 locations 12 12 624
10 queries × 4 locations 40 40 2,080
50 queries × 20 locations 1,000 1,000 52,000
50 queries × 20 locations, plus 200 item lookups 1,200 1,200 62,400

The last two rows are a different scale. 1,000 calls a week is about 4,330 credits a month: the Starter pack's 10,000 credits covers a little over two months of it. Purchased credits last 12 months, and there's no subscription. At 1,000 calls a week, the free tier's 1 request a second gets through a run in under 17 minutes; paying accounts run at least 5 a second. See pricing for what credits cost and the credits docs for how they're debited.

What do the restricted-endpoint terms mean here?

The Facebook API has restricted endpoints, and they work only after you accept the restricted-endpoint terms in your dashboard. Until then a call returns restricted_endpoint (403) and costs nothing. The terms don't permit collecting personal data without a lawful basis, or using it to contact people. That shapes what a Marketplace job should keep.

Keep the job about listings and prices in aggregate: what a used road bike asks in Oakland this month, how asking prices for a model move over a quarter, how many listings a category has in a city. Don't build records of individual sellers, follow particular people across listings, or use anything you collect to message anyone. If a response contains seller details, drop them before storage, or keep only what the analysis needs.

Read Facebook's own terms before you build on its data, and get legal advice for commercial use. Data is collected from publicly available sources and returned as found at the time of the call, so a listing can sell or change between your call and your analysis.

How does this fit with other classifieds data?

Marketplace is one source of second-hand asking prices, and a price study usually needs more than one. Craigslist Scraper or API: Watching New Postings covers polling a classifieds search for new postings, and eBay Scraper or API: Prices Without the Parsing covers a marketplace where sold prices sit next to asking prices. The same key reaches all of them, and the API guides list the rest.

For an agent that answers questions such as "what do standing desks go for in San Jose", connect the MCP server instead of writing a collector; the AI agents docs cover the setup. To start, run marketplace-search with your own query and location in the playground on the Facebook API page, then get a free API key for the scheduled job.

APIs in this post

Frequently asked questions

Is there a Facebook Marketplace API for listings?

Yes, as endpoints in the Perceptlayer catalogue. GET /v1/facebook/marketplace-search searches by query and location, GET /v1/facebook/marketplace-browse lists by location, and GET /v1/facebook/marketplace-item returns one listing by listing_id. Each successful call costs 1 credit. They're restricted endpoints, so accept the restricted-endpoint terms in your dashboard first.

How much does a Facebook Marketplace search cost?

Each successful call costs 1 credit, whichever of the three endpoints you use. Failed calls cost nothing and return X-Credits-Used: 0. A weekly job of 10 queries in 4 locations is 40 credits a week. Every account gets 100 free credits after verifying an email, with no credit card.

Can I filter Marketplace results by price or category?

Not through documented parameters. Search takes only query and location, and browse takes only location. To study one price range, run a narrow query, store the full response and filter on your side after checking the fields in the playground. Keeping one fixed query per product makes the weeks comparable.

What happens when I hit the rate limit?

The call returns rate_limited (429) with a Retry-After header giving the seconds to wait, and it costs nothing. Limits are per account, shared by all its keys, and counted per minute. Free accounts get 1 request a second (60 a minute); paying accounts get at least 5 a second. The rate limits docs list each pack's rate.

Can I use Marketplace data to contact sellers?

No. The restricted-endpoint terms don't permit collecting personal data without a lawful basis or using it to contact people. Use Marketplace data for listings and prices in aggregate, such as typical asking prices by city or category over time, and leave seller details out of what you store.

  1. Craigslist Scraper or API: Watching New Postings

    Compare a Craigslist scraper with four endpoints at 1 credit a call: a recorded Portland bike search with 821 results, bumped_at times and a 3-call sweep.

  2. Kleinanzeigen API: Search German Classifieds as JSON

    Search Kleinanzeigen ads by query, city, category and price range with one GET call. Parameters, a real response and the cost: 1 credit per call.

  3. Craigslist API: Get Classified Postings as JSON

    Search Craigslist postings by site, category and price as JSON, then poll for new ones. A real response, the parameters and the credit cost.

Start with 100 free credits

No password to set. We email you a sign-in link, and your key works on every API.

No credit card. 100 free credits on signup.