From 3479514054482f87454805cc2cf5a52ba422d61a Mon Sep 17 00:00:00 2001 From: Ilya Sereb Date: Thu, 31 Jul 2025 18:36:31 -0400 Subject: [PATCH] feat: adding statsV2 --- src/types/get/getProfile.ts | 11 +++++++++++ src/utils/get/getProfile.ts | 19 +++++++++++++++---- test/profile-test.ts | 13 ++++++++++--- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/types/get/getProfile.ts b/src/types/get/getProfile.ts index 49f9f54..d4dc4b5 100644 --- a/src/types/get/getProfile.ts +++ b/src/types/get/getProfile.ts @@ -4,6 +4,7 @@ export type TiktokStalkUserResponse = { result?: { user: UserProfile stats: StatsUserProfile + statsV2: StatsV2UserProfile } } @@ -33,6 +34,16 @@ export type StatsUserProfile = { friendCount: number } + +export type StatsV2UserProfile = { + followerCount: string + followingCount: string + heartCount: string + videoCount: string + likeCount: string + friendCount: string +} + export type StatisticsUserProfile = { likeCount: number shareCount: number diff --git a/src/utils/get/getProfile.ts b/src/utils/get/getProfile.ts index b5e58da..81e8893 100644 --- a/src/utils/get/getProfile.ts +++ b/src/utils/get/getProfile.ts @@ -8,7 +8,7 @@ import { import { TiktokStalkUserResponse, StatsUserProfile, - UserProfile + UserProfile, StatsV2UserProfile } from "../../types/get/getProfile" import { _getUserPostsParams, _xttParams } from "../../constants/params" import { HttpsProxyAgent } from "https-proxy-agent" @@ -66,13 +66,14 @@ export const StalkUser = ( }) } - const { user, stats } = parseDataUser(dataUser) + const { user, stats, statsV2 } = parseDataUser(dataUser) let response: TiktokStalkUserResponse = { status: "success", result: { user, - stats + stats, + statsV2 } } @@ -110,5 +111,15 @@ const parseDataUser = (dataUser: any) => { friendCount: dataUser.stats.friendCount } - return { user, stats } + // Statistics V2 Result + const statsV2: StatsV2UserProfile = { + followerCount: dataUser.statsV2.followerCount, + followingCount: dataUser.statsV2.followingCount, + heartCount: dataUser.statsV2.heartCount, + videoCount: dataUser.statsV2.videoCount, + likeCount: dataUser.statsV2.diggCount, + friendCount: dataUser.statsV2.friendCount + } + + return { user, stats, statsV2 } } diff --git a/test/profile-test.ts b/test/profile-test.ts index 08d24cf..17ced80 100644 --- a/test/profile-test.ts +++ b/test/profile-test.ts @@ -3,13 +3,12 @@ import Tiktok from "../src/index" async function testProfile() { try { - const username = "tobz2k19" // Change to a valid TikTok username + const username = "charlidamelio" // Change to a valid TikTok username const result = await Tiktok.StalkUser(username, { proxy: undefined }) if (result.status === "success" && result.result) { - const user = result.result.user - const stats = result.result.stats + const { user, stats, statsV2 } = result.result console.log("\nProfile fetched successfully!") console.log("========================") console.log("User Profile:") @@ -30,6 +29,14 @@ async function testProfile() { console.log(`- Likes: ${stats.likeCount}`) console.log(`- Friends: ${stats.friendCount}`) console.log("========================") + console.log("\nStats V2:") + console.log(`- Followers: ${statsV2.followerCount}`) + console.log(`- Following: ${statsV2.followingCount}`) + console.log(`- Hearts: ${statsV2.heartCount}`) + console.log(`- Videos: ${statsV2.videoCount}`) + console.log(`- Likes: ${statsV2.likeCount}`) + console.log(`- Friends: ${statsV2.friendCount}`) + console.log("========================") } else { console.error("Error:", result.message) }