{
  "id": "gkLNOPJ1h0Pjqy6B",
  "name": "Get Xiaohongshu keyword suggestions with JustOneAPI",
  "tags": [],
  "nodes": [
    {
      "id": "c32b0283-47fa-43d0-b6a5-932683a9e3c9",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1392,
        1152
      ],
      "parameters": {
        "width": 528,
        "height": 544,
        "content": "## Get Xiaohongshu keyword suggestions with JustOneAPI\n\n### How it works\n\n1. The workflow is triggered manually.\n2. It prepares API and keyword inputs for the request.\n3. A GET request is made to fetch Xiaohongshu keyword suggestions.\n4. The raw suggestions are outputted.\n5. A custom code node builds a structured list of keyword suggestions.\n6. The final keyword suggestions are outputted.\n\n### Setup steps\n\n- - [ ] Configure the manual trigger node if needed.\n- - [ ] Set up the API endpoint and authentication details in the 'Prepare API and Keyword Inputs' node.\n- - [ ] Ensure the 'Get Xiaohongshu Keyword Suggestions' node has the correct URL and parameters.\n- - [ ] Review and adjust the custom code in the 'Build Keyword Suggestions List' node if necessary.\n\n### Customization\n\nThe custom code in the 'Build Keyword Suggestions List' node can be modified to change how the suggestions are structured or filtered."
      },
      "typeVersion": 1
    },
    {
      "id": "75c3b86e-cc00-4219-a5ea-56df8b63c56d",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1952,
        1152
      ],
      "parameters": {
        "color": 7,
        "height": 80,
        "content": "## Workflow Trigger\n\nInitiates the workflow manually."
      },
      "typeVersion": 1
    },
    {
      "id": "78631ac8-b5ea-4d1a-ba3b-a9212eb8b689",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2224,
        1152
      ],
      "parameters": {
        "color": 7,
        "height": 96,
        "content": "## Prepare API Inputs\n\nSets up the necessary API and keyword inputs for the request."
      },
      "typeVersion": 1
    },
    {
      "id": "3585c534-ed01-447a-b0a1-b18f16ce48c9",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2592,
        1152
      ],
      "parameters": {
        "color": 7,
        "height": 144,
        "content": "## Fetch Keyword Suggestions\n\nMakes a GET request to the Xiaohongshu API to fetch keyword suggestions."
      },
      "typeVersion": 1
    },
    {
      "id": "0168ec9e-3348-4fba-aed0-c1f0915ad681",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2944,
        1152
      ],
      "parameters": {
        "color": 7,
        "height": 144,
        "content": "## Output Raw Suggestions\n\nOutputs the raw keyword suggestions from the API response."
      },
      "typeVersion": 1
    },
    {
      "id": "5e20b700-5179-4d65-9d4e-bda463cac303",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2944,
        1504
      ],
      "parameters": {
        "color": 7,
        "height": 144,
        "content": "## Build Suggestions List\n\nProcesses the raw suggestions into a structured list using custom code."
      },
      "typeVersion": 1
    },
    {
      "id": "fd9aae34-0ff3-4f48-a2ba-49c0d3c4e7e6",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3264,
        1504
      ],
      "parameters": {
        "color": 7,
        "height": 128,
        "content": "## Output Final Suggestions\n\nOutputs the final processed keyword suggestions."
      },
      "typeVersion": 1
    },
    {
      "id": "17760d46-c80a-4f8a-8b98-89146e37fde0",
      "name": "Manual Workflow Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        2016,
        1440
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "9bc6ce38-c6ef-4f35-acfc-d1bd963bd122",
      "name": "Set API and Keyword Parameters",
      "type": "n8n-nodes-base.set",
      "position": [
        2272,
        1440
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "{\n  \"baseUrl\": \"https://api.justoneapi.com\",\n  \"token\": \"PASTE_YOUR_TOKEN_HERE\",\n  \"keyword\": \"PASTE_YOUR_KEYWORD_HERE\"\n}"
      },
      "typeVersion": 3.4
    },
    {
      "id": "aab342d7-9a9d-43ee-b23b-426a96e54215",
      "name": "Fetch Xiaohongshu Suggestions",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2656,
        1440
      ],
      "parameters": {
        "url": "={{$json.baseUrl + '/api/xiaohongshu/search-recommend/v1'}}",
        "options": {
          "timeout": 60000,
          "redirect": {
            "redirect": {}
          }
        },
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "token",
              "value": "={{$json.token}}"
            },
            {
              "name": "keyword",
              "value": "={{$json.keyword}}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "70f4cf2e-cdde-4af7-8ea0-a39cac3429e9",
      "name": "Output Raw Suggestions Data",
      "type": "n8n-nodes-base.set",
      "position": [
        2992,
        1312
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "={{$json}}"
      },
      "typeVersion": 3.4
    },
    {
      "id": "981ef2af-4c54-4d88-a820-fb3e094a5c66",
      "name": "Build Suggestions List",
      "type": "n8n-nodes-base.code",
      "position": [
        2992,
        1664
      ],
      "parameters": {
        "jsCode": "const cfg = $('Set API and Keyword Parameters').first().json;\nconst rows = $input.all();\n\nfunction normalizeItems(root) {\n  const items = Array.isArray(root?.data?.items) ? root.data.items : [];\n\n  return items.map((item, index) => ({\n    index: index + 1,\n    text: item?.text ?? '',\n    searchType: item?.search_type ?? '',\n    suggestionType: item?.type ?? '',\n    description: item?.desc ?? '',\n    link: item?.link ?? '',\n    isIntervened: Boolean(item?.is_intervened ?? false),\n    highlightFlags: Array.isArray(item?.highlight_flags) ? item.highlight_flags : []\n  }));\n}\n\nreturn rows.map((item, index) => {\n  const root = item.json || {};\n  const normalizedItems = normalizeItems(root);\n\n  const noteSuggestions = normalizedItems\n    .filter(entry => entry.searchType === 'notes')\n    .map(entry => entry.text)\n    .filter(Boolean);\n\n  const goodsSuggestions = normalizedItems\n    .filter(entry => entry.searchType === 'goods')\n    .map(entry => ({\n      text: entry.text,\n      description: entry.description,\n      suggestionType: entry.suggestionType\n    }))\n    .filter(entry => entry.text);\n\n  const allSuggestionTexts = normalizedItems\n    .map(entry => entry.text)\n    .filter(Boolean);\n\n  return {\n    json: {\n      keyword: cfg.keyword || '',\n      suggestionCount: normalizedItems.length,\n      noteSuggestionCount: noteSuggestions.length,\n      goodsSuggestionCount: goodsSuggestions.length,\n      noteSuggestions,\n      goodsSuggestions,\n      allSuggestionTexts,\n      items: normalizedItems,\n      wordRequestId: root?.data?.word_request_id ?? '',\n      searchCplId: root?.data?.search_cpl_id ?? '',\n      requestResult: root?.data?.result ?? {},\n      sourceNode: 'Get Xiaohongshu Keyword Suggestions',\n      responseIndex: index + 1,\n      raw: root\n    }\n  };\n});\n"
      },
      "typeVersion": 2
    },
    {
      "id": "a5c05b9b-e756-48ca-b9eb-3e458f9b642b",
      "name": "Output Final Suggestions",
      "type": "n8n-nodes-base.set",
      "position": [
        3312,
        1664
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "={{$json}}"
      },
      "typeVersion": 3.4
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "executionOrder": "v1"
  },
  "versionId": "05a29148-7bf1-499f-a5f3-789f766930ae",
  "connections": {
    "Build Suggestions List": {
      "main": [
        [
          {
            "node": "Output Final Suggestions",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Manual Workflow Trigger": {
      "main": [
        [
          {
            "node": "Set API and Keyword Parameters",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Xiaohongshu Suggestions": {
      "main": [
        [
          {
            "node": "Output Raw Suggestions Data",
            "type": "main",
            "index": 0
          },
          {
            "node": "Build Suggestions List",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set API and Keyword Parameters": {
      "main": [
        [
          {
            "node": "Fetch Xiaohongshu Suggestions",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}