{
  "name": "Pinterest Trending Topics & Shopping Category Scraper - clean export",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "days",
              "daysInterval": 1,
              "triggerAtHour": 8,
              "triggerAtMinute": 0
            }
          ]
        }
      },
      "id": "69ab36f9-6adc-4206-a171-4b7ca3569936",
      "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  \"maxItems\": 25,\n  \"mode\": \"trendingSearches\"\n};\n\nreturn [{ json: input }];"
      },
      "id": "dc4da112-1638-481a-aaff-52524ffff22b",
      "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/vexaloom-labs~pinterest-trending-topics-and-shopping-category/run-sync-get-dataset-items",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpQueryAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify($json) }}",
        "options": {
          "timeout": 300000
        }
      },
      "id": "f801e327-8e62-4bc6-ae31-1b8f4b9aefab",
      "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 = null; // no stable id in this output: identical rows are dropped\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/vexaloom-labs/pinterest-trending-topics-and-shopping-category\";\n  out._scrapedAt = scrapedAt;\n  clean.push(out);\n}\nreturn clean.map((json) => ({ json }));"
      },
      "id": "984335f0-78c1-4e6f-a247-8326b1de8acd",
      "name": "Normalize + dedupe",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        640,
        0
      ]
    },
    {
      "parameters": {},
      "id": "7dfd9ee6-2667-4570-a06e-6ae3fc6d30a6",
      "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": "1d624cef-d500-4251-a4c0-31644f71f913",
      "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": "## Pinterest Trending Topics & Shopping Category Scraper\n\n**Actor:** [Pinterest Trending Topics & Shopping Category Scraper](https://apify.com/vexaloom-labs/pinterest-trending-topics-and-shopping-category)\n\n**Docs:** https://scraperfinder.com/n8n/pinterest-trending-topics-and-shopping-category-scraper/\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, required)\n- `region` (string)\n- `trendType` (string)\n- `lookbackWindow` (string)\n- `endDate` (string)\n- `interest` (string)\n- `moment` (string)\n- `keywordsToInclude` (array)\n- `keywordsToExclude` (array)\n- `ageGroup` (string)\n- `gender` (string)\n- `keywords` (array)\n\n### Output fields\n- `term` (Term)\n- `title` (Title)\n- `name` (Name)\n- `region` (Region)\n- `trendType` (Trend Type)\n- `rank` (Rank)\n- `weekOverWeekChange` (Week Over Week Change)",
        "height": 640,
        "width": 560,
        "color": 4
      },
      "id": "0ce222f4-689d-4a18-a76d-e3f6e9aa989e",
      "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": "9db769cd-946d-4540-a5f9-6e098414b06c",
  "description": "Pinterest trending topics scraper: runs the Pinterest Trending Topics & Shopping Category Scraper Apify Actor, returns term, title, name, region, rank and more, then normalizes and dedupes the rows before an optional Google Sheets append."
}
