vidnavigator 2.3.1 → 2.5.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 CHANGED
@@ -11,6 +11,8 @@ The official JavaScript/TypeScript SDK for the [VidNavigator Developer API](http
11
11
 
12
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
+ - **Watch a video** — what it shows, scene by scene, with the text readable on screen, next to its transcript, in one result.
15
+ - **Scenes in analysis and extraction** — with `include_scenes`, an analysis or an extraction reads what the video shows as well as what it says, for online videos and for uploaded files.
14
16
  - **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
17
  - **TikTok LIVE room** — check one room or streamer right away, with its latest comments, pinned comment and top viewers.
16
18
  - **Instagram carousel support** — select a specific video by index, or transcribe every video in a carousel post with one call.
@@ -24,21 +26,21 @@ The official JavaScript/TypeScript SDK for the [VidNavigator Developer API](http
24
26
 
25
27
  ## Supported Platforms
26
28
 
27
- | Platform | Transcript | Transcribe (speech-to-text) | Carousel |
28
- |----------|:----------:|:---------------------------:|:--------:|
29
- | YouTube | Yes | - | - |
30
- | Instagram Reels | - | Yes | Yes |
31
- | Instagram Posts | - | Yes | Yes (`all_videos`) |
32
- | TikTok | Yes | Yes | - |
33
- | X / Twitter | Yes | Yes | - |
34
- | Vimeo | Yes | Yes | - |
35
- | Facebook | Yes | Yes | - |
36
- | Dailymotion | Yes | Yes | - |
37
- | Loom | Yes | Yes | - |
38
- | Snapchat | Yes, when Snapchat has a transcript | Yes | Yes (highlights: `img_index`, `all_videos`) |
39
- | Uploaded files | Yes | Yes | - |
40
-
41
- > **Transcript** = fast caption/subtitle extraction. **Transcribe** = speech-to-text via AI models (works when captions are unavailable).
29
+ | Platform | Transcript | Transcribe (speech-to-text) | Watch (scenes) | Carousel |
30
+ |----------|:----------:|:---------------------------:|:--------------:|:--------:|
31
+ | YouTube | Yes | - | Yes | - |
32
+ | Instagram Reels | - | Yes | Yes | Yes |
33
+ | Instagram Posts | - | Yes | Yes | Yes (`all_videos`) |
34
+ | TikTok | Yes | Yes | Yes | - |
35
+ | X / Twitter | Yes | Yes | Yes | - |
36
+ | Vimeo | Yes | Yes | Yes | - |
37
+ | Facebook | Yes | Yes | Yes | - |
38
+ | Dailymotion | Yes | Yes | Yes | - |
39
+ | Loom | Yes | Yes | Yes | - |
40
+ | Snapchat | Yes, when Snapchat has a transcript | Yes | Yes | Yes (highlights: `img_index`, `all_videos`) |
41
+ | Uploaded files | Yes | Yes | Yes (`include_scenes` at upload, or `analyzeFileScenes()`) | - |
42
+
43
+ > **Transcript** = fast caption/subtitle extraction. **Transcribe** = speech-to-text via AI models (works when captions are unavailable). **Watch** = what the video shows, scene by scene, next to its transcript, via `vn.watch()`. The same scenes can feed an analysis or an extraction with `include_scenes: true`.
42
44
 
43
45
  ## Installation
44
46
 
@@ -152,15 +154,76 @@ const tweet = await vn.getTranscript({
152
154
  });
153
155
  ```
154
156
 
157
+ ### 2b. Watch a video: scenes next to the transcript
158
+
159
+ `vn.watch()` reads what a video **shows**, next to what it says. The result holds the transcript and a list of scenes: for each one, when it starts and ends, a description of the picture, and the text readable on screen. It works with every platform `getTranscript` and `transcribe` support, and runs as a [background job](#3-background-jobs-one-call-or-many-at-once).
160
+
161
+ ```ts
162
+ const watched = await vn.watch('https://www.tiktok.com/@nasa/video/7300000000000000000');
163
+
164
+ for (const scene of watched.scenes) {
165
+ console.log(`[${scene.start.toFixed(0)}s - ${scene.end.toFixed(0)}s] ${scene.description}`);
166
+ if (scene.on_screen_text) console.log(` on screen: ${scene.on_screen_text}`);
167
+ }
168
+ // [4s - 12s] A presenter stands in front of a world map and points at Europe.
169
+ // on screen: BREAKING NEWS
170
+
171
+ if (Array.isArray(watched.transcript)) {
172
+ for (const seg of watched.transcript) console.log(`[${seg.start.toFixed(1)}s] ${seg.text}`);
173
+ }
174
+
175
+ console.log(watched.frames_analyzed); // number of frames that were analyzed
176
+ ```
177
+
178
+ The transcript comes from the platform's captions when it has them, and from speech-to-text otherwise. A video without speech is not an error: `transcript` is empty, `transcript_error` says why, and the scenes are returned. The same goes for a YouTube video without captions.
179
+
180
+ ```ts
181
+ const watched = await vn.watch(url);
182
+ if (watched.transcript_error) {
183
+ console.log(watched.transcript_error.error); // e.g. "transcript_not_available"
184
+ }
185
+ console.log(watched.scenes.length, 'scenes');
186
+ ```
187
+
188
+ Pass an object instead of a URL for more options:
189
+
190
+ | Option | Type | Description |
191
+ |---|---|---|
192
+ | `video_url` | `string` | URL of the video (`?img_index=N` selects one video of an Instagram carousel or a Snapchat highlight) |
193
+ | `detail` | `string` | How closely the picture is followed: `'low'`, `'auto'` (the default) or `'high'`. The number of frames depends on the video at every level: few on a fixed shot, many on a fast-cut clip. A higher level analyzes more frames when the picture changes often. |
194
+ | `include_transcript` | `boolean` | Default `true`. `false` returns the scenes only (the result has no `transcript`). |
195
+ | `transcript_text` | `boolean` | Return the transcript as a single string instead of segments |
196
+ | `webhook_url` | `string` | Optional; see [Webhooks](#4-webhooks) |
197
+
198
+ The waiting options (`timeoutMs`, `include_usage`, ...) go in the second argument, as for every background job. With `include_usage: true` the result has a `usage` block; the frames are its `frame_analysis` charge.
199
+
200
+ To start it without waiting, use the handle, as for any background job:
201
+
202
+ ```ts
203
+ const job = await vn.watch.submit({ video_url: url, detail: 'high' }, { include_usage: true });
204
+ console.log(job.task_id);
205
+
206
+ const watched = await job.result(); // waits if needed
207
+ console.log(watched.usage?.charge_for('frame_analysis')?.quantity); // frames charged
208
+
209
+ const later = vn.watch.resume(savedTaskId); // the same handle, later
210
+ ```
211
+
212
+ `vn.watchVideo({ video_url, detail, include_usage: true })` is the same call with `include_usage` in the payload, like `transcribeVideo()`.
213
+
214
+ Errors worth handling: `NotFoundError` with `error_code` `'frames_not_available'` (a live stream, or a clip of a few seconds, has no picture to read) and `BadRequestError` with `error_code` `'video_too_long'` (videos longer than 2 hours are not accepted, except on YouTube).
215
+
155
216
  ### 3. Background jobs: one call, or many at once
156
217
 
157
- Transcription, structured extraction, tweet analysis, and TikTok scraping run as background jobs on VidNavigator. The SDK always uses the async API endpoints, so **video length is never a problem**. You never deal with the request-response limits of long transcriptions.
218
+ Transcription, watch, structured extraction, tweet analysis, and TikTok scraping run as background jobs on VidNavigator. The SDK always uses the async API endpoints, so **video length is never a problem**. You never deal with the request-response limits of long transcriptions. Video analysis has both: `analyzeVideo()` is a direct call, and `vn.analyze` runs the same analysis as a background job, for long videos with `include_scenes`.
158
219
 
159
220
  Each of these operations comes in two shapes:
160
221
 
161
222
  | Operation | Wait for the result | Start it and come back later |
162
223
  |---|---|---|
163
224
  | Transcription | `await vn.transcribe(url)` | `await vn.transcribe.submit(url)` |
225
+ | Watch (scenes and transcript) | `await vn.watch(url)` | `await vn.watch.submit(url)` |
226
+ | Video analysis | `await vn.analyze(url)` | `await vn.analyze.submit(url)` |
164
227
  | Structured extraction | `await vn.extractVideo({ video_url, schema })` | `await vn.extractVideo.submit({ ... })` |
165
228
  | Tweet claim analysis | `await vn.tweetStatement(tweetId)` | `await vn.tweetStatement.submit(tweetId)` |
166
229
  | TikTok profile scrape | `await vn.tiktokProfile(profileUrl)` | `await vn.tiktokProfile.submit(profileUrl)` |
@@ -310,7 +373,7 @@ function pending(): string[] {
310
373
 
311
374
  ### 4. Webhooks
312
375
 
313
- You can also have VidNavigator call your server when a job finishes. Pass `webhook_url` to any of the operations above (transcription, extraction, tweet analysis, TikTok profile and search), or set an account-wide default in **Studio → API**. A per-job `webhook_url` overrides the default, and `webhook_url: ''` turns the default off for that one job. The URL must be a public `https` endpoint; private and loopback hosts are rejected with a `BadRequestError`.
376
+ You can also have VidNavigator call your server when a job finishes. Pass `webhook_url` to any of the operations above (transcription, watch, video analysis, extraction, tweet analysis, TikTok profile and search), or set an account-wide default in **Studio → API**. A per-job `webhook_url` overrides the default, and `webhook_url: ''` turns the default off for that one job. The URL must be a public `https` endpoint; private and loopback hosts are rejected with a `BadRequestError`.
314
377
 
315
378
  Webhooks are optional. Waiting with `result()` or the one-liners works exactly the same whether or not a webhook is set, and it remains the source of truth.
316
379
 
@@ -359,7 +422,7 @@ app.post('/hooks/vidnavigator', express.raw({ type: 'application/json' }), async
359
422
  });
360
423
  ```
361
424
 
362
- - `event.data.result` holds the raw result for transcription, extraction, and tweet events, unless it was over 256 KB (`result_truncated: true`). For TikTok events it is only a summary, `{ stats, download_url_available }`, since a scrape can hold thousands of videos. In every case, `resume(task_id).result()` gets the full parsed result.
425
+ - `event.data.result` holds the raw result for transcription, watch, video analysis, extraction, and tweet events, unless it was over 256 KB (`result_truncated: true`). For TikTok events it is only a summary, `{ stats, download_url_available }`, since a scrape can hold thousands of videos. In every case, `resume(task_id).result()` gets the full parsed result.
363
426
  - `verifyWebhookSignature(rawBody, signatureHeader, secret)` returns `true` or `false` instead of throwing.
364
427
  - Deliveries older than 5 minutes are rejected by default. Change this with `{ toleranceSeconds }`; `0` turns the check off.
365
428
  - Failed deliveries (5xx, 429, network errors) are retried 5 times over about 13 minutes. Other 4xx responses are not retried.
@@ -470,7 +533,7 @@ for (const result of task.results) {
470
533
  - `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.
471
534
 
472
535
  - `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.
536
+ - Billing: 1 `residential_request` per 30 results returned (`task.stats.results_count`), minimum 1 per search and 1 per 5 TikTok pages read (`task.stats.pages_fetched`).
474
537
 
475
538
  ### 6b. TikTok LIVE search (async)
476
539
 
@@ -492,7 +555,7 @@ for (const room of task.results) {
492
555
  - 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
556
  - `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
557
  - `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.
558
+ - Billing: 1 `residential_request` per 30 rooms returned (`task.stats.results_count`), minimum 1 per search.
496
559
 
497
560
  ### 6c. TikTok LIVE room (sync)
498
561
 
@@ -601,6 +664,61 @@ const { files, has_more } = await vn.getFiles({ status: 'completed', limit: 20,
601
664
  await vn.deleteFile(file_id);
602
665
  ```
603
666
 
667
+ ### 8b. Scenes of an uploaded file
668
+
669
+ Pass `include_scenes: true` at the upload to have the picture of a video file analyzed as well: what it shows, scene by scene, with the text readable on screen, as `vn.watch()` does for an online video. The scenes of a file are analyzed once and kept with it. `file_info.scenes_status` says where that stands (`'none'`, `'processing'`, `'completed'` or `'failed'`), and `getFile()` returns the scenes once it is `'completed'`:
670
+
671
+ ```ts
672
+ const { file_id } = await vn.uploadFile({ filePath: './recipe.mp4', include_scenes: true });
673
+
674
+ let file = await vn.getFile(file_id);
675
+ while (file.file_info.status === 'processing' || file.file_info.scenes_status === 'processing') {
676
+ await new Promise((r) => setTimeout(r, 5000));
677
+ file = await vn.getFile(file_id);
678
+ }
679
+
680
+ console.log(file.file_info.scenes_status, file.file_info.frames_analyzed); // 'completed', and the number of frames analyzed
681
+ for (const scene of file.scenes ?? []) {
682
+ console.log(`[${scene.start}s - ${scene.end}s] ${scene.description}`);
683
+ if (scene.on_screen_text) console.log(` on screen: ${scene.on_screen_text}`);
684
+ }
685
+ ```
686
+
687
+ For a file that is already uploaded, start the same analysis with `analyzeFileScenes()`, then follow `scenes_status` in the same way:
688
+
689
+ ```ts
690
+ const { scenes_status } = await vn.analyzeFileScenes(file_id);
691
+ // 'processing': started, or already running. 'completed': the scenes are already there.
692
+ ```
693
+
694
+ `analyzeFile()` and `extractFileData()` then read the scenes with `include_scenes: true`. The analysis is made from the transcript of the file and its scenes together, and the result also has `scenes` and `frames_analyzed`:
695
+
696
+ ```ts
697
+ const { transcript_analysis, scenes, frames_analyzed } = await vn.analyzeFile({
698
+ file_id,
699
+ query: 'What are the ingredients and their quantities?',
700
+ include_scenes: true,
701
+ });
702
+ ```
703
+
704
+ A file that has no scenes to read is refused with `ScenesNotAvailableError` (HTTP 409). Its `scenes_status` says why: `'none'` (never asked for), `'processing'` (call again once `getFile()` reports `'completed'`) or `'failed'` (see `scenes_error`):
705
+
706
+ ```ts
707
+ import { ScenesNotAvailableError } from 'vidnavigator';
708
+
709
+ try {
710
+ await vn.analyzeFile({ file_id, include_scenes: true });
711
+ } catch (err) {
712
+ if (err instanceof ScenesNotAvailableError && err.scenes_status === 'none') {
713
+ await vn.analyzeFileScenes(file_id); // then wait for scenes_status 'completed' and call again
714
+ } else {
715
+ throw err;
716
+ }
717
+ }
718
+ ```
719
+
720
+ An audio file has no picture. `analyzeFileScenes()` throws `BadRequestError` with `error_code` `'frames_not_available'` for it, and an audio file uploaded with `include_scenes` gets `scenes_status` `'failed'` with the same code in `file_info.scenes_error`. A file without speech is analyzed from its scenes alone, and the result has a `transcript_error`.
721
+
604
722
  ### Analyze an online video
605
723
 
606
724
  ```ts
@@ -615,6 +733,37 @@ console.log(transcript_analysis.query_answer?.answer); // direct ans
615
733
  console.log(transcript_analysis.query_answer?.relevant_segments); // supporting transcript excerpts
616
734
  ```
617
735
 
736
+ Pass `include_scenes: true` to make the analysis from what the video **shows** as well as what it says. The result then also has `scenes` and `frames_analyzed`, as [`vn.watch()`](#2b-watch-a-video-scenes-next-to-the-transcript) returns them:
737
+
738
+ ```ts
739
+ const { transcript_analysis, scenes, frames_analyzed } = await vn.analyzeVideo({
740
+ video_url: 'https://www.tiktok.com/@user/video/1234567890',
741
+ query: 'What are the ingredients and their quantities?',
742
+ include_scenes: true,
743
+ });
744
+
745
+ console.log(transcript_analysis.query_answer?.answer); // also read from the text written on screen
746
+ console.log(`${scenes?.length} scenes from ${frames_analyzed} frames`);
747
+ ```
748
+
749
+ - When the picture cannot be read, the analysis is made from the transcript alone: `scenes` is empty and `scenes_error` says why. A video without a transcript is analyzed from its scenes, and `transcript_error` says why the transcript is missing.
750
+ - With scenes, the segments an answer refers to (`best_segment_index`, `relevant_segments`) are counted among the transcript segments and the scenes together, in chronological order. Use `transcript_analysis.timestamp` to locate the moment.
751
+ - With `include_usage: true`, the frames are the `frame_analysis` charge of the `usage` block: 1 credit per 1,000 frames analyzed, with at least 334 frames per hour of video; for an uploaded file the frames are charged once, when its scenes are analyzed.
752
+
753
+ `analyzeVideo()` waits on a single HTTP request. With `include_scenes` on a video longer than about 10 minutes, use `vn.analyze()`: it runs the same analysis as a [background job](#3-background-jobs-one-call-or-many-at-once) and returns the same result.
754
+
755
+ ```ts
756
+ const result = await vn.analyze(
757
+ { video_url: 'https://www.youtube.com/watch?v=4czjS9h4Fpg', query: 'Where did the rover land?', include_scenes: true },
758
+ { include_usage: true }
759
+ );
760
+ console.log(result.transcript_analysis.query_answer?.answer, result.scenes?.length);
761
+
762
+ // Or start it and come back later, as for any background job
763
+ const job = await vn.analyze.submit({ video_url: url, include_scenes: true });
764
+ const later = await vn.analyze.resume(job.task_id).result();
765
+ ```
766
+
618
767
  ### 9. Extract structured data
619
768
 
620
769
  Define a schema and get back clean, structured data extracted from any video or file transcript. Powered by LLMs with per-call usage tracking (see [Per-call usage](#per-call-usage)).
@@ -670,11 +819,28 @@ const { data } = await vn.extractVideoData({
670
819
  });
671
820
  ```
672
821
 
822
+ Pass `include_scenes: true` to extract from what the video shows as well as what it says: a value shown or written on screen counts as much as one that is said. The result then has `frames_analyzed`:
823
+
824
+ ```ts
825
+ const { data, frames_analyzed } = await vn.extractVideoData({
826
+ video_url: 'https://www.tiktok.com/@user/video/1234567890',
827
+ schema: {
828
+ dish: { type: 'String', description: 'Name of the dish' },
829
+ ingredients: { type: 'Array', description: 'Every ingredient with its quantity', items: { type: 'String', description: 'An ingredient and its quantity' } },
830
+ },
831
+ include_scenes: true,
832
+ });
833
+
834
+ console.log(data, frames_analyzed); // quantities that are only written on screen are found too
835
+ ```
836
+
837
+ When the picture cannot be read, the fields are extracted from the transcript alone and the result has a `scenes_error`; a video without a transcript is extracted from its scenes, with a `transcript_error`. The same option works on an uploaded file, `vn.extractFileData({ file_id, schema, include_scenes: true })`, once the file has its scenes (see [Scenes of an uploaded file](#8b-scenes-of-an-uploaded-file)).
838
+
673
839
  **Supported schema types:** `String`, `Number`, `Boolean`, `Integer`, `Object`, `Array`, `Enum`
674
840
 
675
841
  **Schema rules:** every field needs `type` and `description`. `Array` fields also need `items` (the schema of one element). `Object` fields list their sub-fields in `properties` (up to 10), and `Enum` fields list the allowed values in `enum`. At most 10 top-level fields and 3 levels of nesting. An invalid schema is rejected with a `BadRequestError` before anything runs.
676
842
 
677
- > `extractVideoData()` runs as a background job, so videos of any length work. For many extractions at once, use `vn.extractVideo.submit()` (see [Background jobs](#3-background-jobs-one-call-or-many-at-once)). The result has `data` (the extracted fields), `video_info` (the video's metadata), and `usage` when requested.
843
+ > `extractVideoData()` runs as a background job, so videos of any length work. For many extractions at once, use `vn.extractVideo.submit()` (see [Background jobs](#3-background-jobs-one-call-or-many-at-once)). The result has `data` (the extracted fields), `video_info` (the video's metadata), `frames_analyzed` with `include_scenes`, and `usage` when requested.
678
844
 
679
845
  ### 10. Semantic search
680
846
 
@@ -758,7 +924,7 @@ console.log(`Channels indexed: ${usage.channelsIndexed.used} / ${usage.channelsI
758
924
 
759
925
  ### Per-call usage
760
926
 
761
- Pass `include_usage: true` to most endpoints (`getTranscript`, `transcribeVideo`, `analyzeVideo`, `analyzeFile`, `extractVideoData`, `extractFileData`, `searchYouTube`, `searchFiles`) to receive a `usage` block describing exactly what the request cost. For background jobs, pass it in the options: `vn.transcribe(url, { include_usage: true })`, `vn.transcribe.submit(url, { include_usage: true })`, or `vn.transcribe.resume(taskId, { include_usage: true })`. The result's `usage` is filled in once the job completes. A failed job has all its charges reverted, so it has no usage.
927
+ Pass `include_usage: true` to most endpoints (`getTranscript`, `transcribeVideo`, `watchVideo`, `analyzeVideo`, `analyzeFile`, `extractVideoData`, `extractFileData`, `searchYouTube`, `searchFiles`) to receive a `usage` block describing exactly what the request cost. For background jobs (`vn.transcribe`, `vn.watch`, `vn.analyze`, ...), pass it in the options: `vn.transcribe(url, { include_usage: true })`, `vn.transcribe.submit(url, { include_usage: true })`, or `vn.transcribe.resume(taskId, { include_usage: true })`. The result's `usage` is filled in once the job completes. A failed job has all its charges reverted, so it has no usage.
762
928
 
763
929
  The `usage` field is a `UsageBlock`:
764
930
 
@@ -784,7 +950,7 @@ if (usage) {
784
950
  }
785
951
  ```
786
952
 
787
- `service_type` is one of: `standard_request`, `residential_request`, `transcription_hour`, `analysis_request`, `search_request`, `scene_analysis_hour`. LLM token counts (for `/extract/*`, `/analyze/*`, and `/youtube/search`) are nested inside the `analysis_request` charge — read them via the `analysis_tokens` accessor rather than expecting flat `total_tokens`. When a charge is waived via a cache-hit sponsorship, the entry carries `waived: true` + `credits_saved`, and the block carries a top-level `waived.credits_saved`.
953
+ `service_type` is one of: `standard_request`, `residential_request`, `transcription_hour`, `frame_analysis`, `analysis_request`, `search_request`, `scene_analysis_hour`. LLM token counts (for `/extract/*`, `/analyze/*`, and `/youtube/search`) are nested inside the `analysis_request` charge — read them via the `analysis_tokens` accessor rather than expecting flat `total_tokens`. When a charge is waived via a cache-hit sponsorship, the entry carries `waived: true` + `credits_saved`, and the block carries a top-level `waived.credits_saved`.
788
954
 
789
955
  ---
790
956
 
@@ -803,11 +969,18 @@ All methods return a `Promise`. Responses are automatically parsed into typed mo
803
969
 
804
970
  **Common options:** `video_url`, `language`, `metadata_only`, `fallback_to_metadata`, `transcript_text`, `include_usage`
805
971
 
972
+ ### Watch
973
+
974
+ | Method | Description |
975
+ |--------|-------------|
976
+ | `watch(urlOrInput, options?)` | What a video shows, scene by scene, next to its transcript. Input: `video_url`, `detail` (`'low'`, `'auto'`, `'high'`), `include_transcript`, `transcript_text`, `webhook_url`. Returns a `WatchResult`. See [Background jobs](#background-jobs) |
977
+ | `watchVideo(payload, options?)` | Same as `watch()`, with `include_usage` in the payload |
978
+
806
979
  ### Background jobs
807
980
 
808
981
  | Member | Description |
809
982
  |--------|-------------|
810
- | `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` |
983
+ | `vn.transcribe`, `vn.watch`, `vn.analyze`, `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` |
811
984
  | `.submit(input, { include_usage? })` | Start the job and return a `Job` immediately |
812
985
  | `.resume(task_id, { include_usage? })` | Get a `Job` for a job you already started (no request is made) |
813
986
  | `job.task_id`, `job.job_type`, `job.check_status_url`, `job.webhook_url` | Job details from the submit response |
@@ -816,7 +989,7 @@ All methods return a `Promise`. Responses are automatically parsed into typed mo
816
989
  | `job.result(options?)` | Wait until finished and return the result. Throws on failure or timeout; every error carries `task_id` |
817
990
  | `job.wait(options?)` | Wait until finished and return the final task, without throwing on failure |
818
991
 
819
- 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`.
992
+ Results: `transcribe` → same shape as `transcribeVideo()`; `watch` → `WatchResult` (`video_info`, `transcript`, `scenes`, `frames_analyzed`, `usage?`); `analyze` → same shape as `analyzeVideo()`; `extractVideo` → `{ data, video_info, frames_analyzed?, usage? }`; `tweetStatement` → `TweetStatement`; `tiktokProfile` / `tiktokSearch` / `tiktokLiveSearch` → the completed task with every page of `videos` / `results`.
820
993
 
821
994
  ### Webhooks
822
995
 
@@ -826,7 +999,7 @@ Results: `transcribe` → same shape as `transcribeVideo()`; `extractVideo` →
826
999
  | `verifyWebhookSignature(rawBody, signatureHeader, secret, options?)` | Same check, returning `true` / `false` |
827
1000
  | `WEBHOOK_HEADERS` | Header names: `signature`, `delivery`, `event`, `taskId` |
828
1001
 
829
- `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`.
1002
+ `options`: `toleranceSeconds` (default `300`, `0` turns the check off). Event types: `transcribe.*`, `watch.*`, `analyze_video.*`, `extract_video.*`, `tweet_statement.*`, `tiktok_profile.*`, `tiktok_search.*`, `tiktok_live_search.*`, each with `.completed` or `.failed`.
830
1003
 
831
1004
  ### TikTok
832
1005
 
@@ -850,8 +1023,9 @@ Completed profile tasks include `videos`; completed search tasks include `result
850
1023
  | Method | Description |
851
1024
  |--------|-------------|
852
1025
  | `getFiles(query?)` | List uploaded files (paginated). Filter by `status` or `namespace_id` |
853
- | `getFile(file_id, query?)` | Get file info and transcript. Pass `transcript_text: true` for plain text |
854
- | `uploadFile(options)` | Upload audio/video. Options: `filePath`, `wait_for_completion`, `namespace_ids` |
1026
+ | `getFile(file_id, query?)` | Get file info and transcript, and the `scenes` of the file once `file_info.scenes_status` is `'completed'`. Pass `transcript_text: true` for plain text |
1027
+ | `uploadFile(options)` | Upload audio/video. Options: `filePath`, `wait_for_completion`, `namespace_ids`, `include_scenes` (also analyze the scenes of a video file) |
1028
+ | `analyzeFileScenes(file_id)` | Start the scene analysis of a file already uploaded. Returns `{ file_id, scenes_status, message }`, with `scenes_status` `'processing'` or `'completed'` |
855
1029
  | `deleteFile(file_id)` | Delete a file |
856
1030
  | `getFileUrl(file_id)` | Get a signed download URL |
857
1031
  | `retryFileProcessing(file_id)` | Retry a failed processing job |
@@ -873,8 +1047,9 @@ Completed profile tasks include `videos`; completed search tasks include `result
873
1047
 
874
1048
  | Method | Description |
875
1049
  |--------|-------------|
876
- | `analyzeVideo(payload)` | Analyze an online video with an optional natural language query |
877
- | `analyzeFile(payload)` | Analyze an uploaded file with an optional natural language query |
1050
+ | `analyzeVideo(payload)` | Analyze an online video with an optional natural language query. Options: `video_url`, `query`, `include_scenes`, `transcript_text`, `include_usage` |
1051
+ | `analyze(urlOrInput, options?)` | The same analysis as a background job, for long videos with `include_scenes`. Input: `video_url`, `query`, `include_scenes`, `transcript_text`, `webhook_url`. Returns the same result as `analyzeVideo()`. See [Background jobs](#background-jobs) |
1052
+ | `analyzeFile(payload)` | Analyze an uploaded file with an optional natural language query. Options: `file_id`, `query`, `include_scenes`, `transcript_text`, `include_usage` |
878
1053
  | `tweetStatement(tweetIdOrInput, options?)` | Structured claim analysis of an X/Twitter tweet, including attached media of any length. Input: `tweet_id`, `webhook_url`. Returns a `TweetStatement` |
879
1054
  | `getTweetStatement(payload, options?)` | Same as `tweetStatement()`, with the original payload shape |
880
1055
 
@@ -885,15 +1060,17 @@ Returns `transcript_analysis` containing:
885
1060
  - `key_subjects` — important topics (name, description, importance)
886
1061
  - `query_answer` — direct answer to your query (when provided) with `answer`, `best_segment_index`, and `relevant_segments`
887
1062
 
1063
+ With `include_scenes: true`, the result of `analyzeVideo`, `analyze` and `analyzeFile` also has `scenes` (a list of `VideoScene`) and `frames_analyzed`, plus `scenes_error` or `transcript_error` (`{ error, message }`) when the picture or the transcript could not be had. `analyzeFile` on a file that has no scenes throws `ScenesNotAvailableError`.
1064
+
888
1065
  ### Extraction
889
1066
 
890
1067
  | Method | Description |
891
1068
  |--------|-------------|
892
- | `extractVideo(input, options?)` | Structured data from an online video of any length. Input: `video_url`, `schema` or `schemaFilePath`, `what_to_extract`, `transcribe`, `webhook_url`. Returns `{ data, video_info, usage? }` |
1069
+ | `extractVideo(input, options?)` | Structured data from an online video of any length. Input: `video_url`, `schema` or `schemaFilePath`, `what_to_extract`, `transcribe`, `include_scenes`, `webhook_url`. Returns `{ data, video_info, frames_analyzed?, usage? }` |
893
1070
  | `extractVideoData(payload, options?)` | Same as `extractVideo()`, with the original payload shape (`include_usage` in the payload) |
894
- | `extractFileData(payload)` | Extract structured data from an uploaded file transcript |
1071
+ | `extractFileData(payload)` | Extract structured data from an uploaded file transcript, and from its scenes with `include_scenes`. Returns `{ data, file_info, frames_analyzed?, usage? }` |
895
1072
 
896
- **Options:** `schema` (required for JSON requests), `schemaFilePath` (JSON/YAML schema file via multipart form-data), `what_to_extract` (optional guidance), `include_usage` (attach a per-call `UsageBlock`; read LLM tokens via `usage.analysis_tokens`)
1073
+ **Options:** `schema` (required for JSON requests), `schemaFilePath` (JSON/YAML schema file via multipart form-data), `what_to_extract` (optional guidance), `include_scenes` (also extract from what the video or the file shows; the result then has `frames_analyzed`, plus `scenes_error` or `transcript_error` when one of the two could not be had), `include_usage` (attach a per-call `UsageBlock`; read LLM tokens via `usage.analysis_tokens`)
897
1074
 
898
1075
  **Schema field types:** `String`, `Number`, `Boolean`, `Integer`, `Object`, `Array`, `Enum`
899
1076
 
@@ -948,6 +1125,7 @@ try {
948
1125
  | `InsufficientCreditsError` | 402 | A job could not start: not enough credits (`limit_exceeded`). Extends `PaymentRequiredError` |
949
1126
  | `AccessDeniedError` | 403 | Insufficient permissions |
950
1127
  | `NotFoundError` | 404 | Resource does not exist, or a job's `task_id` is unknown or expired (`task_not_found`) |
1128
+ | `ScenesNotAvailableError` | 409 | `include_scenes` was asked on an uploaded file that has no scenes to read (`scenes_not_available`). Has `scenes_status` (`'none'`, `'processing'` or `'failed'`) and, when failed, `scenes_error` |
951
1129
  | `StorageQuotaExceededError` | 413 | Storage quota exceeded |
952
1130
  | `RateLimitExceededError` | 429 | Too many requests |
953
1131
  | `TooManyActiveJobsError` | 429 | A job could not start: too many of your jobs are already running (`too_many_active_jobs`). Extends `RateLimitExceededError` |
@@ -966,7 +1144,7 @@ All API responses are parsed into typed classes with static `fromJSON()` constru
966
1144
  | Class | Description |
967
1145
  |-------|-------------|
968
1146
  | `VideoInfo` | Video metadata: title, channel, duration, views, likes, published date, keywords, carousel info |
969
- | `FileInfo` | Uploaded file: name, size, type, duration, status, `namespace_ids`, `namespaces` |
1147
+ | `FileInfo` | Uploaded file: name, size, type, duration, status, `namespace_ids`, `namespaces`, and where its scene analysis stands: `scenes_status`, `frames_analyzed`, `scenes_error` |
970
1148
  | `TranscriptSegment` | Timed segment: `text`, `start`, `end` (seconds) |
971
1149
  | `AnalysisResult` | AI analysis: summary, people, places, key subjects, query answer |
972
1150
  | `Namespace` | Full namespace: id, name, created/updated timestamps |
@@ -980,7 +1158,9 @@ All API responses are parsed into typed classes with static `fromJSON()` constru
980
1158
  | `CarouselInfo` | Carousel summary: total items, video/image count, transcribed count, total duration |
981
1159
  | `CarouselVideoResult` | Per-video result in a carousel: index, status, video info, transcript |
982
1160
  | `Job` | Handle returned by `.submit()` / `.resume()`: `task_id`, `status()`, `refresh()`, `result()`, `wait()` |
983
- | `AsyncJob<T>` | Task snapshot of a transcription, extraction, or tweet job (from `job.refresh()` / `job.wait()`): `task_status`, `result`, `error`, `webhook`, `request`, timestamps |
1161
+ | `AsyncJob<T>` | Task snapshot of a transcription, watch, video analysis, extraction, or tweet job (from `job.refresh()` / `job.wait()`): `task_status`, `result`, `error`, `webhook`, `request`, timestamps |
1162
+ | `WatchResult` | A watched video, from `watch()`: `video_info`, `transcript` (left out with `include_transcript: false`), `transcript_error`, `scenes`, `frames_analyzed`, `usage` |
1163
+ | `VideoScene` | What a video or an uploaded file shows between `start` and `end` (seconds): `description`, `on_screen_text`. Returned by `watch()`, by `getFile()`, and by the analyses asked with `include_scenes` |
984
1164
  | `TikTokProfileScrapeSubmission` | Async scrape submission: `task_id`, status, profile URL, expiry, `webhook_url` |
985
1165
  | `TikTokProfileTask` | TikTok profile scrape task with status, profile metadata, videos, pagination, `download_url`, `error`, `webhook` |
986
1166
  | `TikTokVideo` | Public TikTok video metadata returned by profile scraping, including `published_at` as a `Date` and integer counters |
@@ -993,6 +1173,17 @@ All API responses are parsed into typed classes with static `fromJSON()` constru
993
1173
  | `TikTokLiveRoomDetail` | A `TikTokLiveRoom` from `getTikTokLiveRoom`: `status` / `isLive`, `ended_at`, `stats.new_followers`, `author.bio`, `share_url`, `chat_enabled`, `subscribers_only`, `products` |
994
1174
  | `TweetStatement` | Structured X/Twitter claim analysis, topics, entities, tone, intent, and source text |
995
1175
 
1176
+ ## What's new in 2.5.0
1177
+
1178
+ - **Scenes in analysis and extraction:** `include_scenes: true` on `analyzeVideo()`, `analyzeFile()`, `extractVideo()` / `extractVideoData()` and `extractFileData()` makes the analysis or the extraction from what the video shows as well as what it says. Analysis results gain `scenes` and `frames_analyzed`, extraction results gain `frames_analyzed`; `scenes_error` and `transcript_error` say when one of the two could not be had.
1179
+ - **Video analysis as a background job:** [`vn.analyze()`](#analyze-an-online-video) runs the analysis of `analyzeVideo()` as a background job, for long videos with `include_scenes`, with `vn.analyze.submit()`, `vn.analyze.resume(task_id)` and the `analyze_video.completed` / `analyze_video.failed` webhook events. `analyzeVideo()` itself still makes a direct call.
1180
+ - **Scenes of an uploaded file:** [`uploadFile({ include_scenes: true })`](#8b-scenes-of-an-uploaded-file) analyzes the scenes of a video file at the upload, and `analyzeFileScenes(file_id)` does it for a file already uploaded. `file_info` gains `scenes_status`, `frames_analyzed` and `scenes_error`, and `getFile()` returns the `scenes` once they are there.
1181
+ - **`ScenesNotAvailableError`** (HTTP 409): thrown by `analyzeFile()` and `extractFileData()` when `include_scenes` is asked on a file that has no scenes to read. Its `scenes_status` says where their analysis stands.
1182
+
1183
+ ## What's new in 2.4.0
1184
+
1185
+ - **Watch:** [`vn.watch()`](#2b-watch-a-video-scenes-next-to-the-transcript) reads what a video shows, next to what it says: a list of scenes (`start`, `end`, `description`, `on_screen_text`) and the transcript, in one result. `detail` sets how closely the picture is followed, `include_transcript: false` returns the scenes only. Runs as a background job like `vn.transcribe()`, with `vn.watch.submit()`, `vn.watch.resume(task_id)`, `watchVideo()` and the `watch.completed` / `watch.failed` webhook events.
1186
+
996
1187
  ## Links
997
1188
 
998
1189
  - [VidNavigator Website](https://vidnavigator.com)
package/dist/errors.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Custom exception classes for VidNavigator SDK.
3
3
  */
4
+ import { FileScenesStatus, ScenesError } from './models';
4
5
  /**
5
6
  * Base class for all VidNavigator SDK errors.
6
7
  * Contains additional information from the API response when available.
@@ -95,6 +96,18 @@ export declare class InsufficientCreditsError extends PaymentRequiredError {
95
96
  export declare class TooManyActiveJobsError extends RateLimitExceededError {
96
97
  constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any);
97
98
  }
99
+ /**
100
+ * Raised when `include_scenes` was asked on an uploaded file that has no scenes to read
101
+ * (HTTP 409, `scenes_not_available`). `scenes_status` says where their analysis stands: `none`
102
+ * (never asked for: start it with `analyzeFileScenes(file_id)`), `processing` (call again once
103
+ * `getFile()` reports `completed`) or `failed` (see `scenes_error`).
104
+ */
105
+ export declare class ScenesNotAvailableError extends VidNavigatorError {
106
+ readonly scenes_status?: Exclude<FileScenesStatus, 'completed'>;
107
+ /** Present when `scenes_status` is `failed`, e.g. `frames_not_available` for an audio file. */
108
+ readonly scenes_error?: ScenesError;
109
+ constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any, scenes_status?: Exclude<FileScenesStatus, 'completed'>, scenes_error?: ScenesError);
110
+ }
98
111
  /**
99
112
  * Raised when waiting for a job exceeds `timeoutMs`. Always carries `task_id`: the job keeps
100
113
  * running server-side and its result stays readable for 1 hour after it finishes, so resume it
package/dist/errors.js CHANGED
@@ -1,9 +1,6 @@
1
1
  "use strict";
2
- /**
3
- * Custom exception classes for VidNavigator SDK.
4
- */
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.WebhookSignatureError = exports.TaskTimeoutError = exports.TooManyActiveJobsError = exports.InsufficientCreditsError = exports.SystemOverloadError = exports.GeoRestrictedError = exports.StorageQuotaExceededError = exports.ServerError = exports.PaymentRequiredError = exports.RateLimitExceededError = exports.NotFoundError = exports.AccessDeniedError = exports.BadRequestError = exports.AuthenticationError = exports.VidNavigatorError = void 0;
3
+ exports.WebhookSignatureError = exports.TaskTimeoutError = exports.ScenesNotAvailableError = exports.TooManyActiveJobsError = exports.InsufficientCreditsError = exports.SystemOverloadError = exports.GeoRestrictedError = exports.StorageQuotaExceededError = exports.ServerError = exports.PaymentRequiredError = exports.RateLimitExceededError = exports.NotFoundError = exports.AccessDeniedError = exports.BadRequestError = exports.AuthenticationError = exports.VidNavigatorError = void 0;
7
4
  /**
8
5
  * Base class for all VidNavigator SDK errors.
9
6
  * Contains additional information from the API response when available.
@@ -157,6 +154,22 @@ class TooManyActiveJobsError extends RateLimitExceededError {
157
154
  }
158
155
  }
159
156
  exports.TooManyActiveJobsError = TooManyActiveJobsError;
157
+ /**
158
+ * Raised when `include_scenes` was asked on an uploaded file that has no scenes to read
159
+ * (HTTP 409, `scenes_not_available`). `scenes_status` says where their analysis stands: `none`
160
+ * (never asked for: start it with `analyzeFileScenes(file_id)`), `processing` (call again once
161
+ * `getFile()` reports `completed`) or `failed` (see `scenes_error`).
162
+ */
163
+ class ScenesNotAvailableError extends VidNavigatorError {
164
+ constructor(message, status_code, error_code, error_message, details, scenes_status, scenes_error) {
165
+ super(message, status_code, error_code, error_message, details);
166
+ this.name = 'ScenesNotAvailableError';
167
+ this.scenes_status = scenes_status;
168
+ this.scenes_error = scenes_error;
169
+ Object.setPrototypeOf(this, ScenesNotAvailableError.prototype);
170
+ }
171
+ }
172
+ exports.ScenesNotAvailableError = ScenesNotAvailableError;
160
173
  /**
161
174
  * Raised when waiting for a job exceeds `timeoutMs`. Always carries `task_id`: the job keeps
162
175
  * running server-side and its result stays readable for 1 hour after it finishes, so resume it
package/dist/http.js CHANGED
@@ -31,6 +31,11 @@ function buildApiError(status, data, fallbackMessage) {
31
31
  return new errors_1.AccessDeniedError(message, status, errorCode, errorMessage, details);
32
32
  case 404:
33
33
  return new errors_1.NotFoundError(message, status, errorCode, errorMessage, details);
34
+ case 409:
35
+ if (errorCode === 'scenes_not_available') {
36
+ return new errors_1.ScenesNotAvailableError(message, status, errorCode, errorMessage, details, data?.scenes_status, data?.scenes_error);
37
+ }
38
+ return new errors_1.VidNavigatorError(message, status, errorCode, errorMessage, details);
34
39
  case 413:
35
40
  return new errors_1.StorageQuotaExceededError(message, status, errorCode, errorMessage, details);
36
41
  case 429: