@nxgiang/tiktok-api 1.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +492 -0
- package/CODE_OF_CONDUCT.md +128 -0
- package/CONTRIBUTING.md +95 -0
- package/LICENSE +201 -0
- package/README.md +1663 -0
- package/bun.lock +367 -0
- package/helper/signature.js +390 -0
- package/helper/webmssdk.js +4586 -0
- package/helper/xbogus.js +563 -0
- package/install.sh +51 -0
- package/lib/cli/index.d.ts +2 -0
- package/lib/cli/index.js +809 -0
- package/lib/constants/api.d.ts +22 -0
- package/lib/constants/api.js +39 -0
- package/lib/constants/headers.d.ts +2 -0
- package/lib/constants/headers.js +5 -0
- package/lib/constants/index.d.ts +23 -0
- package/lib/constants/index.js +26 -0
- package/lib/constants/params.d.ts +19 -0
- package/lib/constants/params.js +531 -0
- package/lib/index.d.ts +93 -0
- package/lib/index.js +137 -0
- package/lib/lib/logger.d.ts +8 -0
- package/lib/lib/logger.js +25 -0
- package/lib/services/cookieManager.d.ts +10 -0
- package/lib/services/cookieManager.js +51 -0
- package/lib/services/downloadManager.d.ts +5 -0
- package/lib/services/downloadManager.js +188 -0
- package/lib/services/tiktokService.d.ts +14 -0
- package/lib/services/tiktokService.js +78 -0
- package/lib/types/common.d.ts +65 -0
- package/lib/types/common.js +2 -0
- package/lib/types/cookieManager.d.ts +13 -0
- package/lib/types/cookieManager.js +2 -0
- package/lib/types/downloader/musicaldownDownloader.d.ts +27 -0
- package/lib/types/downloader/musicaldownDownloader.js +2 -0
- package/lib/types/downloader/ssstikDownloader.d.ts +30 -0
- package/lib/types/downloader/ssstikDownloader.js +2 -0
- package/lib/types/downloader/tiktokApiDownloader.d.ts +38 -0
- package/lib/types/downloader/tiktokApiDownloader.js +2 -0
- package/lib/types/get/getCollection.d.ts +53 -0
- package/lib/types/get/getCollection.js +2 -0
- package/lib/types/get/getComments.d.ts +26 -0
- package/lib/types/get/getComments.js +2 -0
- package/lib/types/get/getMusicDetail.d.ts +49 -0
- package/lib/types/get/getMusicDetail.js +2 -0
- package/lib/types/get/getMusicVideos.d.ts +93 -0
- package/lib/types/get/getMusicVideos.js +2 -0
- package/lib/types/get/getPlaylist.d.ts +65 -0
- package/lib/types/get/getPlaylist.js +2 -0
- package/lib/types/get/getProfile.d.ts +71 -0
- package/lib/types/get/getProfile.js +2 -0
- package/lib/types/get/getTrendings.d.ts +61 -0
- package/lib/types/get/getTrendings.js +2 -0
- package/lib/types/get/getUserLiked.d.ts +90 -0
- package/lib/types/get/getUserLiked.js +2 -0
- package/lib/types/get/getUserPosts.d.ts +68 -0
- package/lib/types/get/getUserPosts.js +2 -0
- package/lib/types/get/getUserReposts.d.ts +104 -0
- package/lib/types/get/getUserReposts.js +2 -0
- package/lib/types/search/index.d.ts +15 -0
- package/lib/types/search/index.js +2 -0
- package/lib/types/search/liveSearch.d.ts +48 -0
- package/lib/types/search/liveSearch.js +2 -0
- package/lib/types/search/userSearch.d.ts +32 -0
- package/lib/types/search/userSearch.js +2 -0
- package/lib/types/search/videoSearch.d.ts +62 -0
- package/lib/types/search/videoSearch.js +2 -0
- package/lib/utils/downloader/musicaldownDownloader.d.ts +2 -0
- package/lib/utils/downloader/musicaldownDownloader.js +193 -0
- package/lib/utils/downloader/ssstikDownloader.d.ts +2 -0
- package/lib/utils/downloader/ssstikDownloader.js +177 -0
- package/lib/utils/downloader/tiktokAPIDownloader.d.ts +3 -0
- package/lib/utils/downloader/tiktokAPIDownloader.js +221 -0
- package/lib/utils/get/getCollection.d.ts +7 -0
- package/lib/utils/get/getCollection.js +113 -0
- package/lib/utils/get/getComments.d.ts +2 -0
- package/lib/utils/get/getComments.js +139 -0
- package/lib/utils/get/getMusicDetail.d.ts +2 -0
- package/lib/utils/get/getMusicDetail.js +68 -0
- package/lib/utils/get/getMusicVideos.d.ts +2 -0
- package/lib/utils/get/getMusicVideos.js +249 -0
- package/lib/utils/get/getPlaylist.d.ts +7 -0
- package/lib/utils/get/getPlaylist.js +115 -0
- package/lib/utils/get/getProfile.d.ts +2 -0
- package/lib/utils/get/getProfile.js +92 -0
- package/lib/utils/get/getTrendings.d.ts +7 -0
- package/lib/utils/get/getTrendings.js +120 -0
- package/lib/utils/get/getUserLiked.d.ts +2 -0
- package/lib/utils/get/getUserLiked.js +204 -0
- package/lib/utils/get/getUserPosts.d.ts +2 -0
- package/lib/utils/get/getUserPosts.js +199 -0
- package/lib/utils/get/getUserRepost.d.ts +2 -0
- package/lib/utils/get/getUserRepost.js +239 -0
- package/lib/utils/search/liveSearch.d.ts +2 -0
- package/lib/utils/search/liveSearch.js +99 -0
- package/lib/utils/search/userSearch.d.ts +2 -0
- package/lib/utils/search/userSearch.js +76 -0
- package/lib/utils/search/videoSearch.d.ts +2 -0
- package/lib/utils/search/videoSearch.js +140 -0
- package/lib/utils/urlExtractors.d.ts +3 -0
- package/lib/utils/urlExtractors.js +37 -0
- package/lib/utils/validator.d.ts +1 -0
- package/lib/utils/validator.js +13 -0
- package/package.json +60 -0
- package/test/collection-test.ts +73 -0
- package/test/comments-test.ts +54 -0
- package/test/downloader-v1-test.ts +49 -0
- package/test/downloader-v2-test.ts +47 -0
- package/test/downloader-v3-test.ts +35 -0
- package/test/music-detail-test.ts +97 -0
- package/test/music-videos-test.ts +86 -0
- package/test/playlist-test.ts +48 -0
- package/test/profile-test.ts +49 -0
- package/test/search-live-test.ts +42 -0
- package/test/search-user-test.ts +46 -0
- package/test/search-video-test.ts +53 -0
- package/test/trending-test.ts +128 -0
- package/test/userliked-test.ts +65 -0
- package/test/userposts-test.ts +56 -0
- package/test/userreposts-test.ts +57 -0
- package/tobyg74-tiktok-api-1.3.7.tgz +0 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Test for Tiktok Downloader v3
|
|
2
|
+
import Tiktok from "../src/index"
|
|
3
|
+
|
|
4
|
+
async function testDownloaderV3() {
|
|
5
|
+
try {
|
|
6
|
+
const url = "https://www.tiktok.com/@tobz2k19/video/7451777267107187986" // Change to a valid TikTok video URL
|
|
7
|
+
console.log(`\nTesting Downloader version: v3`)
|
|
8
|
+
const result = await Tiktok.Downloader(url, {
|
|
9
|
+
version: "v3",
|
|
10
|
+
proxy: undefined
|
|
11
|
+
})
|
|
12
|
+
if (result.status === "success" && result.result) {
|
|
13
|
+
const r = result.result
|
|
14
|
+
console.log(`Type: ${r.type}`)
|
|
15
|
+
if (r.desc) console.log(`Description: ${r.desc}`)
|
|
16
|
+
if (r.author && r.author.nickname) {
|
|
17
|
+
console.log(`Author: ${r.author.nickname}`)
|
|
18
|
+
} else if (r.author && r.author.avatar) {
|
|
19
|
+
// fallback for v3 author structure
|
|
20
|
+
console.log(`Author Avatar: ${r.author.avatar}`)
|
|
21
|
+
}
|
|
22
|
+
if (r.videoHD) console.log(`Video HD: ${r.videoHD}`)
|
|
23
|
+
if (r.videoWatermark) console.log(`Video Watermark: ${r.videoWatermark}`)
|
|
24
|
+
if (r.images?.length) console.log(`Images: ${r.images.join(", ")}`)
|
|
25
|
+
if (r.music) console.log(`Music: ${r.music}`)
|
|
26
|
+
console.log("========================")
|
|
27
|
+
} else {
|
|
28
|
+
console.error("Error:", result.message)
|
|
29
|
+
}
|
|
30
|
+
} catch (error) {
|
|
31
|
+
console.error("Test failed:", error)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
testDownloaderV3()
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// Test for Tiktok Get Music Detail
|
|
2
|
+
import Tiktok from "../src/index"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Test getMusicDetail function
|
|
6
|
+
* This test will fetch detailed information for a specific music ID or URL
|
|
7
|
+
* Note: This requires a valid TikTok cookie
|
|
8
|
+
*/
|
|
9
|
+
async function testGetMusicDetail() {
|
|
10
|
+
console.log("Testing getMusicDetail function...")
|
|
11
|
+
|
|
12
|
+
// You can use either music ID or URL
|
|
13
|
+
const musicIdOrUrl = "https://www.tiktok.com/music/QKThr-6771810675950880769"
|
|
14
|
+
// const musicIdOrUrl = "6771810675950880769" // Alternative: use direct ID
|
|
15
|
+
|
|
16
|
+
// IMPORTANT: Replace with your actual TikTok cookie
|
|
17
|
+
const cookie = "YOUR_TIKTOK_COOKIE_HERE" // Get this from your browser's dev tools
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
console.log(`Fetching music detail for: ${musicIdOrUrl}`)
|
|
21
|
+
console.log("Note: Make sure you have set a valid TikTok cookie\n")
|
|
22
|
+
|
|
23
|
+
const result = await Tiktok.GetMusicDetail(musicIdOrUrl, {
|
|
24
|
+
cookie: cookie
|
|
25
|
+
// proxy: "http://your-proxy-url" // Optional: Add proxy if needed
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
console.log("Result received:")
|
|
29
|
+
console.log(`Status: ${result.status}`)
|
|
30
|
+
|
|
31
|
+
if (result.status === "success" && result.result) {
|
|
32
|
+
const { musicInfo, shareMeta } = result.result
|
|
33
|
+
|
|
34
|
+
console.log("\n========================")
|
|
35
|
+
console.log("MUSIC INFORMATION")
|
|
36
|
+
console.log("========================")
|
|
37
|
+
console.log(`Music ID: ${musicInfo.music.id}`)
|
|
38
|
+
console.log(`Title: ${musicInfo.music.title}`)
|
|
39
|
+
console.log(`Author Name: ${musicInfo.music.authorName}`)
|
|
40
|
+
console.log(`Duration: ${musicInfo.music.duration} seconds`)
|
|
41
|
+
console.log(`Original: ${musicInfo.music.original ? "Yes" : "No"}`)
|
|
42
|
+
console.log(
|
|
43
|
+
`Copyrighted: ${musicInfo.music.isCopyrighted ? "Yes" : "No"}`
|
|
44
|
+
)
|
|
45
|
+
console.log(`Private: ${musicInfo.music.private ? "Yes" : "No"}`)
|
|
46
|
+
|
|
47
|
+
console.log("\n========================")
|
|
48
|
+
console.log("AUTHOR INFORMATION")
|
|
49
|
+
console.log("========================")
|
|
50
|
+
console.log(`Author ID: ${musicInfo.author?.id}`)
|
|
51
|
+
console.log(`Nickname: ${musicInfo.author?.nickname}`)
|
|
52
|
+
console.log(`Username: @${musicInfo.author?.uniqueId}`)
|
|
53
|
+
console.log(`Verified: ${musicInfo.author?.ftc ? "Yes" : "No"}`)
|
|
54
|
+
console.log(
|
|
55
|
+
`Private Account: ${musicInfo.author?.privateAccount ? "Yes" : "No"}`
|
|
56
|
+
)
|
|
57
|
+
console.log(`Secure UID: ${musicInfo.author?.secUid}`)
|
|
58
|
+
console.log(`Signature: ${musicInfo.author?.signature || "No signature"}`)
|
|
59
|
+
|
|
60
|
+
console.log("\n========================")
|
|
61
|
+
console.log("STATISTICS")
|
|
62
|
+
console.log("========================")
|
|
63
|
+
console.log(
|
|
64
|
+
`Videos using this music: ${musicInfo.stats.videoCount.toLocaleString()}`
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
console.log("\n========================")
|
|
68
|
+
console.log("URLS")
|
|
69
|
+
console.log("========================")
|
|
70
|
+
console.log(`Play URL: ${musicInfo.music.playUrl}`)
|
|
71
|
+
console.log(`Cover Thumbnail: ${musicInfo.music.coverThumb}`)
|
|
72
|
+
console.log(`Cover Medium: ${musicInfo.music.coverMedium}`)
|
|
73
|
+
console.log(`Cover Large: ${musicInfo.music.coverLarge}`)
|
|
74
|
+
|
|
75
|
+
if (shareMeta) {
|
|
76
|
+
console.log("\n========================")
|
|
77
|
+
console.log("SHARE META")
|
|
78
|
+
console.log("========================")
|
|
79
|
+
console.log(`Title: ${shareMeta.title}`)
|
|
80
|
+
console.log(`Description: ${shareMeta.desc}`)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
console.log("\nā
Test completed successfully!")
|
|
84
|
+
console.log(
|
|
85
|
+
"\nš” Tip: Use 'GetVideosByMusicId' to get videos using this music"
|
|
86
|
+
)
|
|
87
|
+
} else {
|
|
88
|
+
console.log(`ā Error: ${result.message}`)
|
|
89
|
+
}
|
|
90
|
+
} catch (error: any) {
|
|
91
|
+
console.error("\nā Test failed:", error.message)
|
|
92
|
+
console.error("\nError details:", error)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Run the test
|
|
97
|
+
testGetMusicDetail()
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// Test for Tiktok Get Music Videos
|
|
2
|
+
import Tiktok from "../src/index"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Test getMusicVideos function
|
|
6
|
+
* This test will fetch videos for a specific music ID or URL
|
|
7
|
+
*/
|
|
8
|
+
async function testGetMusicVideos() {
|
|
9
|
+
console.log("Testing getMusicVideos function...")
|
|
10
|
+
|
|
11
|
+
// You can use either music ID or URL
|
|
12
|
+
const musicIdOrUrl = "https://www.tiktok.com/music/QKThr-6771810675950880769"
|
|
13
|
+
// const musicIdOrUrl = "7034143722082192134" // Alternative: use direct ID
|
|
14
|
+
|
|
15
|
+
try {
|
|
16
|
+
console.log(`Fetching videos for: ${musicIdOrUrl}`)
|
|
17
|
+
|
|
18
|
+
const result = await Tiktok.GetVideosByMusicId(musicIdOrUrl, {
|
|
19
|
+
page: 1,
|
|
20
|
+
count: 30
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
console.log("Result received:")
|
|
24
|
+
console.log(`Status: ${result.status}`)
|
|
25
|
+
|
|
26
|
+
if (result.status === "success" && result.result) {
|
|
27
|
+
console.log(`Music Info:`)
|
|
28
|
+
if (result.result.music) {
|
|
29
|
+
console.log(` - Title: ${result.result.music.title}`)
|
|
30
|
+
console.log(` - Artist: ${result.result.music.authorName}`)
|
|
31
|
+
console.log(` - ID: ${result.result.music.id}`)
|
|
32
|
+
console.log(` - Duration: ${result.result.music.duration}s`)
|
|
33
|
+
console.log(
|
|
34
|
+
` - Original: ${result.result.music.original ? "Yes" : "No"}`
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
console.log(`\nVideos:`)
|
|
39
|
+
console.log(` - Total found: ${result.result.totalVideos}`)
|
|
40
|
+
|
|
41
|
+
if (result.result.videos && result.result.videos.length > 0) {
|
|
42
|
+
result.result.videos.forEach((video, index) => {
|
|
43
|
+
console.log(` ${index + 1}. Video ID: ${video.id}`)
|
|
44
|
+
console.log(
|
|
45
|
+
` Author: @${video.author.uniqueId} (${video.author.nickname})`
|
|
46
|
+
)
|
|
47
|
+
console.log(
|
|
48
|
+
` Description: ${
|
|
49
|
+
video.desc?.substring(0, 50) || "No description"
|
|
50
|
+
}${video.desc && video.desc.length > 50 ? "..." : ""}`
|
|
51
|
+
)
|
|
52
|
+
console.log(
|
|
53
|
+
` Created: ${new Date(
|
|
54
|
+
video.createTime * 1000
|
|
55
|
+
).toLocaleDateString()}`
|
|
56
|
+
)
|
|
57
|
+
console.log(
|
|
58
|
+
` Stats: ${video.stats.playCount} views, ${video.stats.diggCount} likes, ${video.stats.commentCount} comments`
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
if (video.video) {
|
|
62
|
+
console.log(` Video Duration: ${video.video.duration}s`)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (video.imagePost) {
|
|
66
|
+
console.log(` Image Post: ${video.imagePost.length} images`)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (video.effectStickers && video.effectStickers.length > 0) {
|
|
70
|
+
console.log(
|
|
71
|
+
` Effects: ${video.effectStickers.length} effects used`
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
console.log("")
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
} else {
|
|
79
|
+
console.log(`ā Error: ${result.message}`)
|
|
80
|
+
}
|
|
81
|
+
} catch (error: any) {
|
|
82
|
+
console.error("ā Test failed:", error.message)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
testGetMusicVideos()
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Test for Tiktok Playlist
|
|
2
|
+
import Tiktok from "../src/index"
|
|
3
|
+
|
|
4
|
+
async function testPlaylist() {
|
|
5
|
+
try {
|
|
6
|
+
const playlistUrl =
|
|
7
|
+
"https://www.tiktok.com/@tobz2k19/playlist/tset-7511644672511626004" // Ganti dengan URL playlist yang valid jika perlu
|
|
8
|
+
console.log(`\nTesting Playlist: ${playlistUrl}`)
|
|
9
|
+
const result = await Tiktok.Playlist(playlistUrl, {
|
|
10
|
+
proxy: undefined,
|
|
11
|
+
page: 1,
|
|
12
|
+
count: 5
|
|
13
|
+
})
|
|
14
|
+
if (result.status === "success" && result.result) {
|
|
15
|
+
const { itemList, hasMore, extra } = result.result
|
|
16
|
+
console.log(`Total Videos: ${itemList.length}`)
|
|
17
|
+
itemList.forEach((item, idx) => {
|
|
18
|
+
console.log(`\n[${idx + 1}] ID: ${item.id}`)
|
|
19
|
+
console.log(`Description: ${item.desc}`)
|
|
20
|
+
if (item.author) {
|
|
21
|
+
console.log(`Author: ${item.author.nickname}`)
|
|
22
|
+
}
|
|
23
|
+
if (item.stats) {
|
|
24
|
+
console.log("Statistics:")
|
|
25
|
+
console.log(`- Likes: ${item.stats.diggCount}`)
|
|
26
|
+
console.log(`- Comments: ${item.stats.commentCount}`)
|
|
27
|
+
console.log(`- Shares: ${item.stats.shareCount}`)
|
|
28
|
+
console.log(`- Plays: ${item.stats.playCount}`)
|
|
29
|
+
}
|
|
30
|
+
if (item.video?.playAddr?.length) {
|
|
31
|
+
console.log(`Video URL: ${item.video.playAddr}`)
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
console.log("========================")
|
|
35
|
+
if (hasMore) {
|
|
36
|
+
console.log(
|
|
37
|
+
"There are more videos. Use the 'page' option to fetch next page."
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
} else {
|
|
41
|
+
console.error("Error:", result.message)
|
|
42
|
+
}
|
|
43
|
+
} catch (error) {
|
|
44
|
+
console.error("Test failed:", error)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
testPlaylist()
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Test for Tiktok Stalk User Profile
|
|
2
|
+
import Tiktok from "../src/index"
|
|
3
|
+
|
|
4
|
+
async function testProfile() {
|
|
5
|
+
try {
|
|
6
|
+
const username = "charlidamelio" // Change to a valid TikTok username
|
|
7
|
+
const result = await Tiktok.StalkUser(username, {
|
|
8
|
+
proxy: undefined
|
|
9
|
+
})
|
|
10
|
+
if (result.status === "success" && result.result) {
|
|
11
|
+
const { user, stats, statsV2 } = result.result
|
|
12
|
+
console.log("\nProfile fetched successfully!")
|
|
13
|
+
console.log("========================")
|
|
14
|
+
console.log("User Profile:")
|
|
15
|
+
console.log("========================")
|
|
16
|
+
console.log(`Username: @${user.username}`)
|
|
17
|
+
console.log(`Nickname: ${user.nickname}`)
|
|
18
|
+
console.log(`Signature: ${user.signature}`)
|
|
19
|
+
console.log(`Verified: ${user.verified ? "Yes" : "No"}`)
|
|
20
|
+
console.log(`Region: ${user.region}`)
|
|
21
|
+
console.log(`Private Account: ${user.privateAccount ? "Yes" : "No"}`)
|
|
22
|
+
console.log(`Commerce User: ${user.commerceUser ? "Yes" : "No"}`)
|
|
23
|
+
console.log(`Avatar: ${user.avatarLarger}`)
|
|
24
|
+
console.log(`Secured ID: ${user.secUid}`)
|
|
25
|
+
console.log("\nStats:")
|
|
26
|
+
console.log(`- Followers: ${stats.followerCount}`)
|
|
27
|
+
console.log(`- Following: ${stats.followingCount}`)
|
|
28
|
+
console.log(`- Hearts: ${stats.heartCount}`)
|
|
29
|
+
console.log(`- Videos: ${stats.videoCount}`)
|
|
30
|
+
console.log(`- Likes: ${stats.likeCount}`)
|
|
31
|
+
console.log(`- Friends: ${stats.friendCount}`)
|
|
32
|
+
console.log("========================")
|
|
33
|
+
console.log("\nStats V2:")
|
|
34
|
+
console.log(`- Followers: ${statsV2.followerCount}`)
|
|
35
|
+
console.log(`- Following: ${statsV2.followingCount}`)
|
|
36
|
+
console.log(`- Hearts: ${statsV2.heartCount}`)
|
|
37
|
+
console.log(`- Videos: ${statsV2.videoCount}`)
|
|
38
|
+
console.log(`- Likes: ${statsV2.likeCount}`)
|
|
39
|
+
console.log(`- Friends: ${statsV2.friendCount}`)
|
|
40
|
+
console.log("========================")
|
|
41
|
+
} else {
|
|
42
|
+
console.error("Error:", result.message)
|
|
43
|
+
}
|
|
44
|
+
} catch (error) {
|
|
45
|
+
console.error("Test failed:", error)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
testProfile()
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Test for Tiktok Search Live
|
|
2
|
+
import Tiktok from "../src/index"
|
|
3
|
+
|
|
4
|
+
async function testSearchLive() {
|
|
5
|
+
try {
|
|
6
|
+
const keyword = "call of duty" // Change to a valid search keyword
|
|
7
|
+
const cookie = "" // Optional: provide a valid TikTok cookie if needed
|
|
8
|
+
console.log(`\nTesting Search type: live`)
|
|
9
|
+
const result = await Tiktok.Search(keyword, {
|
|
10
|
+
type: "live",
|
|
11
|
+
cookie,
|
|
12
|
+
page: 1,
|
|
13
|
+
proxy: undefined
|
|
14
|
+
})
|
|
15
|
+
if (result.status === "success" && result.result) {
|
|
16
|
+
console.log("Success! Parsed Result:")
|
|
17
|
+
result.result.forEach((item, index) => {
|
|
18
|
+
if (item.type === "live") {
|
|
19
|
+
const live = item as typeof item & { liveInfo: any }
|
|
20
|
+
if (live.liveInfo) {
|
|
21
|
+
console.log(`\nResult ${index + 1}:`)
|
|
22
|
+
console.log("-------------------")
|
|
23
|
+
console.log(`ID: ${live.liveInfo.id}`)
|
|
24
|
+
console.log(`Title: ${live.liveInfo.title}`)
|
|
25
|
+
console.log(`Hashtag: ${live.liveInfo.hashtag}`)
|
|
26
|
+
if (live.liveInfo.owner)
|
|
27
|
+
console.log(`Owner: ${live.liveInfo.owner.nickname}`)
|
|
28
|
+
if (live.liveInfo.stats)
|
|
29
|
+
console.log(`Viewers: ${live.liveInfo.stats.viewerCount}`)
|
|
30
|
+
console.log("========================")
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
} else {
|
|
35
|
+
console.error("Error:", result.message)
|
|
36
|
+
}
|
|
37
|
+
} catch (error) {
|
|
38
|
+
console.error("Test failed:", error)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
testSearchLive()
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Test for Tiktok Search User
|
|
2
|
+
import Tiktok from "../src/index"
|
|
3
|
+
|
|
4
|
+
async function testSearchUser() {
|
|
5
|
+
try {
|
|
6
|
+
const keyword = "call of duty" // Change to a valid search keyword
|
|
7
|
+
const cookie = "" // Optional: provide a valid TikTok cookie if needed
|
|
8
|
+
console.log(`\nTesting Search type: user`)
|
|
9
|
+
const result = await Tiktok.Search(keyword, {
|
|
10
|
+
type: "user",
|
|
11
|
+
cookie,
|
|
12
|
+
page: 1,
|
|
13
|
+
proxy: undefined
|
|
14
|
+
})
|
|
15
|
+
if (result.status === "success" && result.result) {
|
|
16
|
+
console.log("Success! Parsed Result:")
|
|
17
|
+
result.result.forEach((item, index) => {
|
|
18
|
+
if (item.type === "user") {
|
|
19
|
+
const user = item as typeof item & {
|
|
20
|
+
uid: string
|
|
21
|
+
username: string
|
|
22
|
+
nickname: string
|
|
23
|
+
followerCount: number
|
|
24
|
+
isVerified: boolean
|
|
25
|
+
url: string
|
|
26
|
+
}
|
|
27
|
+
console.log(`\nResult ${index + 1}:`)
|
|
28
|
+
console.log("-------------------")
|
|
29
|
+
console.log(`UID: ${user.uid}`)
|
|
30
|
+
console.log(`Username: ${user.username}`)
|
|
31
|
+
console.log(`Nickname: ${user.nickname}`)
|
|
32
|
+
console.log(`Followers: ${user.followerCount}`)
|
|
33
|
+
console.log(`Verified: ${user.isVerified ? "Yes" : "No"}`)
|
|
34
|
+
console.log(`Profile URL: ${user.url}`)
|
|
35
|
+
console.log("========================")
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
} else {
|
|
39
|
+
console.error("Error:", result.message)
|
|
40
|
+
}
|
|
41
|
+
} catch (error) {
|
|
42
|
+
console.error("Test failed:", error)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
testSearchUser()
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Test for Tiktok Search Video
|
|
2
|
+
import Tiktok from "../src/index"
|
|
3
|
+
|
|
4
|
+
async function testSearchVideo() {
|
|
5
|
+
try {
|
|
6
|
+
const keyword = "call of duty" // Change to a valid search keyword
|
|
7
|
+
const cookie = "" // Optional: provide a valid TikTok cookie if needed
|
|
8
|
+
console.log(`\nTesting Search type: video`)
|
|
9
|
+
const result = await Tiktok.Search(keyword, {
|
|
10
|
+
type: "video",
|
|
11
|
+
cookie,
|
|
12
|
+
page: 1,
|
|
13
|
+
proxy: undefined
|
|
14
|
+
})
|
|
15
|
+
if (result.status === "success" && result.result) {
|
|
16
|
+
console.log("Success! Parsed Result:")
|
|
17
|
+
result.result.forEach((item, index) => {
|
|
18
|
+
if (item.type === "video") {
|
|
19
|
+
const video = item as typeof item & {
|
|
20
|
+
id: string
|
|
21
|
+
desc: string
|
|
22
|
+
author: any
|
|
23
|
+
createTime: number
|
|
24
|
+
stats: any
|
|
25
|
+
}
|
|
26
|
+
console.log(`\nResult ${index + 1}:`)
|
|
27
|
+
console.log("-------------------")
|
|
28
|
+
console.log(`ID: ${video.id}`)
|
|
29
|
+
console.log(`Description: ${video.desc}`)
|
|
30
|
+
if (video.author) console.log(`Author: ${video.author.nickname}`)
|
|
31
|
+
if (video.createTime)
|
|
32
|
+
console.log(
|
|
33
|
+
`Created: ${new Date(video.createTime * 1000).toLocaleString()}`
|
|
34
|
+
)
|
|
35
|
+
if (video.stats) {
|
|
36
|
+
console.log("Statistics:")
|
|
37
|
+
console.log(`- Likes: ${video.stats.likeCount}`)
|
|
38
|
+
console.log(`- Comments: ${video.stats.commentCount}`)
|
|
39
|
+
console.log(`- Shares: ${video.stats.shareCount}`)
|
|
40
|
+
console.log(`- Plays: ${video.stats.playCount}`)
|
|
41
|
+
}
|
|
42
|
+
console.log("========================")
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
} else {
|
|
46
|
+
console.error("Error:", result.message)
|
|
47
|
+
}
|
|
48
|
+
} catch (error) {
|
|
49
|
+
console.error("Test failed:", error)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
testSearchVideo()
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// Test for TikTok Trending Content
|
|
2
|
+
import Tiktok from "../src/index"
|
|
3
|
+
|
|
4
|
+
async function testTrending() {
|
|
5
|
+
try {
|
|
6
|
+
console.log(`\nTesting TikTok Trending Content`)
|
|
7
|
+
console.log("===============================")
|
|
8
|
+
|
|
9
|
+
// Test basic trending functionality
|
|
10
|
+
const result = await Tiktok.Trending({
|
|
11
|
+
proxy: undefined // Add proxy if needed
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
if (result.status === "success" && result.result) {
|
|
15
|
+
console.log("ā
Success! Trending content fetched successfully")
|
|
16
|
+
console.log(`š Total trending sections: ${result.result.length}`)
|
|
17
|
+
|
|
18
|
+
result.result.forEach((section, sectionIndex) => {
|
|
19
|
+
console.log(`\nš Section ${sectionIndex + 1}:`)
|
|
20
|
+
console.log("-------------------")
|
|
21
|
+
console.log(`Items in this section: ${section.exploreList.length}`)
|
|
22
|
+
|
|
23
|
+
section.exploreList.slice(0, 3).forEach((item, index) => {
|
|
24
|
+
const cardItem = item.cardItem
|
|
25
|
+
console.log(`\n Item ${index + 1}:`)
|
|
26
|
+
console.log(` ID: ${cardItem.id}`)
|
|
27
|
+
console.log(` Title: ${cardItem.title}`)
|
|
28
|
+
console.log(` Subtitle: ${cardItem.subTitle}`)
|
|
29
|
+
console.log(` Type: ${cardItem.type}`)
|
|
30
|
+
console.log(
|
|
31
|
+
` Description: ${cardItem.description.substring(0, 100)}${
|
|
32
|
+
cardItem.description.length > 100 ? "..." : ""
|
|
33
|
+
}`
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
if (cardItem.extraInfo) {
|
|
37
|
+
console.log(
|
|
38
|
+
` Verified: ${cardItem.extraInfo.verified ? "Yes" : "No"}`
|
|
39
|
+
)
|
|
40
|
+
console.log(
|
|
41
|
+
` Fans: ${cardItem.extraInfo.fans?.toLocaleString() || "N/A"}`
|
|
42
|
+
)
|
|
43
|
+
console.log(
|
|
44
|
+
` Likes: ${cardItem.extraInfo.likes?.toLocaleString() || "N/A"}`
|
|
45
|
+
)
|
|
46
|
+
console.log(` Videos: ${cardItem.extraInfo.video || "N/A"}`)
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
if (section.exploreList.length > 3) {
|
|
51
|
+
console.log(` ... and ${section.exploreList.length - 3} more items`)
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
} else {
|
|
55
|
+
console.error("ā Error fetching trending content:", result.message)
|
|
56
|
+
}
|
|
57
|
+
} catch (error) {
|
|
58
|
+
console.error("ā Test failed:", error)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async function testTrendingCreators() {
|
|
63
|
+
try {
|
|
64
|
+
console.log(`\n\nTesting TikTok Trending Creators`)
|
|
65
|
+
console.log("=================================")
|
|
66
|
+
|
|
67
|
+
// Test trending creators functionality
|
|
68
|
+
const result = await Tiktok.TrendingCreators({
|
|
69
|
+
proxy: undefined // Add proxy if needed
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
if (result.status === "success" && result.result) {
|
|
73
|
+
console.log("ā
Success! Trending creators fetched successfully")
|
|
74
|
+
console.log(`š„ Total trending creators: ${result.result.length}`)
|
|
75
|
+
|
|
76
|
+
result.result.slice(0, 10).forEach((creator, index) => {
|
|
77
|
+
console.log(`\nš¤ Creator ${index + 1}:`)
|
|
78
|
+
console.log("-------------------")
|
|
79
|
+
console.log(`ID: ${creator.id}`)
|
|
80
|
+
console.log(`Username: @${creator.username}`)
|
|
81
|
+
console.log(`Nickname: ${creator.nickname}`)
|
|
82
|
+
console.log(`Verified: ${creator.verified ? "ā
Yes" : "ā No"}`)
|
|
83
|
+
console.log(`Followers: ${creator.followerCount.toLocaleString()}`)
|
|
84
|
+
console.log(`Total Likes: ${creator.likeCount.toLocaleString()}`)
|
|
85
|
+
console.log(`Videos: ${creator.videoCount.toLocaleString()}`)
|
|
86
|
+
console.log(`Following: ${creator.followingCount.toLocaleString()}`)
|
|
87
|
+
console.log(
|
|
88
|
+
`Description: ${creator.description.substring(0, 80)}${
|
|
89
|
+
creator.description.length > 80 ? "..." : ""
|
|
90
|
+
}`
|
|
91
|
+
)
|
|
92
|
+
console.log(`Profile Link: https://www.tiktok.com${creator.link}`)
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
if (result.result.length > 10) {
|
|
96
|
+
console.log(`\n... and ${result.result.length - 10} more creators`)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Show some statistics
|
|
100
|
+
const verifiedCount = result.result.filter((c) => c.verified).length
|
|
101
|
+
const totalFollowers = result.result.reduce(
|
|
102
|
+
(sum, c) => sum + c.followerCount,
|
|
103
|
+
0
|
|
104
|
+
)
|
|
105
|
+
const avgFollowers = Math.round(totalFollowers / result.result.length)
|
|
106
|
+
|
|
107
|
+
console.log(`\nš Statistics:`)
|
|
108
|
+
console.log(`Verified creators: ${verifiedCount}/${result.result.length}`)
|
|
109
|
+
console.log(`Average followers: ${avgFollowers.toLocaleString()}`)
|
|
110
|
+
console.log(
|
|
111
|
+
`Total combined followers: ${totalFollowers.toLocaleString()}`
|
|
112
|
+
)
|
|
113
|
+
} else {
|
|
114
|
+
console.error("ā Error fetching trending creators:", result.message)
|
|
115
|
+
}
|
|
116
|
+
} catch (error) {
|
|
117
|
+
console.error("ā Test failed:", error)
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Run both tests
|
|
122
|
+
async function runAllTests() {
|
|
123
|
+
await testTrending()
|
|
124
|
+
await testTrendingCreators()
|
|
125
|
+
console.log(`\nš All trending tests completed!`)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
runAllTests()
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// Test for Tiktok Get User Liked Videos
|
|
2
|
+
import Tiktok from "../src/index"
|
|
3
|
+
|
|
4
|
+
async function testUserLiked() {
|
|
5
|
+
try {
|
|
6
|
+
const username = "Tobz2k19" // Change to a valid TikTok username
|
|
7
|
+
const cookie = "YOUR_TIKTOK_COOKIE_HERE" // Get this from your browser's dev tools
|
|
8
|
+
const result = await Tiktok.GetUserLiked(username, {
|
|
9
|
+
cookie,
|
|
10
|
+
postLimit: 5,
|
|
11
|
+
proxy: undefined
|
|
12
|
+
})
|
|
13
|
+
if (result.status === "success" && result.result) {
|
|
14
|
+
console.log("\nUser Liked Videos fetched successfully!")
|
|
15
|
+
console.log("========================")
|
|
16
|
+
console.log("Liked Videos Overview:")
|
|
17
|
+
console.log("========================")
|
|
18
|
+
console.log(`Total liked videos fetched: ${result.result.length}`)
|
|
19
|
+
result.result.forEach((liked, index) => {
|
|
20
|
+
console.log(`\nLiked Video ${index + 1}:`)
|
|
21
|
+
console.log("-------------------")
|
|
22
|
+
console.log(`ID: ${liked.id}`)
|
|
23
|
+
console.log(`Description: ${liked.desc}`)
|
|
24
|
+
if (liked.author) {
|
|
25
|
+
console.log(
|
|
26
|
+
`Author: ${liked.author.nickname} (@${liked.author.username})`
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
if (liked.createTime) {
|
|
30
|
+
console.log(
|
|
31
|
+
`Created: ${new Date(
|
|
32
|
+
Number(liked.createTime) * 1000
|
|
33
|
+
).toLocaleString()}`
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
if (liked.stats) {
|
|
37
|
+
console.log("Statistics:")
|
|
38
|
+
console.log(`- Likes: ${liked.stats.diggCount}`)
|
|
39
|
+
console.log(`- Favorites: ${liked.stats.collectCount}`)
|
|
40
|
+
console.log(`- Comments: ${liked.stats.commentCount}`)
|
|
41
|
+
console.log(`- Shares: ${liked.stats.shareCount}`)
|
|
42
|
+
console.log(`- Plays: ${liked.stats.playCount}`)
|
|
43
|
+
console.log(`- Reposts: ${liked.stats.repostCount}`)
|
|
44
|
+
}
|
|
45
|
+
if (liked.video?.playAddr) {
|
|
46
|
+
console.log(`Video URL: ${liked.video.playAddr}`)
|
|
47
|
+
}
|
|
48
|
+
if (liked.imagePost?.length) {
|
|
49
|
+
console.log(
|
|
50
|
+
`Images: \n${liked.imagePost
|
|
51
|
+
.map((img) => img.images)
|
|
52
|
+
.join("\n - ")}`
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
console.log("========================")
|
|
56
|
+
})
|
|
57
|
+
} else {
|
|
58
|
+
console.error("Error:", result.message)
|
|
59
|
+
}
|
|
60
|
+
} catch (error) {
|
|
61
|
+
console.error("Test failed:", error)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
testUserLiked()
|