{
  "id": "Us0ywmdayIMfspYa",
  "name": "Search Xiaohongshu users and get profile details with JustOneAPI",
  "tags": [],
  "nodes": [
    {
      "id": "95d70ba3-51a6-4e51-9a65-318316e94a40",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        10688,
        -16
      ],
      "parameters": {
        "width": 480,
        "height": 512,
        "content": "## Search Xiaohongshu users and get profile details with JustOneAPI\n\n### How it works\n\n1. The workflow is manually triggered to start the process.\n2. It prepares API and research inputs for the search.\n3. It fetches Xiaohongshu users based on the provided keyword.\n4. It extracts user IDs from the search results.\n5. It fetches detailed profiles for the extracted user IDs.\n6. It builds a list of user profiles and outputs the final result.\n\n### Setup steps\n\n- - [ ] Configure the base URL and API key for JustOneAPI in the 'Prepare API and Research Inputs' node.\n- - [ ] Ensure the 'Fetch Xiaohongshu Users by Keyword' and 'Fetch Xiaohongshu User Profiles' nodes have the correct endpoint paths.\n- - [ ] Verify the code in 'Extract User IDs from Results' and 'Build User Profile List' nodes is functioning as expected.\n\n### Customization\n\nYou can customize the search keywords and fields to extract in the 'Prepare API and Research Inputs' node."
      },
      "typeVersion": 1
    },
    {
      "id": "56d106c1-66e6-4daf-ad6e-727bbfe09cbb",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        11248,
        16
      ],
      "parameters": {
        "color": 7,
        "height": 128,
        "content": "## Workflow Trigger\n\nManually starts the workflow process."
      },
      "typeVersion": 1
    },
    {
      "id": "16266ed2-5e23-456c-bd86-43653c71c4f4",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        11536,
        16
      ],
      "parameters": {
        "color": 7,
        "width": 224,
        "height": 144,
        "content": "## Prepare Inputs\n\nSets up API and research inputs for the search."
      },
      "typeVersion": 1
    },
    {
      "id": "c2ca6e9b-57a3-4e0b-bb03-6b83a651d327",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        11808,
        16
      ],
      "parameters": {
        "color": 7,
        "width": 528,
        "height": 112,
        "content": "## Search Users\n\nFetches Xiaohongshu users based on the provided keyword."
      },
      "typeVersion": 1
    },
    {
      "id": "e426f4cf-a7d0-4658-8a9a-9e6ceadda931",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        12496,
        16
      ],
      "parameters": {
        "color": 7,
        "width": 512,
        "height": 96,
        "content": "## Extract User IDs\n\nExtracts user IDs from the search results for further processing."
      },
      "typeVersion": 1
    },
    {
      "id": "61387857-1dc4-4709-8ae1-3a467c072999",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        13040,
        16
      ],
      "parameters": {
        "color": 7,
        "height": 112,
        "content": "## Fetch User Profiles\n\nFetches detailed profiles for the extracted user IDs."
      },
      "typeVersion": 1
    },
    {
      "id": "1dfbc30f-adcf-4cb8-ba82-674dc6450c94",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        13312,
        16
      ],
      "parameters": {
        "color": 7,
        "width": 656,
        "height": 96,
        "content": "## Build and Output Profiles\n\nBuilds a list of user profiles and outputs the final result."
      },
      "typeVersion": 1
    },
    {
      "id": "b5f56bbb-72b9-4702-bd71-fa40ed7698da",
      "name": "Start Workflow",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        11248,
        224
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "2b70de18-6cb9-4792-91ae-5ef039d630ed",
      "name": "Set API and Search Parameters",
      "type": "n8n-nodes-base.set",
      "position": [
        11536,
        224
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "{\n  \"baseUrl\": \"https://api.justoneapi.com\",\n  \"token\": \"YOUR_JUSTONEAPI_TOKEN\",\n  \"keyword\": \"YOUR_RESEARCH_KEYWORD\",\n  \"page\": 1,\n  \"maxUsers\": 1\n}"
      },
      "typeVersion": 3.4
    },
    {
      "id": "1ace594a-a5b5-4f72-b725-d7339953fbf3",
      "name": "Search Xiaohongshu Users by Keyword",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        11824,
        224
      ],
      "parameters": {
        "url": "={{$json.baseUrl + '/api/xiaohongshu/search-user/v2'}}",
        "options": {
          "redirect": {
            "redirect": {}
          }
        },
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "token",
              "value": "={{$json.token}}"
            },
            {
              "name": "keyword",
              "value": "={{$json.keyword}}"
            },
            {
              "name": "page",
              "value": "={{$json.page}}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "fd9821cc-c3ab-4c37-8622-f7b40538dfdd",
      "name": "Output Search Results",
      "type": "n8n-nodes-base.set",
      "position": [
        12160,
        448
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "={{$json}}"
      },
      "typeVersion": 3.4
    },
    {
      "id": "60623283-7053-4e75-a10f-d8bbb844dcd2",
      "name": "Extract User IDs from Search Results",
      "type": "n8n-nodes-base.code",
      "position": [
        12512,
        224
      ],
      "parameters": {
        "jsCode": "const cfg = $('Set API and Search Parameters').first().json;\nconst maxUsers = Math.max(1, Number(cfg.maxUsers || 1));\nconst token = cfg.token;\nconst baseUrl = cfg.baseUrl;\nconst keyword = cfg.keyword;\n\n// Match the real search-user/v2 response structure:\n// [\n//   {\n//     code: 0,\n//     data: {\n//       users: [\n//         { id: \"...\", name: \"...\", red_id: \"...\" }\n//       ]\n//     }\n//   }\n// ]\n\nconst rows = $input.all();\nconst ids = [];\n\nfor (const row of rows) {\n  const users = row.json?.data?.users || [];\n  for (const user of users) {\n    const userId = user?.id;\n    if (typeof userId === 'string' && userId.length >= 8) {\n      ids.push(userId);\n    }\n  }\n}\n\nconst uniqueIds = [...new Set(ids)].slice(0, maxUsers);\n\nreturn uniqueIds.map((userId, index) => ({\n  json: {\n    baseUrl,\n    token,\n    keyword,\n    userId,\n    userRank: index + 1,\n    selectedBy: 'search-user-v2',\n  }\n}));"
      },
      "typeVersion": 2
    },
    {
      "id": "831a1ebb-9eb5-41ce-8216-851a7db571a6",
      "name": "Output Extracted User IDs List",
      "type": "n8n-nodes-base.set",
      "position": [
        12832,
        448
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "={{$json}}"
      },
      "typeVersion": 3.4
    },
    {
      "id": "1b4430b7-4304-44a8-9e2f-9982fcdc50b8",
      "name": "Get Xiaohongshu User Profiles",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        13056,
        224
      ],
      "parameters": {
        "url": "={{$json.baseUrl + '/api/xiaohongshu/get-user/v3'}}",
        "options": {
          "redirect": {
            "redirect": {}
          }
        },
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "token",
              "value": "={{$json.token}}"
            },
            {
              "name": "userId",
              "value": "={{$json.userId}}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "2b9781ee-8523-403b-9dcb-0c8bbf282c89",
      "name": "Build Combined User Profiles",
      "type": "n8n-nodes-base.code",
      "position": [
        13328,
        224
      ],
      "parameters": {
        "jsCode": "const rows = $input.all();\n\nreturn rows.map(item => {\n  const root = item.json || {};\n  const profile = root.data || {};\n  const noteNumStat = profile.note_num_stat || {};\n\n  return {\n    json: {\n      userId: profile.userid || '',\n      nickname: profile.nickname || '',\n      redId: profile.red_id || '',\n      followerCount: profile.fans ?? 0,\n      followingCount: profile.follows ?? 0,\n      likedCount: profile.liked ?? 0,\n      collectedCount: profile.collected ?? 0,\n      noteCount: noteNumStat.posted ?? profile.ndiscovery ?? 0,\n      desc: profile.desc || '',\n      avatar: profile.images || '',\n      location: profile.location || '',\n      ipLocation: profile.ip_location || '',\n      gender: profile.gender ?? '',\n      verified: profile.red_official_verified ?? false,\n      verifyType: profile.red_official_verify_type ?? 0,\n      shareLink: profile.share_link || '',\n      requestedKeyword: $('Set API and Search Parameters').first().json.keyword || '',\n      raw: root\n    }\n  };\n});"
      },
      "typeVersion": 2
    },
    {
      "id": "b13cbe7b-45fe-4f8f-81f7-b1f1aa5e0251",
      "name": "Output Final User Profile Data",
      "type": "n8n-nodes-base.set",
      "position": [
        13808,
        224
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "={{$json}}"
      },
      "typeVersion": 3.4
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "executionOrder": "v1"
  },
  "versionId": "9bfe38a1-e654-4c2d-a330-a77a2355c915",
  "connections": {
    "Start Workflow": {
      "main": [
        [
          {
            "node": "Set API and Search Parameters",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Combined User Profiles": {
      "main": [
        [
          {
            "node": "Output Final User Profile Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Xiaohongshu User Profiles": {
      "main": [
        [
          {
            "node": "Build Combined User Profiles",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set API and Search Parameters": {
      "main": [
        [
          {
            "node": "Search Xiaohongshu Users by Keyword",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search Xiaohongshu Users by Keyword": {
      "main": [
        [
          {
            "node": "Output Search Results",
            "type": "main",
            "index": 0
          },
          {
            "node": "Extract User IDs from Search Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract User IDs from Search Results": {
      "main": [
        [
          {
            "node": "Output Extracted User IDs List",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get Xiaohongshu User Profiles",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}