{
  "id": "gDkpASTdLEO2CR8R",
  "name": "Research Kuaishou creator profile details from a keyword with JustOneAPI - real response adjusted",
  "tags": [],
  "nodes": [
    {
      "id": "b367c418-e24a-4adb-80b9-d008bb4611cf",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4128,
        1216
      ],
      "parameters": {
        "width": 512,
        "height": 544,
        "content": "## Research Kuaishou creator profile details from a keyword with JustOneAPI - real response adjusted\n\n### How it works\n\n1. The workflow is triggered manually and prepares API inputs.\n2. It searches Kuaishou users by keyword and extracts user IDs from results.\n3. It checks if a user ID exists and fetches the user profile if true.\n4. It builds a user profile list and outputs the final results.\n\n### Setup steps\n\n- - [ ] Configure the JustOneAPI base URL and credentials in the 'Prepare API and Research Inputs' node.\n- - [ ] Ensure the 'Search Kuaishou Users by Keyword' node has the correct API endpoint and parameters.\n- - [ ] Verify the 'Fetch Kuaishou User Profile' node has the correct API endpoint and parameters.\n\n### Customization\n\nYou can customize the search keywords in the 'Prepare API and Research Inputs' node and adjust the fields to extract in the 'Extract User IDs from Results' and 'Build User Profile List' nodes."
      },
      "typeVersion": 1
    },
    {
      "id": "e08f93fe-acdc-4cb2-a29f-ecfb433abf80",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4688,
        1216
      ],
      "parameters": {
        "color": 7,
        "width": 576,
        "height": 96,
        "content": "## Workflow Trigger\n\nManually starts the workflow and prepares API inputs."
      },
      "typeVersion": 1
    },
    {
      "id": "cb213786-f4bd-4e9f-be66-9467562de8df",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5536,
        1216
      ],
      "parameters": {
        "color": 7,
        "width": 928,
        "height": 96,
        "content": "## Search Kuaishou Users\n\nSearches Kuaishou users by keyword and extracts user IDs from results."
      },
      "typeVersion": 1
    },
    {
      "id": "5fd8db1d-62ef-49bf-b1c5-9c919ff6e2c3",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        6512,
        1216
      ],
      "parameters": {
        "color": 7,
        "width": 544,
        "height": 96,
        "content": "## Check and Fetch User Profile\n\nChecks if a user ID exists and fetches the user profile if true."
      },
      "typeVersion": 1
    },
    {
      "id": "cfcb5572-b64c-49cf-b7c8-b50426986e03",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        7088,
        1216
      ],
      "parameters": {
        "color": 7,
        "width": 528,
        "height": 96,
        "content": "## Build and Output Profile List\n\nBuilds a user profile list and outputs the final results."
      },
      "typeVersion": 1
    },
    {
      "id": "5b249ab5-00de-4988-a1de-dca246faf1cb",
      "name": "Manual Execution Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        4736,
        1344
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "85389219-4128-4888-8ed8-587d4d7c88f1",
      "name": "Set API and Research Parameters",
      "type": "n8n-nodes-base.set",
      "position": [
        5120,
        1344
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "{\n  \"baseUrl\": \"https://api.justoneapi.com\",\n  \"token\": \"YOUR_JUSTONEAPI_TOKEN\",\n  \"keyword\": \"YOUR_SEARCH_KEYWORD\",\n  \"page\": 1,\n  \"maxUsers\": 1\n}"
      },
      "typeVersion": 3.4
    },
    {
      "id": "0d567302-7160-4726-988c-175c0ec88bef",
      "name": "Fetch Kuaishou Users by Keyword",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        5584,
        1344
      ],
      "parameters": {
        "url": "={{$json.baseUrl + '/api/kuaishou/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": "1a07ec58-6405-4869-a939-c75672cc713e",
      "name": "Output Kuaishou Search Results",
      "type": "n8n-nodes-base.set",
      "position": [
        5904,
        1568
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "={{$json}}"
      },
      "typeVersion": 3.4
    },
    {
      "id": "df4e0fe8-84ca-4276-9400-5f1e4baee88d",
      "name": "Parse User IDs from Results",
      "type": "n8n-nodes-base.code",
      "position": [
        6016,
        1344
      ],
      "parameters": {
        "jsCode": "const root = $input.first().json || {};\nconst config = $('Set API and Research Parameters').first().json || {};\nconst maxUsers = Math.max(1, Number(config.maxUsers || 1));\nconst seen = new Set();\nconst candidates = [];\n\nfunction getApiResponse(value) {\n  if (Array.isArray(value)) return value[0] || {};\n  return value || {};\n}\n\nfunction pushCandidate(userId, source, item) {\n  if (userId === undefined || userId === null || userId === '') return;\n  const normalizedUserId = String(userId).trim();\n  if (!normalizedUserId || seen.has(normalizedUserId)) return;\n  seen.add(normalizedUserId);\n  candidates.push({\n    userId: normalizedUserId,\n    userIdSource: source,\n    searchItem: item || null\n  });\n}\n\nconst response = getApiResponse(root);\nconst data = response.data || {};\nconst users = Array.isArray(data.users) ? data.users : [];\n\nfor (const user of users) {\n  pushCandidate(user.user_id, 'data.users[].user_id', user);\n  if (candidates.length >= maxUsers) break;\n}\n\nconst selected = candidates.slice(0, maxUsers);\n\nif (selected.length === 0) {\n  return [\n    {\n      json: {\n        error: 'No userId was extracted from data.users[].user_id in the search response.',\n        baseUrl: config.baseUrl,\n        token: config.token,\n        keyword: config.keyword,\n        page: config.page,\n        maxUsers,\n        rawSearchResponse: root\n      }\n    }\n  ];\n}\n\nreturn selected.map(candidate => ({\n  json: {\n    baseUrl: config.baseUrl,\n    token: config.token,\n    keyword: config.keyword,\n    page: config.page,\n    maxUsers,\n    userId: candidate.userId,\n    userIdSource: candidate.userIdSource,\n    searchItem: candidate.searchItem,\n    rawSearchResponse: root\n  }\n}));"
      },
      "typeVersion": 2
    },
    {
      "id": "7703ce12-8252-48bb-b734-0e9dddd071d5",
      "name": "Output Parsed User IDs",
      "type": "n8n-nodes-base.set",
      "position": [
        6336,
        1568
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "={{$json}}"
      },
      "typeVersion": 3.4
    },
    {
      "id": "cf8590b7-e44e-40cf-97e6-b0eadc433523",
      "name": "Check User ID Exists",
      "type": "n8n-nodes-base.if",
      "position": [
        6560,
        1344
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "da82cc96-baae-4a66-b721-eaf453553942",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{$json.userId}}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "71c55960-68bb-465f-8db6-279cbcf3a0dc",
      "name": "Fetch Kuaishou User Details",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        6896,
        1344
      ],
      "parameters": {
        "url": "={{$json.baseUrl + '/api/kuaishou/get-user-detail/v1'}}",
        "options": {
          "redirect": {
            "redirect": {}
          }
        },
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "token",
              "value": "={{$json.token}}"
            },
            {
              "name": "userId",
              "value": "={{$json.userId}}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "abe29ff8-6bef-435a-abfd-c27f27b0a039",
      "name": "Build User Profile Data List",
      "type": "n8n-nodes-base.code",
      "position": [
        7136,
        1344
      ],
      "parameters": {
        "jsCode": "const rows = $input.all();\nconst extractedRows = $('Parse User IDs from Results').all();\nconst config = $('Set API and Research Parameters').first().json || {};\n\nfunction getApiResponse(value) {\n  if (Array.isArray(value)) return value[0] || {};\n  return value || {};\n}\n\nfunction firstUrl(list) {\n  if (!Array.isArray(list) || list.length === 0) return '';\n  const first = list[0];\n  if (typeof first === 'string') return first;\n  if (first && typeof first === 'object') return first.url || '';\n  return '';\n}\n\nfunction normalizeSearchUser(user) {\n  if (!user || typeof user !== 'object') return {};\n  return {\n    userId: user.user_id ?? '',\n    userName: user.user_name || '',\n    kwaiId: user.kwaiId || '',\n    userText: user.user_text || '',\n    userSex: user.user_sex || '',\n    fansCount: user.fansCount ?? '',\n    headUrl: user.headurl || firstUrl(user.headurls),\n    verified: user.verified ?? '',\n    verifiedDescription: user.verifiedDetail?.description || '',\n    isBanned: user.isBanned ?? '',\n    following: user.following ?? '',\n    isFollowed: user.is_followed ?? '',\n    isFavorited: user.isFavorited ?? '',\n    messageLink: user.messageLink || '',\n    privacy: user.privacy ?? '',\n    living: user.living || null\n  };\n}\n\nfunction normalizeProfile(profileRoot) {\n  const userProfile = profileRoot?.userProfile || {};\n  const profile = userProfile.profile || {};\n  const ownerCount = userProfile.ownerCount || {};\n  const extraLink = userProfile.extraLink || {};\n  const shareInfo = profileRoot?.shareInfo || {};\n\n  return {\n    userId: profile.user_id ?? '',\n    userName: profile.user_name || '',\n    userText: profile.user_text || '',\n    userSex: profile.user_sex || '',\n    headUrl: profile.headurl || firstUrl(profile.headurls),\n    bigHeadUrl: firstUrl(profile.bigHeadUrls),\n    profileBackgroundUrl: profile.user_profile_bg_url || firstUrl(profile.user_profile_bg_urls),\n    verified: userProfile.verified ?? profile.verified ?? '',\n    constellation: userProfile.constellation || '',\n    isLiving: profileRoot?.isLiving ?? '',\n    isUserBanned: userProfile.isUserBanned ?? '',\n    isFollowing: userProfile.isFollowing ?? '',\n    isFriend: userProfile.isFriend ?? '',\n    isFavorited: userProfile.isFavorited ?? profile.isFavorited ?? '',\n    isSubscribe: userProfile.isSubscribe ?? '',\n    showCount: userProfile.showCount ?? '',\n    counts: {\n      fan: ownerCount.fan ?? '',\n      follow: ownerCount.follow ?? '',\n      photo: ownerCount.photo ?? '',\n      photoPublic: ownerCount.photo_public ?? '',\n      photoPrivate: ownerCount.photo_private ?? '',\n      like: ownerCount.like ?? '',\n      collect: ownerCount.collect ?? '',\n      moment: ownerCount.moment ?? '',\n      magicFace: ownerCount.magicFace ?? '',\n      novelDrama: ownerCount.novelDrama ?? '',\n      recommend: ownerCount.recommend ?? ''\n    },\n    extraLink: {\n      type: extraLink.type ?? '',\n      title: extraLink.title || '',\n      tagText: extraLink.tagText || '',\n      subTitle: extraLink.subTitle || '',\n      link: extraLink.link || '',\n      targetId: extraLink.targetId || '',\n      entranceTitle: extraLink.entranceTitle || '',\n      entranceText: extraLink.entranceText || '',\n      icon: extraLink.icon || '',\n      headImg: extraLink.headImg || ''\n    },\n    shareInfo: {\n      shareTitle: shareInfo.shareTitle || '',\n      shareSubTitle: shareInfo.shareSubTitle || '',\n      shareType: shareInfo.shareType || '',\n      shareId: shareInfo.shareId || '',\n      docId: shareInfo.docId || '',\n      objectId: shareInfo.webShareVerifyData?.objectId || ''\n    }\n  };\n}\n\nreturn rows.map((item, index) => {\n  const profileResponse = item.json || {};\n  const extracted = extractedRows[index]?.json || extractedRows[0]?.json || {};\n  const profileApiResponse = getApiResponse(profileResponse);\n  const profileData = profileApiResponse.data || {};\n  const searchResponse = getApiResponse(extracted.rawSearchResponse);\n  const users = Array.isArray(searchResponse.data?.users) ? searchResponse.data.users : [];\n  const searchItem = extracted.searchItem || {};\n\n  return {\n    json: {\n      requestedKeyword: config.keyword || extracted.keyword || '',\n      page: extracted.page ?? config.page ?? '',\n      userId: extracted.userId || '',\n      userIdSource: extracted.userIdSource || '',\n      searchUser: normalizeSearchUser(searchItem),\n      userProfile: normalizeProfile(profileData),\n      debug: {\n        searchResultCount: users.length,\n        profileResult: profileData.result ?? '',\n        isLiving: profileData.isLiving ?? '',\n        profileApiCode: profileApiResponse.code ?? '',\n        profileApiMessage: profileApiResponse.message ?? '',\n        profileRecordTime: profileApiResponse.recordTime || ''\n      },\n      raw: {\n        selectedSearchItem: searchItem,\n        searchResponse: extracted.rawSearchResponse || null,\n        profileData,\n        profileResponse\n      }\n    }\n  };\n});"
      },
      "typeVersion": 2
    },
    {
      "id": "20437979-1014-46ee-b15b-382f401c9ecd",
      "name": "Output User Profile Data",
      "type": "n8n-nodes-base.set",
      "position": [
        7456,
        1344
      ],
      "parameters": {
        "mode": "raw",
        "options": {},
        "jsonOutput": "={{$json}}"
      },
      "typeVersion": 3.4
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "executionOrder": "v1"
  },
  "versionId": "018cca07-abb3-4cb8-b622-0d8651e3a735",
  "connections": {
    "Check User ID Exists": {
      "main": [
        [
          {
            "node": "Fetch Kuaishou User Details",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Manual Execution Trigger": {
      "main": [
        [
          {
            "node": "Set API and Research Parameters",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Kuaishou User Details": {
      "main": [
        [
          {
            "node": "Build User Profile Data List",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse User IDs from Results": {
      "main": [
        [
          {
            "node": "Output Parsed User IDs",
            "type": "main",
            "index": 0
          },
          {
            "node": "Check User ID Exists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build User Profile Data List": {
      "main": [
        [
          {
            "node": "Output User Profile Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Kuaishou Users by Keyword": {
      "main": [
        [
          {
            "node": "Output Kuaishou Search Results",
            "type": "main",
            "index": 0
          },
          {
            "node": "Parse User IDs from Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set API and Research Parameters": {
      "main": [
        [
          {
            "node": "Fetch Kuaishou Users by Keyword",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}