diff --git a/FMARKETPLACE.md b/FMARKETPLACE.md index c7e86ab..e5d18e1 100644 --- a/FMARKETPLACE.md +++ b/FMARKETPLACE.md @@ -1,44 +1,56 @@ # Facebook Marketplace API Reverse Engineering ## Overview -This document tracks findings from reverse-engineering Facebook Marketplace APIs for listing details. + +This document tracks findings from reverse-engineering Facebook Marketplace APIs for +listing details. ## Current Implementation Status + - Search functionality: Implemented in `src/facebook.ts` - Individual listing details: Not yet implemented ## Findings ### Step 1: Initial Setup + - Using Chrome DevTools to inspect Facebook Marketplace - Need to authenticate with Facebook account to access marketplace data - Cookies required for full access - Current status: Successfully logged in and accessed marketplace data ### Step 2: Individual Listing Details Analysis - COMPLETED + - **Data Location**: Embedded in HTML script tags within `require` array structure -- **Path**: `require[0][3].__bbox.result.data.viewer.marketplace_product_details_page.target` +- **Path**: + `require[0][3].__bbox.result.data.viewer.marketplace_product_details_page.target` - **Authentication**: Required for full data access -- **Current Status**: Successfully reverse-engineered the API structure and data extraction method +- **Current Status**: Successfully reverse-engineered the API structure and data + extraction method ### API Endpoints Discovered #### Search Endpoint + - URL: `https://www.facebook.com/marketplace/{location}/search` - Parameters: `query`, `sortBy`, `exact` - Data embedded in HTML script tags with `require` structure - Authentication: Required (cookies) #### Listing Details Endpoint + - **URL Structure**: `https://www.facebook.com/marketplace/item/{listing_id}/` - **Data Source**: Server-side rendered HTML with embedded JSON data in script tags -- **Data Structure**: Relay/GraphQL style data structure under `require[0][3].__bbox.require[...].__bbox.result.data.viewer.marketplace_product_details_page.target` -- **Extraction Method**: Parse JSON from script tags containing marketplace data, navigate to the target object +- **Data Structure**: Relay/GraphQL style data structure under + `require[0][3].__bbox.require[...].__bbox.result.data.viewer.marketplace_product_details_page.target` +- **Extraction Method**: Parse JSON from script tags containing marketplace data, + navigate to the target object - **Authentication**: Required (cookies) ### Listing Data Structure Discovered (Current - 2026) -The current Facebook Marketplace API returns a comprehensive `GroupCommerceProductItem` object with the following key properties: +The current Facebook Marketplace API returns a comprehensive `GroupCommerceProductItem` +object with the following key properties: ```typescript interface FacebookMarketplaceItem { @@ -151,6 +163,7 @@ interface FacebookMarketplaceItem { ``` ### Example Data Extracted (Current Structure) + ```json { "__typename": "GroupCommerceProductItem", @@ -228,36 +241,47 @@ interface FacebookMarketplaceItem { ## Data Extraction Method ### Current Method (2026) -Facebook Marketplace listing data is embedded in JSON within `