Use Facebook Marketplace Listing & Price Extractor with Python
Extract public Facebook Marketplace listings by city feed, category, keyword search, or direct item URL, with price, location, photos, delivery method, seller, and listing status per item.
1. Choose the data you need
Review the published README for supported collection modes, examples, and limits. The recipe below uses the current published input definition.
2. Prepare a source-based input
This JSON contains published prefills and required-field defaults. Review every value for your task before running it; it is not a promise of successful collection.
{
"availability": "all",
"category": "all",
"condition": "any",
"country": "US",
"deduplicateAcrossInputs": true,
"deliveryMethod": "all",
"exactMatch": false,
"includeAllPhotos": false,
"includeListingDetails": false,
"location": "nyc",
"maxItems": 3,
"maxItemsPerUrl": 3,
"maxPagesPerUrl": 1,
"mode": "urls",
"radiusKm": 65,
"rehostImages": false,
"scrapeMode": "fast",
"searchQueries": [
"laptop"
],
"sortBy": "relevance",
"startUrls": [
{
"url": "https://www.facebook.com/marketplace/nyc/search/?query=laptop"
}
]
}
Download input.example.json and save your reviewed copy as input.json.
| Field | Type | Required | Description |
|---|---|---|---|
mode | string | optional | What to scrape. auto uses startUrls when present and otherwise builds a keyword search. search builds a search from searchQueries plus location. urls scrapes the given Marketplace search, category, or city-feed URLs. items fetches direct item URLs or numeric IDs. |
startUrls | array | optional | Marketplace search, city-category, global-category, city-feed, or /marketplace/item/ URLs. In mode=items, a bare numeric listing ID is also accepted. |
searchQueries | array | optional | One to 20 keywords or phrases (mode=search or mode=auto without URLs). Each query becomes one source. |
location | string | optional | Marketplace location slug, city, postal code, or address used by keyword search (mode=search or mode=auto without URLs). Examples: nyc, Austin, Texas, 90210, London. |
country | string | optional | ISO 3166-1 alpha-2 country used when resolving a human location. Use GB for London, CA for Toronto, and so on. |
latitude | number | optional | Optional search center latitude. Provide longitude too. |
longitude | number | optional | Optional search center longitude. Provide latitude too. |
radiusKm | integer | optional | Search radius in kilometres for keyword or category search. URL mode keeps the radius in the URL unless you set this explicitly. |
category | string | optional | Marketplace category. If searchQueries is empty, the actor opens the city category feed (or the global category feed for a human location). Books, shoes, games, motorcycles, cell-phones, computers, video-games, and cameras were verified as category feeds but expose no server category ID, so they are not usable as keyword filters; use categoryId or a category URL for those. |
categoryId | string | optional | Advanced numeric Facebook category ID. Takes precedence over category when set. |
sortBy | string | optional | Server-side sort where Marketplace supports it, plus a client-side re-sort by price or posting time. Rows without a price sort last. |
minPrice | number | optional | Only listings at or above this price. Rows without a price are dropped. |
maxPrice | number | optional | Only listings at or below this price. Rows without a price are dropped. |
condition | string | optional | Server-side condition filter in search/category modes. In deep mode the detail condition is checked too; fast URL rows without condition data are kept. |
deliveryMethod | string | optional | Client-side filter over the listing's delivery types. Listings without delivery data are dropped when this filter is active. Legacy local_pickup is accepted as local. |
daysSinceListed | integer | optional | Only listings created within this many days. Rows without a posting time are dropped. |
availability | string | optional | Client-side status filter. Search feeds are mostly available; sold and pending are more common on direct item pages. |
exactMatch | boolean | optional | Keep only rows whose title (and description in deep mode) contains every query word. |
maxItems | integer | optional | Global output limit across all sources. |
maxItemsPerUrl | integer | optional | Per-source output limit. |
maxPagesPerUrl | integer | optional | Cost guard for cursor pagination. The actor stops earlier on source exhaustion, a repeated cursor, two empty pages, or maxItems. There is no fixed row cap: a Phase 6 probe reached 1,694 unique search rows across 71 pages before Facebook returned an empty page 72. |
scrapeMode | string | optional | fast streams feed rows. deep fetches each listing page for description, condition, attributes, seller, coordinates, and photos. auto follows includeListingDetails and includeAllPhotos. |
includeListingDetails | boolean | optional | Compatibility alias that enables deep mode unless scrapeMode=fast is explicit. |
includeAllPhotos | boolean | optional | Enables deep mode and adds the full photo gallery. |
rehostImages | boolean | optional | Copy primary photos and seller avatars into the actor key-value store so the emitted URLs do not expire. The original Facebook URL is kept in primaryPhotoUrlOriginal. When off, mediaUrlTemporary is emitted. |
deduplicateAcrossInputs | boolean | optional | Emit each listing ID once across sources. Disable to preserve repeats from repeated input URLs. |
proxyConfiguration | object | optional | Optional advanced override. The actor works without a proxy and automatically escalates only when Facebook blocks a request. A missing value never stops a run. |
3. Start an Actor run
Set APIFY_TOKEN in your environment. Python 3.10 or newer is sufficient; this recipe uses no third-party packages.
Execution may incur charges. Review current pricing on Apify. The request asks for a 120-second timeout and a charge limit; these settings are subject to Apify’s pricing and do not guarantee an all-inclusive spending cap.
import json
import os
import urllib.request
# Save the schema-derived example as input.json; review and edit it first.
with open("input.json", encoding="utf-8") as stream:
actor_input = json.load(stream)
token = os.environ["APIFY_TOKEN"]
request = urllib.request.Request(
"https://api.apify.com/v2/acts/DTj8k33mijt0OfkpR/runs?timeout=120&maxTotalChargeUsd=0.50",
data=json.dumps(actor_input).encode("utf-8"),
headers={"Authorization": "Bearer " + token, "Content-Type": "application/json"},
method="POST",
)
# This starts a potentially billable run. Do not automatically retry this POST.
with urllib.request.urlopen(request, timeout=40) as response:
run = json.load(response)["data"]
print("Run ID:", run["id"])
print("Status:", run["status"])
# Inspect and download results in Apify Console once the run succeeds.
4. Inspect the actual results
Open the run in Apify Console and wait for a successful completion. Use the published output schema to locate results and the dataset schema to understand declared views. Missing or optional record fields must not be treated as guaranteed values.
One JSON object per Facebook Marketplace listing. Canonical groups: identity and provenance (id, listingUrl, sourceUrl, sourceType, inputIndex, searchQuery, locationQueried, recordType, scrapedAt), core fields (title, description, price, strikethroughPrice, condition, conditionLabel, attributes, categoryId, categoryName, categorySlug, categoryPath), location (locationText, city, state, latitude, longitude, distanceKm when radius filtering had coordinates), delivery and status (deliveryTypes, shippingAvailable, localPickupAvailable, creationTime, createdAt, listingAgeDays, isLive, isSold, isPending, isHidden, listingStatus), seller (seller with optional profileUrl and dealer, sellerDataAvailability), media (primaryPhotoUrl, primaryPhotoUrlOriginal, mediaUrlTemporary, photos, videoUrl, videos), vehicleDetails (including conditional specs, numberOfOwners, isPaidOff), vehicleVin and vehicleVinSource, and quality/access (dataMode, extractionSource, qualityStatus, missingFields, accessState, detailFetchStatus). Facebook field-name aliases such as marketplace_listing_title, listing_price, marketplace_listing_seller, location, delivery_types, creation_time, primary_listing_photo, listingPhotos, listingVideo, and vehicle are kept when present. Private-seller contact, vehicle features/Carfax/plate/website, and permanent video URLs are not available logged out. Empty values are omitted.
Questions before you run
Which inputs are required?
No top-level fields are marked required in the published schema. Conditional requirements can still apply; check the README.
What does this guide verify?
The fields, prefills, and schema links are rendered from the published build. This is a usage recipe, not a paid live extraction test. Source availability and collection results can vary.
What if the run request times out?
Check Apify Console before retrying. The first request may already have created a run. Do not automatically repeat a run-creation POST.
Generated from source build hZnF0rAlhJEPRa5AQ and its README and schemas. Source changes regenerate this guide; no third-party editorial claims are inferred.