vidnavigator 2.1.0 → 2.3.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.
@@ -37,6 +37,11 @@ export interface TikTokSearchRequest {
37
37
  max_likes?: number;
38
38
  min_views?: number;
39
39
  max_views?: number;
40
+ /**
41
+ * Two-letter country code (`'fr'`, `'de'`, `'jp'`, ...) whose TikTok results you get. Default `'gb'`.
42
+ * `'us'` is refused: TikTok asks US visitors to log in. The API lists the accepted codes.
43
+ */
44
+ country?: string;
40
45
  /**
41
46
  * Where to POST a notification when the task finishes. Overrides the account-level default
42
47
  * configured in Studio → API; pass an empty string to opt this task out of that default.
@@ -70,6 +75,7 @@ export interface TikTokSearchSubmissionJSON {
70
75
  task_id: string;
71
76
  task_status: 'processing';
72
77
  query: string;
78
+ country?: string;
73
79
  max_results?: number;
74
80
  parallel_search_slices?: number;
75
81
  filters?: Record<string, unknown>;
@@ -82,6 +88,8 @@ export declare class TikTokSearchSubmission {
82
88
  task_id: string;
83
89
  task_status: 'processing';
84
90
  query: string;
91
+ /** Country whose TikTok results the search returns. */
92
+ country?: string;
85
93
  max_results?: number;
86
94
  parallel_search_slices?: number;
87
95
  filters?: Record<string, unknown>;
@@ -207,12 +215,27 @@ export interface TikTokSearchFilters {
207
215
  }
208
216
  export interface TikTokSearchStats {
209
217
  pages_fetched?: number;
218
+ /**
219
+ * Distinct videos TikTok returned, including those your filters dropped. Billed at
220
+ * 1 `residential_request` per 30, minimum 1 per search.
221
+ */
222
+ videos_fetched?: number;
210
223
  results_count?: number;
211
224
  next_search_cursor?: number | null;
225
+ /** Slice count the search actually ran with. */
226
+ parallel_search_slices?: number;
212
227
  /** Sort order the search ran with (`relevance` when `sort_by` was omitted). */
213
228
  sort_by?: TikTokSearchSortBy;
214
229
  /** Date window the search ran with; `all` means no window. */
215
230
  published_within?: TikTokPublishedWithin;
231
+ /** Country whose TikTok results the search returned. */
232
+ country?: string;
233
+ /** Only when filters were set: videos checked against them. */
234
+ items_examined?: number;
235
+ /** Only when filters were set: videos they dropped. */
236
+ items_filtered_out?: number;
237
+ /** Only with `parallel_search_slices` > 1: videos several slices returned, counted once. */
238
+ items_deduplicated?: number;
216
239
  }
217
240
  export interface TikTokProfileTaskJSON {
218
241
  task_id: string;
@@ -259,6 +282,7 @@ export interface TikTokSearchTaskJSON {
259
282
  task_id: string;
260
283
  task_status: 'processing' | 'completed' | 'failed';
261
284
  query?: string;
285
+ country?: string;
262
286
  parallel_search_slices?: number;
263
287
  filters?: TikTokSearchFilters;
264
288
  stats?: TikTokSearchStats;
@@ -276,6 +300,8 @@ export declare class TikTokSearchTask {
276
300
  task_id: string;
277
301
  task_status: 'processing' | 'completed' | 'failed';
278
302
  query?: string;
303
+ /** Country whose TikTok results the search returned (`gb` by default). */
304
+ country?: string;
279
305
  parallel_search_slices?: number;
280
306
  filters?: TikTokSearchFilters;
281
307
  stats?: TikTokSearchStats;
@@ -296,3 +322,292 @@ export declare class TikTokSearchTask {
296
322
  constructor(data: TikTokSearchTaskJSON);
297
323
  static fromJSON(json: TikTokSearchTaskJSON): TikTokSearchTask;
298
324
  }
325
+ export interface TikTokLiveSearchRequest {
326
+ query: string;
327
+ /** Cap on rooms. `0` or omitted means as many as TikTok serves, about 50 per keyword. */
328
+ max_results?: number;
329
+ /** Two-letter country code whose LIVE rooms you get. Default `'us'`. The API lists the accepted codes. */
330
+ country?: string;
331
+ /**
332
+ * The API returns each room's playback URLs by default (FLV and HLS by quality, plus an
333
+ * audio-only stream). Pass `false` to leave them out.
334
+ */
335
+ include_stream_urls?: boolean;
336
+ /**
337
+ * Where to POST a notification when the task finishes. Overrides the account-level default
338
+ * configured in Studio → API; pass an empty string to opt this task out of that default.
339
+ * The event's `data.result` is a summary; read the rooms with `vn.tiktokLiveSearch.resume(task_id).result()`.
340
+ */
341
+ webhook_url?: string;
342
+ }
343
+ export interface TikTokLiveSearchSubmissionJSON {
344
+ task_id: string;
345
+ task_status: 'processing';
346
+ query: string;
347
+ country?: string;
348
+ max_results?: number;
349
+ include_stream_urls?: boolean;
350
+ expires_at?: string;
351
+ check_status_url?: string;
352
+ message?: string;
353
+ webhook_url?: string | null;
354
+ }
355
+ export declare class TikTokLiveSearchSubmission {
356
+ task_id: string;
357
+ task_status: 'processing';
358
+ query: string;
359
+ country?: string;
360
+ max_results?: number;
361
+ include_stream_urls?: boolean;
362
+ expires_at?: string;
363
+ check_status_url?: string;
364
+ message?: string;
365
+ /** The URL this task's result notification will be POSTed to, or `null`. */
366
+ webhook_url?: string | null;
367
+ constructor(data: TikTokLiveSearchSubmissionJSON);
368
+ static fromJSON(json: TikTokLiveSearchSubmissionJSON): TikTokLiveSearchSubmission;
369
+ }
370
+ export interface TikTokLiveAuthor {
371
+ id?: string | null;
372
+ /** Username, without @. */
373
+ unique_id?: string | null;
374
+ nickname?: string | null;
375
+ sec_uid?: string | null;
376
+ followers?: number | null;
377
+ avatar_url?: string | null;
378
+ }
379
+ export interface TikTokLiveStats {
380
+ /** Watching when the search ran. */
381
+ viewers?: number | null;
382
+ /** Since the LIVE started. */
383
+ total_viewers?: number | null;
384
+ likes?: number | null;
385
+ comments?: number | null;
386
+ shares?: number | null;
387
+ }
388
+ /** Quality keys of the playback URLs: those the LIVE offers, best first. */
389
+ export type TikTokLiveQuality = 'origin' | 'uhd' | 'hd' | 'sd' | 'ld' | (string & {});
390
+ export interface TikTokLiveStreamUrlsJSON {
391
+ default_quality?: TikTokLiveQuality | null;
392
+ flv?: Record<string, string>;
393
+ hls?: Record<string, string>;
394
+ audio_only?: string | null;
395
+ expires_at?: string | null;
396
+ }
397
+ /** Playback URLs of a LIVE room. They stop working when the LIVE ends. */
398
+ export interface TikTokLiveStreamUrls {
399
+ /** The quality TikTok plays by default (a key of `flv`). */
400
+ default_quality: TikTokLiveQuality | null;
401
+ /** HTTP-FLV URLs keyed by quality. */
402
+ flv: Record<string, string>;
403
+ /** HLS (`.m3u8`) URLs keyed by quality, when TikTok provides them. Can be empty. */
404
+ hls: Record<string, string>;
405
+ /** HTTP-FLV URL of the audio-only stream. */
406
+ audio_only: string | null;
407
+ /** Expiry of the URL signatures. */
408
+ expires_at: Date | null;
409
+ }
410
+ export interface TikTokLiveRoomJSON {
411
+ id?: string | null;
412
+ title?: string | null;
413
+ url?: string | null;
414
+ started_at?: string | null;
415
+ author?: TikTokLiveAuthor;
416
+ stats?: TikTokLiveStats;
417
+ hashtags?: string[];
418
+ category?: string | null;
419
+ game_tags?: string[];
420
+ cover_url?: string | null;
421
+ stream_urls?: TikTokLiveStreamUrlsJSON;
422
+ }
423
+ /** A TikTok LIVE room that was broadcasting when the search ran. */
424
+ export declare class TikTokLiveRoom {
425
+ id?: string | null;
426
+ title?: string | null;
427
+ /** `https://www.tiktok.com/@username/live` */
428
+ url?: string | null;
429
+ started_at?: Date | null;
430
+ author?: TikTokLiveAuthor;
431
+ stats?: TikTokLiveStats;
432
+ /** `#tags` written in the title, without `#`. */
433
+ hashtags: string[];
434
+ /** The LIVE's category on TikTok, e.g. `'Gaming'`. */
435
+ category?: string | null;
436
+ game_tags: string[];
437
+ cover_url?: string | null;
438
+ /** Absent when the search was submitted with `include_stream_urls: false`. */
439
+ stream_urls?: TikTokLiveStreamUrls;
440
+ constructor(data: TikTokLiveRoomJSON);
441
+ static fromJSON(json: TikTokLiveRoomJSON): TikTokLiveRoom;
442
+ }
443
+ /** Exactly one of `room_id`, `username` or `url`. */
444
+ export interface TikTokLiveRoomRequest {
445
+ /**
446
+ * A LIVE room ID, e.g. the `id` of a LIVE search room. Pass it as a string: room IDs have more
447
+ * digits than a JavaScript number holds.
448
+ */
449
+ room_id?: string;
450
+ /** The streamer, with or without `@`: their current LIVE, or their last one when they are offline. */
451
+ username?: string;
452
+ /** `https://www.tiktok.com/@username/live`, the profile URL, or a room's `share_url`. */
453
+ url?: string;
454
+ /**
455
+ * Also return the latest comments (up to 50, newest first), the pinned comment, the intro and the
456
+ * top viewers. Bills 2 `residential_request` instead of 1. Default `false`.
457
+ */
458
+ include_comments?: boolean;
459
+ /** At most this many comments, 1-50 (default 50). */
460
+ comments_limit?: number;
461
+ /** Playback URLs are returned by default; pass `false` to leave them out. */
462
+ include_stream_urls?: boolean;
463
+ /** Add the `usage` block to the result. */
464
+ include_usage?: boolean;
465
+ }
466
+ export interface TikTokLiveRoomAuthor extends TikTokLiveAuthor {
467
+ bio?: string | null;
468
+ /** Accounts the streamer follows. */
469
+ following?: number | null;
470
+ }
471
+ /** A single room's counters. Likes, comments and shares come with LIVE search only. */
472
+ export interface TikTokLiveRoomStats {
473
+ /** Watching now (0 once the LIVE has ended). */
474
+ viewers?: number | null;
475
+ /** Since the LIVE started. */
476
+ total_viewers?: number | null;
477
+ /** Followers the streamer gained during this LIVE. */
478
+ new_followers?: number | null;
479
+ }
480
+ export interface TikTokLiveRoomDetailJSON extends TikTokLiveRoomJSON {
481
+ author?: TikTokLiveRoomAuthor;
482
+ stats?: TikTokLiveRoomStats;
483
+ status?: 'live' | 'ended' | 'unknown';
484
+ ended_at?: string | null;
485
+ share_url?: string | null;
486
+ age_restricted?: boolean;
487
+ subscribers_only?: boolean;
488
+ chat_enabled?: boolean;
489
+ products?: number;
490
+ }
491
+ /** One LIVE room, as `getTikTokLiveRoom` returns it. */
492
+ export declare class TikTokLiveRoomDetail extends TikTokLiveRoom {
493
+ author?: TikTokLiveRoomAuthor;
494
+ stats?: TikTokLiveRoomStats;
495
+ /** `'live'` while broadcasting, `'ended'` once finished. */
496
+ status?: 'live' | 'ended' | 'unknown';
497
+ ended_at?: Date | null;
498
+ /** The room's share link; it can be passed back as `url`. */
499
+ share_url?: string | null;
500
+ age_restricted?: boolean;
501
+ /** Only the streamer's paying subscribers can watch. */
502
+ subscribers_only?: boolean;
503
+ chat_enabled?: boolean;
504
+ /** Products on sale in the LIVE. */
505
+ products?: number;
506
+ constructor(data: TikTokLiveRoomDetailJSON);
507
+ get isLive(): boolean;
508
+ static fromJSON(json: TikTokLiveRoomDetailJSON): TikTokLiveRoomDetail;
509
+ }
510
+ export interface TikTokLiveCommentJSON {
511
+ id?: string | null;
512
+ text?: string | null;
513
+ language?: string | null;
514
+ created_at?: string | null;
515
+ author?: TikTokLiveAuthor;
516
+ author_is_follower?: boolean;
517
+ author_is_moderator?: boolean;
518
+ author_is_subscriber?: boolean;
519
+ }
520
+ /** A comment posted in a LIVE's chat. */
521
+ export interface TikTokLiveComment {
522
+ id?: string | null;
523
+ text?: string | null;
524
+ /** ISO 639-1 code TikTok detected, or `null`. */
525
+ language?: string | null;
526
+ created_at?: Date | null;
527
+ author?: TikTokLiveAuthor;
528
+ author_is_follower?: boolean;
529
+ author_is_moderator?: boolean;
530
+ /** A paying subscriber of the streamer. */
531
+ author_is_subscriber?: boolean;
532
+ }
533
+ /** One of a LIVE's top viewers, ranked by the gifts they sent. */
534
+ export interface TikTokLiveTopViewer {
535
+ rank?: number | null;
536
+ score?: number | null;
537
+ user?: TikTokLiveAuthor;
538
+ }
539
+ export interface TikTokLiveRoomResultJSON {
540
+ room: TikTokLiveRoomDetailJSON;
541
+ comments?: TikTokLiveCommentJSON[];
542
+ pinned_comment?: TikTokLiveCommentJSON | null;
543
+ intro?: string | null;
544
+ top_viewers?: TikTokLiveTopViewer[];
545
+ }
546
+ export interface TikTokLiveRoomResult {
547
+ room: TikTokLiveRoomDetail;
548
+ /** Latest comments, newest first (TikTok keeps about the last 50). Only with `include_comments`. */
549
+ comments?: TikTokLiveComment[];
550
+ /** The comment the streamer pinned. Only with `include_comments`. */
551
+ pinned_comment?: TikTokLiveComment | null;
552
+ /** The LIVE's intro text. Only with `include_comments`. */
553
+ intro?: string | null;
554
+ /** Top viewers by gifts sent. Only with `include_comments`. */
555
+ top_viewers?: TikTokLiveTopViewer[];
556
+ /** Present when called with `include_usage: true`. */
557
+ usage?: UsageBlock;
558
+ }
559
+ export declare function tiktokLiveRoomResultFromJSON(json: TikTokLiveRoomResultJSON): TikTokLiveRoomResult;
560
+ export interface TikTokLiveSearchStats {
561
+ /** TikTok pages fetched (up to 50 rooms each). */
562
+ pages_fetched?: number;
563
+ /**
564
+ * Distinct rooms TikTok returned, including any past `max_results`. Billed at
565
+ * 1 `residential_request` per 30, minimum 1 per search.
566
+ */
567
+ rooms_fetched?: number;
568
+ results_count?: number;
569
+ /** Whether TikTok had more rooms when the search stopped. */
570
+ has_more?: boolean;
571
+ country?: string;
572
+ }
573
+ export interface TikTokLiveSearchTaskJSON {
574
+ task_id: string;
575
+ task_status: 'processing' | 'completed' | 'failed';
576
+ query?: string;
577
+ country?: string;
578
+ stats?: TikTokLiveSearchStats;
579
+ results?: TikTokLiveRoomJSON[];
580
+ pagination?: TikTokProfilePagination;
581
+ download_url?: string | null;
582
+ error_message?: string | null;
583
+ created_at?: string | null;
584
+ completed_at?: string | null;
585
+ expires_at?: string | null;
586
+ error?: AsyncJobError | null;
587
+ webhook?: AsyncJobWebhookStatus | null;
588
+ }
589
+ export declare class TikTokLiveSearchTask {
590
+ task_id: string;
591
+ task_status: 'processing' | 'completed' | 'failed';
592
+ query?: string;
593
+ /** Country whose LIVE rooms the search returned (`us` by default). */
594
+ country?: string;
595
+ stats?: TikTokLiveSearchStats;
596
+ /** Rooms in TikTok's ranking. */
597
+ results: TikTokLiveRoom[];
598
+ pagination?: TikTokProfilePagination;
599
+ download_url?: string | null;
600
+ /** @deprecated Use `error`, which carries a machine-readable code. */
601
+ error_message?: string | null;
602
+ created_at?: string | null;
603
+ completed_at?: string | null;
604
+ expires_at?: string | null;
605
+ /** Present when `task_status === 'failed'`: error code, message and HTTP status. */
606
+ error: AsyncJobError | null;
607
+ /** Webhook delivery state, or `null` when no webhook was configured. */
608
+ webhook?: AsyncJobWebhookStatus | null;
609
+ /** Per-call usage, populated only when polled with `include_usage=true` and `task_status=completed`. */
610
+ usage?: UsageBlock;
611
+ constructor(data: TikTokLiveSearchTaskJSON);
612
+ static fromJSON(json: TikTokLiveSearchTaskJSON): TikTokLiveSearchTask;
613
+ }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TikTokSearchTask = exports.TikTokProfileTask = exports.TikTokSearchResult = exports.TikTokVideo = exports.TikTokSearchSubmission = exports.TikTokProfileScrapeSubmission = void 0;
3
+ exports.TikTokLiveSearchTask = exports.TikTokLiveRoomDetail = exports.TikTokLiveRoom = exports.TikTokLiveSearchSubmission = exports.TikTokSearchTask = exports.TikTokProfileTask = exports.TikTokSearchResult = exports.TikTokVideo = exports.TikTokSearchSubmission = exports.TikTokProfileScrapeSubmission = void 0;
4
+ exports.tiktokLiveRoomResultFromJSON = tiktokLiveRoomResultFromJSON;
4
5
  function toInteger(value) {
5
6
  if (value === null || value === undefined)
6
7
  return value;
@@ -54,13 +55,25 @@ function normalizeStats(stats) {
54
55
  function normalizeSearchStats(stats) {
55
56
  if (!stats)
56
57
  return undefined;
57
- return {
58
+ const normalized = {
58
59
  pages_fetched: toOptionalInteger(stats.pages_fetched),
60
+ videos_fetched: toOptionalInteger(stats.videos_fetched),
59
61
  results_count: toOptionalInteger(stats.results_count),
60
62
  next_search_cursor: toInteger(stats.next_search_cursor),
63
+ parallel_search_slices: toOptionalInteger(stats.parallel_search_slices),
61
64
  sort_by: stats.sort_by,
62
65
  published_within: stats.published_within,
66
+ country: stats.country,
67
+ items_examined: toOptionalInteger(stats.items_examined),
68
+ items_filtered_out: toOptionalInteger(stats.items_filtered_out),
69
+ items_deduplicated: toOptionalInteger(stats.items_deduplicated),
63
70
  };
71
+ // Leave out what the API did not send (the items_* counters are conditional).
72
+ for (const key of Object.keys(normalized)) {
73
+ if (normalized[key] === undefined)
74
+ delete normalized[key];
75
+ }
76
+ return normalized;
64
77
  }
65
78
  function normalizePagination(pagination) {
66
79
  if (!pagination)
@@ -95,6 +108,7 @@ class TikTokSearchSubmission {
95
108
  this.task_id = data.task_id;
96
109
  this.task_status = data.task_status;
97
110
  this.query = data.query;
111
+ this.country = data.country;
98
112
  this.max_results = toOptionalInteger(data.max_results);
99
113
  this.parallel_search_slices = toOptionalInteger(data.parallel_search_slices);
100
114
  this.filters = data.filters;
@@ -190,6 +204,7 @@ class TikTokSearchTask {
190
204
  this.task_id = data.task_id;
191
205
  this.task_status = data.task_status;
192
206
  this.query = data.query;
207
+ this.country = data.country;
193
208
  this.parallel_search_slices = toOptionalInteger(data.parallel_search_slices);
194
209
  this.filters = normalizeSearchFilters(data.filters);
195
210
  this.stats = normalizeSearchStats(data.stats);
@@ -208,3 +223,143 @@ class TikTokSearchTask {
208
223
  }
209
224
  }
210
225
  exports.TikTokSearchTask = TikTokSearchTask;
226
+ class TikTokLiveSearchSubmission {
227
+ constructor(data) {
228
+ this.task_id = data.task_id;
229
+ this.task_status = data.task_status;
230
+ this.query = data.query;
231
+ this.country = data.country;
232
+ this.max_results = toOptionalInteger(data.max_results);
233
+ this.include_stream_urls = data.include_stream_urls;
234
+ this.expires_at = data.expires_at;
235
+ this.check_status_url = data.check_status_url;
236
+ this.message = data.message;
237
+ this.webhook_url = data.webhook_url;
238
+ }
239
+ static fromJSON(json) {
240
+ return new TikTokLiveSearchSubmission(json);
241
+ }
242
+ }
243
+ exports.TikTokLiveSearchSubmission = TikTokLiveSearchSubmission;
244
+ /** A TikTok LIVE room that was broadcasting when the search ran. */
245
+ class TikTokLiveRoom {
246
+ constructor(data) {
247
+ this.id = data.id;
248
+ this.title = data.title;
249
+ this.url = data.url;
250
+ this.started_at = toNullableDate(data.started_at);
251
+ this.author = data.author
252
+ ? { ...data.author, followers: toInteger(data.author.followers) }
253
+ : undefined;
254
+ this.stats = data.stats
255
+ ? {
256
+ viewers: toInteger(data.stats.viewers),
257
+ total_viewers: toInteger(data.stats.total_viewers),
258
+ likes: toInteger(data.stats.likes),
259
+ comments: toInteger(data.stats.comments),
260
+ shares: toInteger(data.stats.shares),
261
+ }
262
+ : undefined;
263
+ this.hashtags = data.hashtags ?? [];
264
+ this.category = data.category;
265
+ this.game_tags = data.game_tags ?? [];
266
+ this.cover_url = data.cover_url;
267
+ if (data.stream_urls) {
268
+ this.stream_urls = {
269
+ default_quality: data.stream_urls.default_quality ?? null,
270
+ flv: data.stream_urls.flv ?? {},
271
+ hls: data.stream_urls.hls ?? {},
272
+ audio_only: data.stream_urls.audio_only ?? null,
273
+ expires_at: toNullableDate(data.stream_urls.expires_at) ?? null,
274
+ };
275
+ }
276
+ }
277
+ static fromJSON(json) {
278
+ return new TikTokLiveRoom(json);
279
+ }
280
+ }
281
+ exports.TikTokLiveRoom = TikTokLiveRoom;
282
+ /** One LIVE room, as `getTikTokLiveRoom` returns it. */
283
+ class TikTokLiveRoomDetail extends TikTokLiveRoom {
284
+ constructor(data) {
285
+ super(data);
286
+ this.author = data.author
287
+ ? { ...data.author, followers: toInteger(data.author.followers), following: toInteger(data.author.following) }
288
+ : undefined;
289
+ this.stats = data.stats
290
+ ? {
291
+ viewers: toInteger(data.stats.viewers),
292
+ total_viewers: toInteger(data.stats.total_viewers),
293
+ new_followers: toInteger(data.stats.new_followers),
294
+ }
295
+ : undefined;
296
+ this.status = data.status;
297
+ this.ended_at = toNullableDate(data.ended_at);
298
+ this.share_url = data.share_url;
299
+ this.age_restricted = data.age_restricted;
300
+ this.subscribers_only = data.subscribers_only;
301
+ this.chat_enabled = data.chat_enabled;
302
+ this.products = toOptionalInteger(data.products);
303
+ }
304
+ get isLive() {
305
+ return this.status === 'live';
306
+ }
307
+ static fromJSON(json) {
308
+ return new TikTokLiveRoomDetail(json);
309
+ }
310
+ }
311
+ exports.TikTokLiveRoomDetail = TikTokLiveRoomDetail;
312
+ function liveCommentFromJSON(json) {
313
+ return {
314
+ ...json,
315
+ created_at: toNullableDate(json.created_at),
316
+ author: json.author ? { ...json.author, followers: toInteger(json.author.followers) } : undefined,
317
+ };
318
+ }
319
+ function tiktokLiveRoomResultFromJSON(json) {
320
+ const result = { room: TikTokLiveRoomDetail.fromJSON(json.room) };
321
+ if (json.comments !== undefined)
322
+ result.comments = (json.comments ?? []).map(liveCommentFromJSON);
323
+ if (json.pinned_comment !== undefined) {
324
+ result.pinned_comment = json.pinned_comment ? liveCommentFromJSON(json.pinned_comment) : null;
325
+ }
326
+ if (json.intro !== undefined)
327
+ result.intro = json.intro;
328
+ if (json.top_viewers !== undefined) {
329
+ result.top_viewers = (json.top_viewers ?? []).map((v) => ({
330
+ ...v,
331
+ rank: toInteger(v.rank),
332
+ score: toInteger(v.score),
333
+ }));
334
+ }
335
+ return result;
336
+ }
337
+ class TikTokLiveSearchTask {
338
+ constructor(data) {
339
+ this.task_id = data.task_id;
340
+ this.task_status = data.task_status;
341
+ this.query = data.query;
342
+ this.country = data.country;
343
+ this.stats = data.stats
344
+ ? {
345
+ ...data.stats,
346
+ pages_fetched: toOptionalInteger(data.stats.pages_fetched),
347
+ rooms_fetched: toOptionalInteger(data.stats.rooms_fetched),
348
+ results_count: toOptionalInteger(data.stats.results_count),
349
+ }
350
+ : undefined;
351
+ this.results = data.results?.map(TikTokLiveRoom.fromJSON) ?? [];
352
+ this.pagination = normalizePagination(data.pagination);
353
+ this.download_url = data.download_url;
354
+ this.error_message = data.error_message;
355
+ this.created_at = data.created_at;
356
+ this.completed_at = data.completed_at;
357
+ this.expires_at = data.expires_at;
358
+ this.error = data.error ?? null;
359
+ this.webhook = data.webhook;
360
+ }
361
+ static fromJSON(json) {
362
+ return new TikTokLiveSearchTask(json);
363
+ }
364
+ }
365
+ exports.TikTokLiveSearchTask = TikTokLiveSearchTask;
@@ -1,7 +1,7 @@
1
1
  import { AsyncJobError } from './models';
2
2
  /** Event types delivered to a `webhook_url` when an async job reaches a terminal state. */
3
- export type WebhookEventType = 'transcribe.completed' | 'transcribe.failed' | 'extract_video.completed' | 'extract_video.failed' | 'tweet_statement.completed' | 'tweet_statement.failed' | 'tiktok_profile.completed' | 'tiktok_profile.failed' | 'tiktok_search.completed' | 'tiktok_search.failed';
4
- /** `data.result` of a `tiktok_profile.*` / `tiktok_search.*` event: a summary, not the videos. */
3
+ export type WebhookEventType = 'transcribe.completed' | 'transcribe.failed' | 'extract_video.completed' | 'extract_video.failed' | 'tweet_statement.completed' | 'tweet_statement.failed' | 'tiktok_profile.completed' | 'tiktok_profile.failed' | 'tiktok_search.completed' | 'tiktok_search.failed' | 'tiktok_live_search.completed' | 'tiktok_live_search.failed';
4
+ /** `data.result` of a `tiktok_profile.*` / `tiktok_search.*` / `tiktok_live_search.*` event: a summary, not the items. */
5
5
  export interface TikTokWebhookResult {
6
6
  /** Same fields as the task's `stats` (e.g. `videos_matched`, or `results_count` / `sort_by` for searches). */
7
7
  stats?: Record<string, unknown>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vidnavigator",
3
- "version": "2.1.0",
3
+ "version": "2.3.0",
4
4
  "description": "Official JavaScript SDK for the VidNavigator Developer API",
5
5
  "author": "VidNavigator",
6
6
  "license": "Apache-2.0",