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.
- package/README.md +65 -8
- package/dist/index.d.ts +28 -3
- package/dist/index.js +62 -3
- package/dist/models/TikTok.d.ts +315 -0
- package/dist/models/TikTok.js +157 -2
- package/dist/webhooks.d.ts +2 -2
- package/package.json +1 -1
- package/src/index.ts +111 -3
- package/src/models/TikTok.ts +481 -1
- package/src/webhooks.ts +4 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# VidNavigator SDK for JavaScript
|
|
2
2
|
|
|
3
|
-
The official JavaScript/TypeScript SDK for the [VidNavigator Developer API](https://vidnavigator.com). Transcribe, analyze, search, and extract structured data from video and audio — YouTube, Instagram, TikTok, X/Twitter, Vimeo, Facebook, Dailymotion, Loom, and your own uploaded files.
|
|
3
|
+
The official JavaScript/TypeScript SDK for the [VidNavigator Developer API](https://vidnavigator.com). Transcribe, analyze, search, and extract structured data from video and audio — YouTube, Instagram, TikTok, X/Twitter, Vimeo, Facebook, Dailymotion, Loom, Snapchat, and your own uploaded files.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/vidnavigator)
|
|
6
6
|
[](https://github.com/vidnavigator/vidnavigator-js/blob/main/LICENSE)
|
|
@@ -9,9 +9,10 @@ The official JavaScript/TypeScript SDK for the [VidNavigator Developer API](http
|
|
|
9
9
|
|
|
10
10
|
## Why VidNavigator?
|
|
11
11
|
|
|
12
|
-
- **Multi-platform transcription** — YouTube, Instagram Reels & carousel posts, TikTok, X/Twitter, Vimeo, Facebook, Dailymotion, Loom, and more.
|
|
12
|
+
- **Multi-platform transcription** — YouTube, Instagram Reels & carousel posts, TikTok, X/Twitter, Vimeo, Facebook, Dailymotion, Loom, Snapchat, and more.
|
|
13
13
|
- **Any video length** — transcription, extraction, and tweet analysis run as background jobs, so there is no duration limit. Get the result with one `await`, or submit many jobs and collect them as they finish.
|
|
14
|
-
- **Async TikTok profile scraping and
|
|
14
|
+
- **Async TikTok profile scraping, keyword search and LIVE search** — collect public TikTok videos, or LIVE rooms with their stream URLs, in the background, then read results via cursor pagination or a signed `download_url`, optionally notified by webhook.
|
|
15
|
+
- **TikTok LIVE room** — check one room or streamer right away, with its latest comments, pinned comment and top viewers.
|
|
15
16
|
- **Instagram carousel support** — select a specific video by index, or transcribe every video in a carousel post with one call.
|
|
16
17
|
- **AI-powered analysis** — get summaries, people mentioned, places, key subjects, and direct answers to questions about any video or audio.
|
|
17
18
|
- **Structured data extraction** — define a JSON schema and receive typed, structured fields extracted from any transcript (powered by LLMs).
|
|
@@ -34,6 +35,7 @@ The official JavaScript/TypeScript SDK for the [VidNavigator Developer API](http
|
|
|
34
35
|
| Facebook | Yes | Yes | - |
|
|
35
36
|
| Dailymotion | Yes | Yes | - |
|
|
36
37
|
| Loom | Yes | Yes | - |
|
|
38
|
+
| Snapchat | Yes, when Snapchat has a transcript | Yes | Yes (highlights: `img_index`, `all_videos`) |
|
|
37
39
|
| Uploaded files | Yes | Yes | - |
|
|
38
40
|
|
|
39
41
|
> **Transcript** = fast caption/subtitle extraction. **Transcribe** = speech-to-text via AI models (works when captions are unavailable).
|
|
@@ -102,7 +104,7 @@ New in 2.0: `vn.transcribe`, `vn.extractVideo`, `vn.tweetStatement`, `vn.tiktokP
|
|
|
102
104
|
|
|
103
105
|
### 1. Get a transcript (any platform)
|
|
104
106
|
|
|
105
|
-
There is a single `getTranscript` method that auto-detects the platform (YouTube, Vimeo, X/Twitter, TikTok, Facebook, Dailymotion, Loom, and more) from the URL.
|
|
107
|
+
There is a single `getTranscript` method that auto-detects the platform (YouTube, Vimeo, X/Twitter, TikTok, Facebook, Dailymotion, Loom, Snapchat, and more) from the URL.
|
|
106
108
|
|
|
107
109
|
```ts
|
|
108
110
|
const { video_info, transcript } = await vn.getTranscript({
|
|
@@ -163,6 +165,7 @@ Each of these operations comes in two shapes:
|
|
|
163
165
|
| Tweet claim analysis | `await vn.tweetStatement(tweetId)` | `await vn.tweetStatement.submit(tweetId)` |
|
|
164
166
|
| TikTok profile scrape | `await vn.tiktokProfile(profileUrl)` | `await vn.tiktokProfile.submit(profileUrl)` |
|
|
165
167
|
| TikTok keyword search | `await vn.tiktokSearch(query)` | `await vn.tiktokSearch.submit(query)` |
|
|
168
|
+
| TikTok LIVE search | `await vn.tiktokLiveSearch(query)` | `await vn.tiktokLiveSearch.submit(query)` |
|
|
166
169
|
|
|
167
170
|
**Wait for the result.** The one-liner submits the job, checks on it until it finishes, and returns the result:
|
|
168
171
|
|
|
@@ -466,6 +469,52 @@ for (const result of task.results) {
|
|
|
466
469
|
- `sort_by` and `published_within` are applied by TikTok itself. If you leave out `sort_by`, results come back newest first. If you leave out `published_within` and set an `after_datetime` more than 24 hours ago, the smallest window that covers it is picked for you.
|
|
467
470
|
- `parallel_search_slices` (`2` to `4`) runs several search chains in parallel to collect more results than TikTok's single-chain limit (about 115 to 140 items). Billing grows with the number of slices, so keep it at `1` unless you need the extra results, and especially when `published_within` is set, since every slice searches the same window.
|
|
468
471
|
|
|
472
|
+
- `country` picks whose TikTok results you get (`'fr'`, `'de'`, `'jp'`, ..., default `'gb'`). `'us'` is refused: TikTok asks US visitors to log in.
|
|
473
|
+
- Billing: 1 `residential_request` per 30 videos TikTok returned (`task.stats.videos_fetched`, including the ones your filters dropped), minimum 1 per search.
|
|
474
|
+
|
|
475
|
+
### 6b. TikTok LIVE search (async)
|
|
476
|
+
|
|
477
|
+
`vn.tiktokLiveSearch()` finds TikTok LIVE rooms broadcasting right now for a keyword, with their stream URLs:
|
|
478
|
+
|
|
479
|
+
```ts
|
|
480
|
+
const task = await vn.tiktokLiveSearch({ query: 'gaming', country: 'us' });
|
|
481
|
+
|
|
482
|
+
for (const room of task.results) {
|
|
483
|
+
console.log(room.title, room.author?.unique_id, room.stats?.viewers, room.category, room.hashtags);
|
|
484
|
+
const urls = room.stream_urls;
|
|
485
|
+
if (urls) {
|
|
486
|
+
const q = urls.default_quality ?? 'hd';
|
|
487
|
+
console.log('FLV:', urls.flv[q], 'HLS:', urls.hls[q], 'audio only:', urls.audio_only);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
- Each room has the same `id`, `url`, `author` and `stats` fields as a keyword search result, plus `started_at` (a `Date`), `stats.viewers` / `stats.total_viewers`, `hashtags` (the `#tags` of the title), `category` (the LIVE's category on TikTok, e.g. `'Gaming'`) and `game_tags`.
|
|
493
|
+
- `stream_urls` holds `flv` and `hls` URLs keyed by quality (`origin`, `uhd`, `hd`, `sd`, `ld`), `default_quality`, an `audio_only` stream and `expires_at`. The URLs play while the LIVE is on. They are returned by default; pass `include_stream_urls: false` to leave them out. Not every LIVE offers HLS, so `hls` can be empty.
|
|
494
|
+
- `country` defaults to `'us'`. Results keep TikTok's ranking; a keyword with no LIVE room in that country at that moment completes with zero results.
|
|
495
|
+
- Billing: 1 `residential_request` per 30 rooms TikTok returned (`task.stats.rooms_fetched`), minimum 1 per search.
|
|
496
|
+
|
|
497
|
+
### 6c. TikTok LIVE room (sync)
|
|
498
|
+
|
|
499
|
+
`vn.getTikTokLiveRoom()` returns one LIVE room right away, no job: by `room_id`, `username` or `url` (exactly one). Use it to check whether someone is live, to follow a room found by LIVE search, or to read its latest comments:
|
|
500
|
+
|
|
501
|
+
```ts
|
|
502
|
+
const { room, comments } = await vn.getTikTokLiveRoom({ username: 'tiktok', include_comments: true });
|
|
503
|
+
|
|
504
|
+
console.log(room.status, room.title, room.stats?.viewers, room.stats?.new_followers);
|
|
505
|
+
if (room.isLive) {
|
|
506
|
+
for (const c of comments ?? []) console.log(c.created_at, c.author?.unique_id, c.text);
|
|
507
|
+
} else {
|
|
508
|
+
console.log('ended at', room.ended_at);
|
|
509
|
+
}
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
- `room_id`: a LIVE room id, as a string (room ids have more digits than a JavaScript number holds). `username`: the streamer, with or without `@`: their current LIVE, or their last one when they are offline. `url`: `https://www.tiktok.com/@username/live`, the profile URL, or a room's `share_url`.
|
|
513
|
+
- The room (`TikTokLiveRoomDetail`) has the LIVE search room fields plus `status` (`'live'` / `'ended'`, also `room.isLive`), `ended_at`, `stats.new_followers`, `author.bio`, `author.following`, `share_url`, `chat_enabled`, `subscribers_only`, `age_restricted` and `products` (items on sale). It has no likes, comment count or share count: LIVE search returns those.
|
|
514
|
+
- `include_comments: true` adds `comments` (newest first, up to `comments_limit`, max 50; TikTok keeps only about the last 50 of a LIVE), `pinned_comment`, `intro` and `top_viewers`. An ended room has no comments.
|
|
515
|
+
- A room or account that does not exist throws `NotFoundError` (`error_code` `'live_not_found'`). The call usually takes a few seconds; a shorter `axiosConfig.timeout` is raised to two minutes for it.
|
|
516
|
+
- Billing: 1 `residential_request` per room, 2 with `include_comments` (1 when the room has ended). Not billed when the room is not found.
|
|
517
|
+
|
|
469
518
|
### 7. Instagram carousel posts (multiple videos)
|
|
470
519
|
|
|
471
520
|
Instagram carousel posts can contain multiple videos. You can select a specific video by index, or transcribe them all at once:
|
|
@@ -749,7 +798,7 @@ All methods return a `Promise`. Responses are automatically parsed into typed mo
|
|
|
749
798
|
|
|
750
799
|
| Member | Description |
|
|
751
800
|
|--------|-------------|
|
|
752
|
-
| `vn.transcribe`, `vn.extractVideo`, `vn.tweetStatement`, `vn.tiktokProfile`, `vn.tiktokSearch` | Call directly to submit and wait for the result. Options: `include_usage`, `timeoutMs`, `intervalMs`, `fastStart`, `signal`, `onPoll` |
|
|
801
|
+
| `vn.transcribe`, `vn.extractVideo`, `vn.tweetStatement`, `vn.tiktokProfile`, `vn.tiktokSearch`, `vn.tiktokLiveSearch` | Call directly to submit and wait for the result. Options: `include_usage`, `timeoutMs`, `intervalMs`, `fastStart`, `signal`, `onPoll` |
|
|
753
802
|
| `.submit(input, { include_usage? })` | Start the job and return a `Job` immediately |
|
|
754
803
|
| `.resume(task_id, { include_usage? })` | Get a `Job` for a job you already started (no request is made) |
|
|
755
804
|
| `job.task_id`, `job.job_type`, `job.check_status_url`, `job.webhook_url` | Job details from the submit response |
|
|
@@ -758,7 +807,7 @@ All methods return a `Promise`. Responses are automatically parsed into typed mo
|
|
|
758
807
|
| `job.result(options?)` | Wait until finished and return the result. Throws on failure or timeout; every error carries `task_id` |
|
|
759
808
|
| `job.wait(options?)` | Wait until finished and return the final task, without throwing on failure |
|
|
760
809
|
|
|
761
|
-
Results: `transcribe` → same shape as `transcribeVideo()`; `extractVideo` → `{ data, video_info, usage? }`; `tweetStatement` → `TweetStatement`; `tiktokProfile` / `tiktokSearch` → the completed task with every page of `videos` / `results`.
|
|
810
|
+
Results: `transcribe` → same shape as `transcribeVideo()`; `extractVideo` → `{ data, video_info, usage? }`; `tweetStatement` → `TweetStatement`; `tiktokProfile` / `tiktokSearch` / `tiktokLiveSearch` → the completed task with every page of `videos` / `results`.
|
|
762
811
|
|
|
763
812
|
### Webhooks
|
|
764
813
|
|
|
@@ -768,7 +817,7 @@ Results: `transcribe` → same shape as `transcribeVideo()`; `extractVideo` →
|
|
|
768
817
|
| `verifyWebhookSignature(rawBody, signatureHeader, secret, options?)` | Same check, returning `true` / `false` |
|
|
769
818
|
| `WEBHOOK_HEADERS` | Header names: `signature`, `delivery`, `event`, `taskId` |
|
|
770
819
|
|
|
771
|
-
`options`: `toleranceSeconds` (default `300`, `0` turns the check off). Event types: `transcribe.*`, `extract_video.*`, `tweet_statement.*`, `tiktok_profile.*`, `tiktok_search.*`, each with `.completed` or `.failed`.
|
|
820
|
+
`options`: `toleranceSeconds` (default `300`, `0` turns the check off). Event types: `transcribe.*`, `extract_video.*`, `tweet_statement.*`, `tiktok_profile.*`, `tiktok_search.*`, `tiktok_live_search.*`, each with `.completed` or `.failed`.
|
|
772
821
|
|
|
773
822
|
### TikTok
|
|
774
823
|
|
|
@@ -776,10 +825,14 @@ Results: `transcribe` → same shape as `transcribeVideo()`; `extractVideo` →
|
|
|
776
825
|
|--------|-------------|
|
|
777
826
|
| `tiktokProfile(urlOrInput, options?)` | Scrape a public profile and return the completed task with every video. See [Background jobs](#background-jobs) |
|
|
778
827
|
| `tiktokSearch(queryOrInput, options?)` | Keyword search returning the completed task with every result |
|
|
828
|
+
| `tiktokLiveSearch(queryOrInput, options?)` | LIVE search returning the completed task with every room and its stream URLs |
|
|
779
829
|
| `submitTikTokProfileScrape(payload)` | Lower-level: start a public TikTok profile scrape. Returns a `task_id` immediately. Options: `max_posts`, `after_datetime`, `before_datetime`, `min_likes`, `max_likes`, `webhook_url` |
|
|
780
830
|
| `getTikTokProfileScrape(task_id, query?)` | Poll task status and retrieve a page of videos. Options: `cursor`, `limit`, `include_usage` |
|
|
781
|
-
| `submitTikTokSearch(payload)` | Start an async TikTok keyword search. Returns a `task_id` immediately. Options: `max_results`, `parallel_search_slices`, `sort_by`, `published_within`, `after_datetime`, `before_datetime`, `min_likes`, `max_likes`, `min_views`, `max_views`, `webhook_url` |
|
|
831
|
+
| `submitTikTokSearch(payload)` | Start an async TikTok keyword search. Returns a `task_id` immediately. Options: `max_results`, `parallel_search_slices`, `sort_by`, `published_within`, `after_datetime`, `before_datetime`, `min_likes`, `max_likes`, `min_views`, `max_views`, `country`, `webhook_url` |
|
|
782
832
|
| `getTikTokSearch(task_id, query?)` | Poll search status and retrieve a page of results. Options: `cursor`, `limit`, `include_usage` |
|
|
833
|
+
| `submitTikTokLiveSearch(payload)` | Start an async TikTok LIVE search. Returns a `task_id` immediately. Options: `max_results`, `country`, `include_stream_urls`, `webhook_url` |
|
|
834
|
+
| `getTikTokLiveSearch(task_id, query?)` | Poll LIVE search status and retrieve a page of rooms. Options: `cursor`, `limit`, `include_usage` |
|
|
835
|
+
| `getTikTokLiveRoom(payload)` | One LIVE room right away, by `room_id`, `username` or `url`. Options: `include_comments`, `comments_limit`, `include_stream_urls`, `include_usage` |
|
|
783
836
|
|
|
784
837
|
Completed profile tasks include `videos`; completed search tasks include `results`. Both include `pagination`, optional `stats`, and an optional short-lived `download_url` for retrieving the whole result as JSON. Failed tasks include `error` (`{ error, message, http_status }`); the older `error_message` string still works but is deprecated. Datetime filters use `after_datetime` and `before_datetime`, each accepting either `YYYY-MM-DD` or full ISO datetime strings with timezone; TikTok `published_at` values are parsed into JavaScript `Date` objects, and numeric counters such as `views` and `likes` are normalized to integers.
|
|
785
838
|
|
|
@@ -925,6 +978,10 @@ All API responses are parsed into typed classes with static `fromJSON()` constru
|
|
|
925
978
|
| `TikTokSearchSubmission` | Async TikTok keyword search submission: `task_id`, query, slice count, expiry, `webhook_url` |
|
|
926
979
|
| `TikTokSearchTask` | TikTok keyword search task with status, results, pagination, `download_url`, `error`, `webhook`; `stats` shows the `sort_by` / `published_within` the search ran with |
|
|
927
980
|
| `TikTokSearchResult` | Normalized TikTok keyword result, including `published_at` as a `Date` and integer counters |
|
|
981
|
+
| `TikTokLiveSearchSubmission` | Async TikTok LIVE search submission: `task_id`, query, country, `include_stream_urls`, expiry, `webhook_url` |
|
|
982
|
+
| `TikTokLiveSearchTask` | TikTok LIVE search task with status, rooms, pagination, `download_url`, `error`, `webhook`; `stats.rooms_fetched` is what is billed |
|
|
983
|
+
| `TikTokLiveRoom` | A LIVE room: author, `stats.viewers`, `hashtags`, `category`, `game_tags`, `started_at` as a `Date`, and `stream_urls` (FLV / HLS by quality, audio only) |
|
|
984
|
+
| `TikTokLiveRoomDetail` | A `TikTokLiveRoom` from `getTikTokLiveRoom`: `status` / `isLive`, `ended_at`, `stats.new_followers`, `author.bio`, `share_url`, `chat_enabled`, `subscribers_only`, `products` |
|
|
928
985
|
| `TweetStatement` | Structured X/Twitter claim analysis, topics, entities, tone, intent, and source text |
|
|
929
986
|
|
|
930
987
|
## Links
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AxiosRequestConfig } from 'axios';
|
|
2
|
-
import { VideoInfo, TranscriptOutput, FileInfo, AnalysisResult, VideoSearchResult, FileSearchResult, UsageData, Namespace, NamespaceRef, ExtractionSchema, UsageBlock, CarouselInfo, CarouselVideoResult, TikTokProfileScrapeRequest, TikTokProfileScrapeSubmission, TikTokProfileTask, TikTokSearchRequest, TikTokSearchSubmission, TikTokSearchTask, TweetStatement, AsyncJob } from './models';
|
|
2
|
+
import { VideoInfo, TranscriptOutput, FileInfo, AnalysisResult, VideoSearchResult, FileSearchResult, UsageData, Namespace, NamespaceRef, ExtractionSchema, UsageBlock, CarouselInfo, CarouselVideoResult, TikTokProfileScrapeRequest, TikTokProfileScrapeSubmission, TikTokProfileTask, TikTokSearchRequest, TikTokSearchSubmission, TikTokSearchTask, TikTokLiveSearchRequest, TikTokLiveSearchSubmission, TikTokLiveSearchTask, TikTokLiveRoomRequest, TikTokLiveRoomResult, TweetStatement, AsyncJob } from './models';
|
|
3
3
|
import { Job, JobOperation, PollOptions, RunOptions, SubmitOptions } from './jobs';
|
|
4
4
|
export * from './models';
|
|
5
5
|
export * from './errors';
|
|
@@ -7,7 +7,7 @@ export * from './webhooks';
|
|
|
7
7
|
export { Job } from './jobs';
|
|
8
8
|
export type { TaskStatus, PollableTask, PollOptions, JobOperation, SubmitOptions, RunOptions, JobInfo } from './jobs';
|
|
9
9
|
/** SDK version (keep in sync with package.json) */
|
|
10
|
-
export declare const SDK_VERSION = "2.
|
|
10
|
+
export declare const SDK_VERSION = "2.3.0";
|
|
11
11
|
export interface SDKConfig {
|
|
12
12
|
apiKey: string;
|
|
13
13
|
baseURL?: string;
|
|
@@ -103,6 +103,8 @@ export type TweetStatementJob = Job<TweetStatementAsyncJob, TweetStatement>;
|
|
|
103
103
|
export type TikTokProfileJob = Job<TikTokProfileTask, TikTokProfileTask>;
|
|
104
104
|
/** `result()` resolves to the completed task with **all** pages of `results` collected. */
|
|
105
105
|
export type TikTokSearchJob = Job<TikTokSearchTask, TikTokSearchTask>;
|
|
106
|
+
/** `result()` resolves to the completed task with **all** pages of rooms collected. */
|
|
107
|
+
export type TikTokLiveSearchJob = Job<TikTokLiveSearchTask, TikTokLiveSearchTask>;
|
|
106
108
|
export type UploadFileSuccessResult = {
|
|
107
109
|
status: 'success';
|
|
108
110
|
file_id: string;
|
|
@@ -247,6 +249,12 @@ export declare class VidNavigatorClient {
|
|
|
247
249
|
* every page of `results` collected. Same shapes as {@link VidNavigatorClient.transcribe}.
|
|
248
250
|
*/
|
|
249
251
|
readonly tiktokSearch: JobOperation<string | TikTokSearchRequest, TikTokSearchTask, TikTokSearchTask>;
|
|
252
|
+
/**
|
|
253
|
+
* TikTok LIVE search, built on `POST /tiktok/live/search`: rooms broadcasting now for a keyword,
|
|
254
|
+
* with their FLV / HLS / audio-only stream URLs. The result is the completed task with every
|
|
255
|
+
* page of `results` collected. Same shapes as {@link VidNavigatorClient.transcribe}.
|
|
256
|
+
*/
|
|
257
|
+
readonly tiktokLiveSearch: JobOperation<string | TikTokLiveSearchRequest, TikTokLiveSearchTask, TikTokLiveSearchTask>;
|
|
250
258
|
constructor(config: SDKConfig);
|
|
251
259
|
private defineOperation;
|
|
252
260
|
private submitAsyncJob;
|
|
@@ -255,7 +263,7 @@ export declare class VidNavigatorClient {
|
|
|
255
263
|
private request;
|
|
256
264
|
/**
|
|
257
265
|
* Get a transcript for any supported video. The endpoint auto-detects the
|
|
258
|
-
* platform (YouTube, Vimeo, X/Twitter, TikTok, Facebook, Dailymotion, Loom, etc.)
|
|
266
|
+
* platform (YouTube, Vimeo, X/Twitter, TikTok, Facebook, Dailymotion, Loom, Snapchat, etc.)
|
|
259
267
|
* from `video_url`. For Instagram, use {@link VidNavigatorClient.transcribeVideo}.
|
|
260
268
|
*/
|
|
261
269
|
getTranscript(payload: TranscriptRequestPayload): Promise<TranscriptResult>;
|
|
@@ -282,6 +290,23 @@ export declare class VidNavigatorClient {
|
|
|
282
290
|
limit?: number;
|
|
283
291
|
include_usage?: boolean;
|
|
284
292
|
}): Promise<TikTokSearchTask>;
|
|
293
|
+
submitTikTokLiveSearch(payload: TikTokLiveSearchRequest): Promise<TikTokLiveSearchSubmission>;
|
|
294
|
+
getTikTokLiveSearch(task_id: string, query?: {
|
|
295
|
+
cursor?: string;
|
|
296
|
+
limit?: number;
|
|
297
|
+
include_usage?: boolean;
|
|
298
|
+
}): Promise<TikTokLiveSearchTask>;
|
|
299
|
+
/**
|
|
300
|
+
* One TikTok LIVE room, right away (`POST /tiktok/live/room`, no job): by `room_id`, `username`
|
|
301
|
+
* or `url`, exactly one. The room says whether it is live or ended (and when), its viewers and new
|
|
302
|
+
* followers, the streamer's bio, and more. With `include_comments: true` the result also has the
|
|
303
|
+
* latest comments (up to 50), the pinned comment, the intro and the top viewers.
|
|
304
|
+
*
|
|
305
|
+
* The room has no likes, comment count or share count: TikTok gives those to LIVE search only.
|
|
306
|
+
* A room or account that does not exist throws `NotFoundError` (`error_code` `live_not_found`)
|
|
307
|
+
* and is not billed. Billing: 1 `residential_request`, 2 with `include_comments`.
|
|
308
|
+
*/
|
|
309
|
+
getTikTokLiveRoom(payload: TikTokLiveRoomRequest): Promise<TikTokLiveRoomResult>;
|
|
285
310
|
getFiles(query?: {
|
|
286
311
|
limit?: number;
|
|
287
312
|
offset?: number;
|
package/dist/index.js
CHANGED
|
@@ -31,7 +31,12 @@ __exportStar(require("./webhooks"), exports);
|
|
|
31
31
|
var jobs_2 = require("./jobs");
|
|
32
32
|
Object.defineProperty(exports, "Job", { enumerable: true, get: function () { return jobs_2.Job; } });
|
|
33
33
|
/** SDK version (keep in sync with package.json) */
|
|
34
|
-
exports.SDK_VERSION = '2.
|
|
34
|
+
exports.SDK_VERSION = '2.3.0';
|
|
35
|
+
/**
|
|
36
|
+
* A LIVE room usually answers in 1-5 s, up to ~30 s when the API has to open a TikTok page, and two
|
|
37
|
+
* minutes at worst. A shorter configured axios timeout is raised to this for that call only.
|
|
38
|
+
*/
|
|
39
|
+
const LIVE_ROOM_TIMEOUT_MS = 120000;
|
|
35
40
|
//endregion
|
|
36
41
|
function parseTranscribeData(inner, usage) {
|
|
37
42
|
if ('videos' in inner && 'carousel_info' in inner) {
|
|
@@ -158,6 +163,15 @@ class VidNavigatorClient {
|
|
|
158
163
|
fetchTask: (task_id) => this.getTikTokSearch(task_id, { limit: 1 }),
|
|
159
164
|
toResult: (task, options) => collectAllPages((query) => this.getTikTokSearch(task.task_id, query), (page) => page.results, (page, all) => { page.results = all; }, options.include_usage),
|
|
160
165
|
});
|
|
166
|
+
this.tiktokLiveSearch = this.defineOperation({
|
|
167
|
+
jobType: 'tiktok_live_search',
|
|
168
|
+
submit: async (input) => {
|
|
169
|
+
const sub = await this.submitTikTokLiveSearch(typeof input === 'string' ? { query: input } : input);
|
|
170
|
+
return { ...sub, job_type: 'tiktok_live_search' };
|
|
171
|
+
},
|
|
172
|
+
fetchTask: (task_id) => this.getTikTokLiveSearch(task_id, { limit: 1 }),
|
|
173
|
+
toResult: (task, options) => collectAllPages((query) => this.getTikTokLiveSearch(task.task_id, query), (page) => page.results, (page, all) => { page.results = all; }, options.include_usage),
|
|
174
|
+
});
|
|
161
175
|
}
|
|
162
176
|
defineOperation(spec) {
|
|
163
177
|
const makeJob = (info, options = {}) => new jobs_1.Job(info, () => spec.fetchTask(info.task_id, options), (task) => spec.toResult(task, options));
|
|
@@ -196,7 +210,11 @@ class VidNavigatorClient {
|
|
|
196
210
|
job.usage = models_1.UsageBlock.fromJSON(response.usage);
|
|
197
211
|
return job;
|
|
198
212
|
}
|
|
199
|
-
async request(method, url, data, params, extraHeaders) {
|
|
213
|
+
async request(method, url, data, params, extraHeaders, minTimeoutMs) {
|
|
214
|
+
// A call known to run long raises a configured timeout, never lowers it
|
|
215
|
+
// (0 / unset means no timeout at all).
|
|
216
|
+
const configured = this.client.defaults.timeout;
|
|
217
|
+
const timeout = minTimeoutMs && configured ? Math.max(configured, minTimeoutMs) : undefined;
|
|
200
218
|
try {
|
|
201
219
|
const response = await this.client.request({
|
|
202
220
|
method,
|
|
@@ -204,6 +222,7 @@ class VidNavigatorClient {
|
|
|
204
222
|
data,
|
|
205
223
|
params,
|
|
206
224
|
headers: extraHeaders,
|
|
225
|
+
...(timeout !== undefined ? { timeout } : {}),
|
|
207
226
|
});
|
|
208
227
|
return response.data;
|
|
209
228
|
}
|
|
@@ -217,7 +236,7 @@ class VidNavigatorClient {
|
|
|
217
236
|
//region --- Transcripts ---
|
|
218
237
|
/**
|
|
219
238
|
* Get a transcript for any supported video. The endpoint auto-detects the
|
|
220
|
-
* platform (YouTube, Vimeo, X/Twitter, TikTok, Facebook, Dailymotion, Loom, etc.)
|
|
239
|
+
* platform (YouTube, Vimeo, X/Twitter, TikTok, Facebook, Dailymotion, Loom, Snapchat, etc.)
|
|
221
240
|
* from `video_url`. For Instagram, use {@link VidNavigatorClient.transcribeVideo}.
|
|
222
241
|
*/
|
|
223
242
|
async getTranscript(payload) {
|
|
@@ -269,6 +288,46 @@ class VidNavigatorClient {
|
|
|
269
288
|
task.usage = models_1.UsageBlock.fromJSON(response.usage);
|
|
270
289
|
return task;
|
|
271
290
|
}
|
|
291
|
+
async submitTikTokLiveSearch(payload) {
|
|
292
|
+
const response = await this.request('POST', '/tiktok/live/search', payload);
|
|
293
|
+
return models_1.TikTokLiveSearchSubmission.fromJSON(response.data);
|
|
294
|
+
}
|
|
295
|
+
async getTikTokLiveSearch(task_id, query) {
|
|
296
|
+
const response = await this.request('GET', `/tiktok/live/search/${task_id}`, undefined, buildTikTokPollParams(query));
|
|
297
|
+
const task = models_1.TikTokLiveSearchTask.fromJSON(response.data);
|
|
298
|
+
if (response.usage)
|
|
299
|
+
task.usage = models_1.UsageBlock.fromJSON(response.usage);
|
|
300
|
+
return task;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* One TikTok LIVE room, right away (`POST /tiktok/live/room`, no job): by `room_id`, `username`
|
|
304
|
+
* or `url`, exactly one. The room says whether it is live or ended (and when), its viewers and new
|
|
305
|
+
* followers, the streamer's bio, and more. With `include_comments: true` the result also has the
|
|
306
|
+
* latest comments (up to 50), the pinned comment, the intro and the top viewers.
|
|
307
|
+
*
|
|
308
|
+
* The room has no likes, comment count or share count: TikTok gives those to LIVE search only.
|
|
309
|
+
* A room or account that does not exist throws `NotFoundError` (`error_code` `live_not_found`)
|
|
310
|
+
* and is not billed. Billing: 1 `residential_request`, 2 with `include_comments`.
|
|
311
|
+
*/
|
|
312
|
+
async getTikTokLiveRoom(payload) {
|
|
313
|
+
const targets = ['room_id', 'username', 'url'].filter((key) => payload?.[key]);
|
|
314
|
+
if (targets.length !== 1) {
|
|
315
|
+
throw new errors_1.VidNavigatorError('Pass exactly one of room_id, username or url');
|
|
316
|
+
}
|
|
317
|
+
let body = payload;
|
|
318
|
+
const roomId = payload.room_id;
|
|
319
|
+
if (typeof roomId === 'number') {
|
|
320
|
+
if (!Number.isSafeInteger(roomId)) {
|
|
321
|
+
throw new errors_1.VidNavigatorError('room_id has more digits than a JavaScript number holds: pass it as a string');
|
|
322
|
+
}
|
|
323
|
+
body = { ...payload, room_id: String(roomId) };
|
|
324
|
+
}
|
|
325
|
+
const response = await this.request('POST', '/tiktok/live/room', body, undefined, undefined, LIVE_ROOM_TIMEOUT_MS);
|
|
326
|
+
const result = (0, models_1.tiktokLiveRoomResultFromJSON)(response.data);
|
|
327
|
+
if (response.usage)
|
|
328
|
+
result.usage = models_1.UsageBlock.fromJSON(response.usage);
|
|
329
|
+
return result;
|
|
330
|
+
}
|
|
272
331
|
//endregion
|
|
273
332
|
//region --- Files ---
|
|
274
333
|
async getFiles(query) {
|