@tiktool/live 2.10.1 → 2.11.0

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/dist/index.d.mts CHANGED
@@ -370,6 +370,71 @@ declare class TikTokLive extends EventEmitter {
370
370
  signServerUrl?: string;
371
371
  quality?: string;
372
372
  }): Promise<StreamInfo>;
373
+ /**
374
+ * Resolve a TikTok username to the streamer's full public profile —
375
+ * numeric user ID, secUid, nickname, bio, avatars, follower stats.
376
+ *
377
+ * Useful when you need the numeric TikTok ID for a username (the inverse
378
+ * of `resolve_user_ids`, which only goes userId → username).
379
+ *
380
+ * Requires Pro tier+. Cached server-side for 24h.
381
+ *
382
+ * @example
383
+ * ```ts
384
+ * const profile = await TikTokLive.getUserProfile({
385
+ * uniqueId: 'dalga.ahmedov',
386
+ * apiKey: 'YOUR_KEY',
387
+ * });
388
+ * console.log(profile.id); // "7355610677036581896" (numeric)
389
+ * console.log(profile.nickname); // display name
390
+ * console.log(profile.stats.followerCount); // 12345
391
+ * console.log(profile.avatarLarger); // CDN URL
392
+ * ```
393
+ */
394
+ static getUserProfile(options: {
395
+ uniqueId: string;
396
+ apiKey: string;
397
+ signServerUrl?: string;
398
+ /** Set `true` to bypass the 24h server cache (e.g. after the user updated their bio). */
399
+ nocache?: boolean;
400
+ }): Promise<{
401
+ id: string;
402
+ uniqueId: string;
403
+ secUid: string;
404
+ nickname: string;
405
+ signature: string;
406
+ verified: boolean;
407
+ avatarThumb: string;
408
+ avatarMedium: string;
409
+ avatarLarger: string;
410
+ stats: {
411
+ followerCount: number;
412
+ followingCount: number;
413
+ heartCount: number;
414
+ videoCount: number;
415
+ };
416
+ }>;
417
+ /**
418
+ * Instance shortcut — fetch the profile of the streamer this client is
419
+ * connected to (or any other user if `uniqueId` is passed).
420
+ */
421
+ getUserProfile(uniqueId?: string): Promise<{
422
+ id: string;
423
+ uniqueId: string;
424
+ secUid: string;
425
+ nickname: string;
426
+ signature: string;
427
+ verified: boolean;
428
+ avatarThumb: string;
429
+ avatarMedium: string;
430
+ avatarLarger: string;
431
+ stats: {
432
+ followerCount: number;
433
+ followingCount: number;
434
+ heartCount: number;
435
+ videoCount: number;
436
+ };
437
+ }>;
373
438
  on<K extends keyof TikTokLiveEvents>(event: K, listener: TikTokLiveEvents[K]): this;
374
439
  once<K extends keyof TikTokLiveEvents>(event: K, listener: TikTokLiveEvents[K]): this;
375
440
  off<K extends keyof TikTokLiveEvents>(event: K, listener: TikTokLiveEvents[K]): this;
package/dist/index.d.ts CHANGED
@@ -370,6 +370,71 @@ declare class TikTokLive extends EventEmitter {
370
370
  signServerUrl?: string;
371
371
  quality?: string;
372
372
  }): Promise<StreamInfo>;
373
+ /**
374
+ * Resolve a TikTok username to the streamer's full public profile —
375
+ * numeric user ID, secUid, nickname, bio, avatars, follower stats.
376
+ *
377
+ * Useful when you need the numeric TikTok ID for a username (the inverse
378
+ * of `resolve_user_ids`, which only goes userId → username).
379
+ *
380
+ * Requires Pro tier+. Cached server-side for 24h.
381
+ *
382
+ * @example
383
+ * ```ts
384
+ * const profile = await TikTokLive.getUserProfile({
385
+ * uniqueId: 'dalga.ahmedov',
386
+ * apiKey: 'YOUR_KEY',
387
+ * });
388
+ * console.log(profile.id); // "7355610677036581896" (numeric)
389
+ * console.log(profile.nickname); // display name
390
+ * console.log(profile.stats.followerCount); // 12345
391
+ * console.log(profile.avatarLarger); // CDN URL
392
+ * ```
393
+ */
394
+ static getUserProfile(options: {
395
+ uniqueId: string;
396
+ apiKey: string;
397
+ signServerUrl?: string;
398
+ /** Set `true` to bypass the 24h server cache (e.g. after the user updated their bio). */
399
+ nocache?: boolean;
400
+ }): Promise<{
401
+ id: string;
402
+ uniqueId: string;
403
+ secUid: string;
404
+ nickname: string;
405
+ signature: string;
406
+ verified: boolean;
407
+ avatarThumb: string;
408
+ avatarMedium: string;
409
+ avatarLarger: string;
410
+ stats: {
411
+ followerCount: number;
412
+ followingCount: number;
413
+ heartCount: number;
414
+ videoCount: number;
415
+ };
416
+ }>;
417
+ /**
418
+ * Instance shortcut — fetch the profile of the streamer this client is
419
+ * connected to (or any other user if `uniqueId` is passed).
420
+ */
421
+ getUserProfile(uniqueId?: string): Promise<{
422
+ id: string;
423
+ uniqueId: string;
424
+ secUid: string;
425
+ nickname: string;
426
+ signature: string;
427
+ verified: boolean;
428
+ avatarThumb: string;
429
+ avatarMedium: string;
430
+ avatarLarger: string;
431
+ stats: {
432
+ followerCount: number;
433
+ followingCount: number;
434
+ heartCount: number;
435
+ videoCount: number;
436
+ };
437
+ }>;
373
438
  on<K extends keyof TikTokLiveEvents>(event: K, listener: TikTokLiveEvents[K]): this;
374
439
  once<K extends keyof TikTokLiveEvents>(event: K, listener: TikTokLiveEvents[K]): this;
375
440
  off<K extends keyof TikTokLiveEvents>(event: K, listener: TikTokLiveEvents[K]): this;
package/dist/index.js CHANGED
@@ -2496,6 +2496,52 @@ var TikTokLive = class _TikTokLive extends import_events.EventEmitter {
2496
2496
  hlsPullUrl: d.hls_pull_url || void 0
2497
2497
  };
2498
2498
  }
2499
+ /**
2500
+ * Resolve a TikTok username to the streamer's full public profile —
2501
+ * numeric user ID, secUid, nickname, bio, avatars, follower stats.
2502
+ *
2503
+ * Useful when you need the numeric TikTok ID for a username (the inverse
2504
+ * of `resolve_user_ids`, which only goes userId → username).
2505
+ *
2506
+ * Requires Pro tier+. Cached server-side for 24h.
2507
+ *
2508
+ * @example
2509
+ * ```ts
2510
+ * const profile = await TikTokLive.getUserProfile({
2511
+ * uniqueId: 'dalga.ahmedov',
2512
+ * apiKey: 'YOUR_KEY',
2513
+ * });
2514
+ * console.log(profile.id); // "7355610677036581896" (numeric)
2515
+ * console.log(profile.nickname); // display name
2516
+ * console.log(profile.stats.followerCount); // 12345
2517
+ * console.log(profile.avatarLarger); // CDN URL
2518
+ * ```
2519
+ */
2520
+ static async getUserProfile(options) {
2521
+ const serverUrl = (options.signServerUrl || DEFAULT_SIGN_SERVER).replace(/\/$/, "");
2522
+ const uname = options.uniqueId.replace(/^@/, "");
2523
+ const qs = new URLSearchParams({ unique_id: uname });
2524
+ if (options.nocache) qs.set("nocache", "1");
2525
+ const resp = await fetch(`${serverUrl}/webcast/user_profile?${qs}`, {
2526
+ headers: { "x-api-key": options.apiKey }
2527
+ });
2528
+ const data = await resp.json();
2529
+ if (data.status_code !== 0 || !data.data?.profile) {
2530
+ throw new Error(data.error || `Failed to get user profile for @${uname}`);
2531
+ }
2532
+ return data.data.profile;
2533
+ }
2534
+ /**
2535
+ * Instance shortcut — fetch the profile of the streamer this client is
2536
+ * connected to (or any other user if `uniqueId` is passed).
2537
+ */
2538
+ async getUserProfile(uniqueId) {
2539
+ return _TikTokLive.getUserProfile({
2540
+ uniqueId: uniqueId || this.uniqueId,
2541
+ apiKey: this.apiKey,
2542
+ signServerUrl: this.signServerUrl
2543
+ });
2544
+ }
2499
2545
  on(event, listener) {
2500
2546
  return super.on(event, listener);
2501
2547
  }