@tiktool/live 2.10.1 → 2.11.1
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/README.md +19 -0
- package/dist/index.d.mts +65 -0
- package/dist/index.d.ts +65 -0
- package/dist/index.js +46 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +46 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2468,6 +2468,52 @@ var TikTokLive = class _TikTokLive extends EventEmitter {
|
|
|
2468
2468
|
hlsPullUrl: d.hls_pull_url || void 0
|
|
2469
2469
|
};
|
|
2470
2470
|
}
|
|
2471
|
+
/**
|
|
2472
|
+
* Resolve a TikTok username to the streamer's full public profile —
|
|
2473
|
+
* numeric user ID, secUid, nickname, bio, avatars, follower stats.
|
|
2474
|
+
*
|
|
2475
|
+
* Useful when you need the numeric TikTok ID for a username (the inverse
|
|
2476
|
+
* of `resolve_user_ids`, which only goes userId → username).
|
|
2477
|
+
*
|
|
2478
|
+
* Requires Pro tier+. Cached server-side for 24h.
|
|
2479
|
+
*
|
|
2480
|
+
* @example
|
|
2481
|
+
* ```ts
|
|
2482
|
+
* const profile = await TikTokLive.getUserProfile({
|
|
2483
|
+
* uniqueId: 'dalga.ahmedov',
|
|
2484
|
+
* apiKey: 'YOUR_KEY',
|
|
2485
|
+
* });
|
|
2486
|
+
* console.log(profile.id); // "7355610677036581896" (numeric)
|
|
2487
|
+
* console.log(profile.nickname); // display name
|
|
2488
|
+
* console.log(profile.stats.followerCount); // 12345
|
|
2489
|
+
* console.log(profile.avatarLarger); // CDN URL
|
|
2490
|
+
* ```
|
|
2491
|
+
*/
|
|
2492
|
+
static async getUserProfile(options) {
|
|
2493
|
+
const serverUrl = (options.signServerUrl || DEFAULT_SIGN_SERVER).replace(/\/$/, "");
|
|
2494
|
+
const uname = options.uniqueId.replace(/^@/, "");
|
|
2495
|
+
const qs = new URLSearchParams({ unique_id: uname });
|
|
2496
|
+
if (options.nocache) qs.set("nocache", "1");
|
|
2497
|
+
const resp = await fetch(`${serverUrl}/webcast/user_profile?${qs}`, {
|
|
2498
|
+
headers: { "x-api-key": options.apiKey }
|
|
2499
|
+
});
|
|
2500
|
+
const data = await resp.json();
|
|
2501
|
+
if (data.status_code !== 0 || !data.data?.profile) {
|
|
2502
|
+
throw new Error(data.error || `Failed to get user profile for @${uname}`);
|
|
2503
|
+
}
|
|
2504
|
+
return data.data.profile;
|
|
2505
|
+
}
|
|
2506
|
+
/**
|
|
2507
|
+
* Instance shortcut — fetch the profile of the streamer this client is
|
|
2508
|
+
* connected to (or any other user if `uniqueId` is passed).
|
|
2509
|
+
*/
|
|
2510
|
+
async getUserProfile(uniqueId) {
|
|
2511
|
+
return _TikTokLive.getUserProfile({
|
|
2512
|
+
uniqueId: uniqueId || this.uniqueId,
|
|
2513
|
+
apiKey: this.apiKey,
|
|
2514
|
+
signServerUrl: this.signServerUrl
|
|
2515
|
+
});
|
|
2516
|
+
}
|
|
2471
2517
|
on(event, listener) {
|
|
2472
2518
|
return super.on(event, listener);
|
|
2473
2519
|
}
|