{
  "name": "Facebook Marketplace Listing & Price Extractor - clean export",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "days",
              "daysInterval": 1,
              "triggerAtHour": 8,
              "triggerAtMinute": 0
            }
          ]
        }
      },
      "id": "61eab7d6-078d-443d-a0d1-adc58a1768d7",
      "name": "Daily trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        -80,
        0
      ]
    },
    {
      "parameters": {
        "jsCode": "// Edit this object for your run. The Actor's full input schema is linked in the sticky note.\nconst input = {\n  \"mode\": \"search\",\n  \"searchQueries\": [\n    \"office chair\"\n  ],\n  \"location\": \"Austin, Texas\",\n  \"maxItems\": 25\n};\n\nreturn [{ json: input }];"
      },
      "id": "a3014a31-c3a5-4701-a3bc-2e13689dbc47",
      "name": "Configure input",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        160,
        0
      ],
      "notes": "Edit the input object for your city, keyword, URLs or limit."
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.apify.com/v2/acts/nimbryxo-studio~facebook-marketplace-listing-and-price-extractor/run-sync-get-dataset-items",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpQueryAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify($json) }}",
        "options": {
          "timeout": 300000
        }
      },
      "id": "83a7afc8-d07d-4482-a9ac-372739ebca80",
      "name": "Run Apify Actor",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        400,
        0
      ],
      "notes": "Select the Apify API Token (Query Auth) credential."
    },
    {
      "parameters": {
        "jsCode": "const rows = $input.all().flatMap((item) => (Array.isArray(item.json) ? item.json : [item.json]));\nconst failed = rows.find((row) => row && row.error && typeof row.error === 'object' && Object.keys(row).length === 1);\nif (failed) throw new Error(`Apify: ${failed.error.type || 'error'} ${failed.error.message || ''}`.trim());\nconst keyField = \"listingUrl\"; // a stable identity from the Actor output\nconst kindField = rows.some((row) => row && row.recordType !== undefined) ? 'recordType' : null;\nconst scrapedAt = new Date().toISOString();\nconst seen = new Set();\nconst clean = [];\nfor (const row of rows) {\n  if (!row || typeof row !== 'object') continue;\n  const out = {};\n  for (const [k, v] of Object.entries(row)) {\n    if (v === null || v === undefined) continue;\n    out[k] = typeof v === 'string' ? v.trim() : v;\n  }\n  const value = keyField ? out[keyField] : undefined;\n  const id = (kindField ? `${out[kindField]}|` : '') + (value === undefined || value === '' ? JSON.stringify(out) : String(value).toLowerCase());\n  if (seen.has(id)) continue;\n  seen.add(id);\n  out._source = \"https://apify.com/nimbryxo-studio/facebook-marketplace-listing-and-price-extractor\";\n  out._scrapedAt = scrapedAt;\n  clean.push(out);\n}\nreturn clean.map((json) => ({ json }));"
      },
      "id": "70a144ac-3d76-48e1-a0db-8b9a295109d9",
      "name": "Normalize + dedupe",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        640,
        0
      ]
    },
    {
      "parameters": {},
      "id": "ac4e0ca7-4157-4f67-ad43-f0e5d28c0280",
      "name": "Rows ready",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        880,
        0
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "YOUR_GOOGLE_SHEET_ID",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "Rows",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "autoMapInputData",
          "value": {}
        },
        "options": {}
      },
      "id": "8652d61a-5094-4bc8-af9e-3c0fa16197d2",
      "name": "Google Sheets (optional)",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        1120,
        0
      ],
      "disabled": true,
      "notes": "Enable this after adding your Google Sheets credential and sheet ID."
    },
    {
      "parameters": {
        "content": "## Facebook Marketplace Listing & Price Extractor\n\n**Actor:** [Facebook Marketplace Listing & Price Extractor](https://apify.com/nimbryxo-studio/facebook-marketplace-listing-and-price-extractor)\n\n**Docs:** https://scraperfinder.com/n8n/facebook-marketplace-listing-and-price-extractor/\n\n### Setup\n1. Create an Apify account and copy an API token.\n2. In n8n, create a **Query Auth** credential:\n   - Name: `Apify API Token`\n   - Query parameter name: `token`\n   - Value: your Apify token\n3. Open **Run Apify Actor** and select that credential.\n4. Click **Execute workflow**. The rows appear in **Rows ready**.\n5. Optional: enable **Google Sheets** and set your document and sheet.\n\n### Notes\n- This calls the public Actor endpoint. No API token is stored in this file.\n- `run-sync-get-dataset-items` waits up to 300 seconds. For large runs, switch to the async run + dataset endpoint.\n- Public data only. Respect the target site's terms and local law.\n\n### Input fields\n- `mode` (string)\n- `startUrls` (array)\n- `searchQueries` (array)\n- `location` (string)\n- `country` (string)\n- `latitude` (number)\n- `longitude` (number)\n- `radiusKm` (integer)\n- `category` (string)\n- `categoryId` (string)\n- `sortBy` (string)\n- `minPrice` (number)\n\n### Output fields\n- `title` (Title)\n- `price` (Price)\n- `city` (City)\n- `state` (State)\n- `locationText` (Location)\n- `condition` (Condition)\n- `deliveryTypes` (Delivery)\n- `seller` (Seller)\n- `primaryPhotoUrl` (Photo)\n- `listingUrl` (Listing URL)",
        "height": 640,
        "width": 560,
        "color": 4
      },
      "id": "bfdafcfd-83d8-4a58-a261-be828909d768",
      "name": "Setup notes",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -80,
        -700
      ]
    }
  ],
  "connections": {
    "Daily trigger": {
      "main": [
        [
          {
            "node": "Configure input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Configure input": {
      "main": [
        [
          {
            "node": "Run Apify Actor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run Apify Actor": {
      "main": [
        [
          {
            "node": "Normalize + dedupe",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize + dedupe": {
      "main": [
        [
          {
            "node": "Rows ready",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Rows ready": {
      "main": [
        [
          {
            "node": "Google Sheets (optional)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "tags": [],
  "versionId": "27fd63fe-9db3-44a0-a2e7-debb8cba5531",
  "description": "Facebook Marketplace scraper: runs the Facebook Marketplace Listing & Price Extractor Apify Actor, returns title, price, city, state, locationText and more, then normalizes and dedupes the rows before an optional Google Sheets append."
}
