vidnavigator 2.4.0 → 2.6.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
@@ -12,6 +12,7 @@ The official JavaScript/TypeScript SDK for the [VidNavigator Developer API](http
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
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.
15
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.
16
17
  - **TikTok LIVE room** — check one room or streamer right away, with its latest comments, pinned comment and top viewers.
17
18
  - **Instagram carousel support** — select a specific video by index, or transcribe every video in a carousel post with one call.
@@ -37,9 +38,9 @@ The official JavaScript/TypeScript SDK for the [VidNavigator Developer API](http
37
38
  | Dailymotion | Yes | Yes | Yes | - |
38
39
  | Loom | Yes | Yes | Yes | - |
39
40
  | Snapchat | Yes, when Snapchat has a transcript | Yes | Yes | Yes (highlights: `img_index`, `all_videos`) |
40
- | Uploaded files | Yes | Yes | - | - |
41
+ | Uploaded files | Yes | Yes | Yes (`include_scenes` at upload, or `analyzeFileScenes()`) | - |
41
42
 
42
- > **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()`.
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`.
43
44
 
44
45
  ## Installation
45
46
 
@@ -214,7 +215,7 @@ Errors worth handling: `NotFoundError` with `error_code` `'frames_not_available'
214
215
 
215
216
  ### 3. Background jobs: one call, or many at once
216
217
 
217
- 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.
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`.
218
219
 
219
220
  Each of these operations comes in two shapes:
220
221
 
@@ -222,6 +223,7 @@ Each of these operations comes in two shapes:
222
223
  |---|---|---|
223
224
  | Transcription | `await vn.transcribe(url)` | `await vn.transcribe.submit(url)` |
224
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)` |
225
227
  | Structured extraction | `await vn.extractVideo({ video_url, schema })` | `await vn.extractVideo.submit({ ... })` |
226
228
  | Tweet claim analysis | `await vn.tweetStatement(tweetId)` | `await vn.tweetStatement.submit(tweetId)` |
227
229
  | TikTok profile scrape | `await vn.tiktokProfile(profileUrl)` | `await vn.tiktokProfile.submit(profileUrl)` |
@@ -256,8 +258,11 @@ results.forEach((r, i) => console.log(urls[i], r.status === 'fulfilled' ? r.valu
256
258
  const job = await vn.extractVideo.submit({
257
259
  video_url: 'https://www.facebook.com/watch/?v=1234567890',
258
260
  schema: {
259
- speakers: { type: 'Array', description: 'Names of everyone who speaks', items: { type: 'String', description: 'A speaker name' } },
260
- verdict: { type: 'String', description: 'The final conclusion of the video' },
261
+ type: 'object',
262
+ properties: {
263
+ speakers: { type: 'array', description: 'Names of everyone who speaks', items: { type: 'string' } },
264
+ verdict: { type: 'string', description: 'The final conclusion of the video' },
265
+ },
261
266
  },
262
267
  });
263
268
 
@@ -371,7 +376,7 @@ function pending(): string[] {
371
376
 
372
377
  ### 4. Webhooks
373
378
 
374
- You can also have VidNavigator call your server when a job finishes. Pass `webhook_url` to any of the operations above (transcription, watch, 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`.
379
+ 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`.
375
380
 
376
381
  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.
377
382
 
@@ -420,7 +425,7 @@ app.post('/hooks/vidnavigator', express.raw({ type: 'application/json' }), async
420
425
  });
421
426
  ```
422
427
 
423
- - `event.data.result` holds the raw result for transcription, watch, 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.
428
+ - `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.
424
429
  - `verifyWebhookSignature(rawBody, signatureHeader, secret)` returns `true` or `false` instead of throwing.
425
430
  - Deliveries older than 5 minutes are rejected by default. Change this with `{ toleranceSeconds }`; `0` turns the check off.
426
431
  - Failed deliveries (5xx, 429, network errors) are retried 5 times over about 13 minutes. Other 4xx responses are not retried.
@@ -490,12 +495,15 @@ for (const video of videos) {
490
495
  const { data } = await vn.extractVideoData({
491
496
  video_url: video.url,
492
497
  schema: {
493
- hook: { type: 'String', description: 'The opening hook or premise' },
494
- products: { type: 'Array', description: 'Products or brands mentioned', items: { type: 'String', description: 'A product or brand' } },
495
- sentiment: {
496
- type: 'Enum',
497
- description: 'Overall sentiment',
498
- enum: ['positive', 'negative', 'neutral', 'mixed'],
498
+ type: 'object',
499
+ properties: {
500
+ hook: { type: 'string', description: 'The opening hook or premise' },
501
+ products: { type: 'array', description: 'Products or brands mentioned', items: { type: 'string' } },
502
+ sentiment: {
503
+ type: 'string',
504
+ description: 'Overall sentiment',
505
+ enum: ['positive', 'negative', 'neutral', 'mixed'],
506
+ },
499
507
  },
500
508
  },
501
509
  what_to_extract: 'Extract creator messaging and product mentions.',
@@ -662,6 +670,61 @@ const { files, has_more } = await vn.getFiles({ status: 'completed', limit: 20,
662
670
  await vn.deleteFile(file_id);
663
671
  ```
664
672
 
673
+ ### 8b. Scenes of an uploaded file
674
+
675
+ 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'`:
676
+
677
+ ```ts
678
+ const { file_id } = await vn.uploadFile({ filePath: './recipe.mp4', include_scenes: true });
679
+
680
+ let file = await vn.getFile(file_id);
681
+ while (file.file_info.status === 'processing' || file.file_info.scenes_status === 'processing') {
682
+ await new Promise((r) => setTimeout(r, 5000));
683
+ file = await vn.getFile(file_id);
684
+ }
685
+
686
+ console.log(file.file_info.scenes_status, file.file_info.frames_analyzed); // 'completed', and the number of frames analyzed
687
+ for (const scene of file.scenes ?? []) {
688
+ console.log(`[${scene.start}s - ${scene.end}s] ${scene.description}`);
689
+ if (scene.on_screen_text) console.log(` on screen: ${scene.on_screen_text}`);
690
+ }
691
+ ```
692
+
693
+ For a file that is already uploaded, start the same analysis with `analyzeFileScenes()`, then follow `scenes_status` in the same way:
694
+
695
+ ```ts
696
+ const { scenes_status } = await vn.analyzeFileScenes(file_id);
697
+ // 'processing': started, or already running. 'completed': the scenes are already there.
698
+ ```
699
+
700
+ `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`:
701
+
702
+ ```ts
703
+ const { transcript_analysis, scenes, frames_analyzed } = await vn.analyzeFile({
704
+ file_id,
705
+ query: 'What are the ingredients and their quantities?',
706
+ include_scenes: true,
707
+ });
708
+ ```
709
+
710
+ 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`):
711
+
712
+ ```ts
713
+ import { ScenesNotAvailableError } from 'vidnavigator';
714
+
715
+ try {
716
+ await vn.analyzeFile({ file_id, include_scenes: true });
717
+ } catch (err) {
718
+ if (err instanceof ScenesNotAvailableError && err.scenes_status === 'none') {
719
+ await vn.analyzeFileScenes(file_id); // then wait for scenes_status 'completed' and call again
720
+ } else {
721
+ throw err;
722
+ }
723
+ }
724
+ ```
725
+
726
+ 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`.
727
+
665
728
  ### Analyze an online video
666
729
 
667
730
  ```ts
@@ -676,19 +739,52 @@ console.log(transcript_analysis.query_answer?.answer); // direct ans
676
739
  console.log(transcript_analysis.query_answer?.relevant_segments); // supporting transcript excerpts
677
740
  ```
678
741
 
742
+ 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:
743
+
744
+ ```ts
745
+ const { transcript_analysis, scenes, frames_analyzed } = await vn.analyzeVideo({
746
+ video_url: 'https://www.tiktok.com/@user/video/1234567890',
747
+ query: 'What are the ingredients and their quantities?',
748
+ include_scenes: true,
749
+ });
750
+
751
+ console.log(transcript_analysis.query_answer?.answer); // also read from the text written on screen
752
+ console.log(`${scenes?.length} scenes from ${frames_analyzed} frames`);
753
+ ```
754
+
755
+ - 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.
756
+ - 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.
757
+ - With `include_usage: true`, the frames are the `frame_analysis` charge of the `usage` block: 1 credit per 2,000 frames analyzed, with at least 667 frames per hour of video; for an uploaded file the frames are charged once, when its scenes are analyzed.
758
+
759
+ `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.
760
+
761
+ ```ts
762
+ const result = await vn.analyze(
763
+ { video_url: 'https://www.youtube.com/watch?v=4czjS9h4Fpg', query: 'Where did the rover land?', include_scenes: true },
764
+ { include_usage: true }
765
+ );
766
+ console.log(result.transcript_analysis.query_answer?.answer, result.scenes?.length);
767
+
768
+ // Or start it and come back later, as for any background job
769
+ const job = await vn.analyze.submit({ video_url: url, include_scenes: true });
770
+ const later = await vn.analyze.resume(job.task_id).result();
771
+ ```
772
+
679
773
  ### 9. Extract structured data
680
774
 
681
- 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)).
775
+ Define a schema, as a standard JSON Schema, and get back clean, structured data extracted from any video or file transcript. Or skip the schema and say what you want in plain words with `what_to_extract`. Per-call usage tracking included (see [Per-call usage](#per-call-usage)).
682
776
 
683
777
  ```ts
684
778
  const { data, usage } = await vn.extractVideoData({
685
779
  video_url: 'https://youtube.com/watch?v=dQw4w9WgXcQ',
686
780
  schema: {
687
- topic: { type: 'String', description: 'Main topic of the video' },
688
- language: { type: 'String', description: 'Primary spoken language (ISO 639-1)' },
689
- tone: { type: 'Enum', description: 'Overall tone',
690
- enum: ['positive', 'negative', 'neutral', 'mixed'] },
691
- key_quotes: { type: 'Array', description: 'Top 3 memorable quotes', items: { type: 'String', description: 'A quote' } },
781
+ type: 'object',
782
+ properties: {
783
+ topic: { type: 'string', description: 'Main topic of the video' },
784
+ language: { type: 'string', description: 'Primary spoken language (ISO 639-1)' },
785
+ tone: { type: 'string', description: 'Overall tone', enum: ['positive', 'negative', 'neutral', 'mixed'] },
786
+ key_quotes: { type: 'array', description: 'Top 3 memorable quotes', items: { type: 'string' } },
787
+ },
692
788
  },
693
789
  what_to_extract: 'Determine the topic, language, tone, and notable quotes.',
694
790
  include_usage: true,
@@ -713,10 +809,12 @@ Also works on uploaded files:
713
809
  const { data } = await vn.extractFileData({
714
810
  file_id: 'your-file-id',
715
811
  schema: {
716
- action_items: { type: 'Array', description: 'List of action items from the meeting', items: { type: 'String', description: 'An action item' } },
717
- next_meeting: { type: 'String', description: 'When is the next meeting scheduled?' },
718
- sentiment: { type: 'Enum', description: 'Overall meeting mood',
719
- enum: ['productive', 'tense', 'casual', 'urgent'] },
812
+ type: 'object',
813
+ properties: {
814
+ action_items: { type: 'array', description: 'List of action items from the meeting', items: { type: 'string' } },
815
+ next_meeting: { type: 'string', description: 'When is the next meeting scheduled?' },
816
+ sentiment: { type: 'string', description: 'Overall meeting mood', enum: ['productive', 'tense', 'casual', 'urgent'] },
817
+ },
720
818
  },
721
819
  });
722
820
  ```
@@ -731,11 +829,41 @@ const { data } = await vn.extractVideoData({
731
829
  });
732
830
  ```
733
831
 
734
- **Supported schema types:** `String`, `Number`, `Boolean`, `Integer`, `Object`, `Array`, `Enum`
832
+ 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`:
833
+
834
+ ```ts
835
+ const { data, frames_analyzed } = await vn.extractVideoData({
836
+ video_url: 'https://www.tiktok.com/@user/video/1234567890',
837
+ schema: {
838
+ type: 'object',
839
+ properties: {
840
+ dish: { type: 'string', description: 'Name of the dish' },
841
+ ingredients: { type: 'array', description: 'Every ingredient with its quantity', items: { type: 'string' } },
842
+ },
843
+ },
844
+ include_scenes: true,
845
+ });
846
+
847
+ console.log(data, frames_analyzed); // quantities that are only written on screen are found too
848
+ ```
849
+
850
+ 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)).
851
+
852
+ **Schema format:** a standard JSON Schema whose root is an object, `{ type: 'object', properties: { ... } }`. Property types: `string`, `number`, `integer`, `boolean`, `array` (with `items`, the schema of one element) and `object` (with its own `properties`); `enum` restricts a property to a list of values. Give each property a `description`: it tells what to put in it. At most 10 fields per level and 3 levels of nesting. A Zod schema converted with `zod-to-json-schema` works as it is. `required` and `additionalProperties` change nothing: a field the video does not give comes back as `null`. An invalid schema is rejected with a `BadRequestError` before anything runs.
853
+
854
+ **Without a schema:** pass `what_to_extract` alone. The schema is written for you and comes back as `schema` on the result; pass it as `schema` next time to get the same fields.
855
+
856
+ ```ts
857
+ const { data, schema } = await vn.extractVideoData({
858
+ video_url: 'https://youtube.com/watch?v=dQw4w9WgXcQ',
859
+ what_to_extract: 'The mood of the song and every topic it touches on',
860
+ });
735
861
 
736
- **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.
862
+ console.log(data); // { mood: "upbeat", topics: ["love", "commitment"] }
863
+ console.log(schema); // { type: "object", properties: { mood: {...}, topics: {...} }, ... }
864
+ ```
737
865
 
738
- > `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.
866
+ > `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`, `schema` when it was written from `what_to_extract`, and `usage` when requested.
739
867
 
740
868
  ### 10. Semantic search
741
869
 
@@ -819,7 +947,7 @@ console.log(`Channels indexed: ${usage.channelsIndexed.used} / ${usage.channelsI
819
947
 
820
948
  ### Per-call usage
821
949
 
822
- 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, 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.
950
+ 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.
823
951
 
824
952
  The `usage` field is a `UsageBlock`:
825
953
 
@@ -875,7 +1003,7 @@ All methods return a `Promise`. Responses are automatically parsed into typed mo
875
1003
 
876
1004
  | Member | Description |
877
1005
  |--------|-------------|
878
- | `vn.transcribe`, `vn.watch`, `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` |
1006
+ | `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` |
879
1007
  | `.submit(input, { include_usage? })` | Start the job and return a `Job` immediately |
880
1008
  | `.resume(task_id, { include_usage? })` | Get a `Job` for a job you already started (no request is made) |
881
1009
  | `job.task_id`, `job.job_type`, `job.check_status_url`, `job.webhook_url` | Job details from the submit response |
@@ -884,7 +1012,7 @@ All methods return a `Promise`. Responses are automatically parsed into typed mo
884
1012
  | `job.result(options?)` | Wait until finished and return the result. Throws on failure or timeout; every error carries `task_id` |
885
1013
  | `job.wait(options?)` | Wait until finished and return the final task, without throwing on failure |
886
1014
 
887
- Results: `transcribe` → same shape as `transcribeVideo()`; `watch` → `WatchResult` (`video_info`, `transcript`, `scenes`, `frames_analyzed`, `usage?`); `extractVideo` → `{ data, video_info, usage? }`; `tweetStatement` → `TweetStatement`; `tiktokProfile` / `tiktokSearch` / `tiktokLiveSearch` → the completed task with every page of `videos` / `results`.
1015
+ 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`.
888
1016
 
889
1017
  ### Webhooks
890
1018
 
@@ -894,7 +1022,7 @@ Results: `transcribe` → same shape as `transcribeVideo()`; `watch` → `WatchR
894
1022
  | `verifyWebhookSignature(rawBody, signatureHeader, secret, options?)` | Same check, returning `true` / `false` |
895
1023
  | `WEBHOOK_HEADERS` | Header names: `signature`, `delivery`, `event`, `taskId` |
896
1024
 
897
- `options`: `toleranceSeconds` (default `300`, `0` turns the check off). Event types: `transcribe.*`, `watch.*`, `extract_video.*`, `tweet_statement.*`, `tiktok_profile.*`, `tiktok_search.*`, `tiktok_live_search.*`, each with `.completed` or `.failed`.
1025
+ `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`.
898
1026
 
899
1027
  ### TikTok
900
1028
 
@@ -918,8 +1046,9 @@ Completed profile tasks include `videos`; completed search tasks include `result
918
1046
  | Method | Description |
919
1047
  |--------|-------------|
920
1048
  | `getFiles(query?)` | List uploaded files (paginated). Filter by `status` or `namespace_id` |
921
- | `getFile(file_id, query?)` | Get file info and transcript. Pass `transcript_text: true` for plain text |
922
- | `uploadFile(options)` | Upload audio/video. Options: `filePath`, `wait_for_completion`, `namespace_ids` |
1049
+ | `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 |
1050
+ | `uploadFile(options)` | Upload audio/video. Options: `filePath`, `wait_for_completion`, `namespace_ids`, `include_scenes` (also analyze the scenes of a video file) |
1051
+ | `analyzeFileScenes(file_id)` | Start the scene analysis of a file already uploaded. Returns `{ file_id, scenes_status, message }`, with `scenes_status` `'processing'` or `'completed'` |
923
1052
  | `deleteFile(file_id)` | Delete a file |
924
1053
  | `getFileUrl(file_id)` | Get a signed download URL |
925
1054
  | `retryFileProcessing(file_id)` | Retry a failed processing job |
@@ -941,8 +1070,9 @@ Completed profile tasks include `videos`; completed search tasks include `result
941
1070
 
942
1071
  | Method | Description |
943
1072
  |--------|-------------|
944
- | `analyzeVideo(payload)` | Analyze an online video with an optional natural language query |
945
- | `analyzeFile(payload)` | Analyze an uploaded file with an optional natural language query |
1073
+ | `analyzeVideo(payload)` | Analyze an online video with an optional natural language query. Options: `video_url`, `query`, `include_scenes`, `transcript_text`, `include_usage` |
1074
+ | `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) |
1075
+ | `analyzeFile(payload)` | Analyze an uploaded file with an optional natural language query. Options: `file_id`, `query`, `include_scenes`, `transcript_text`, `include_usage` |
946
1076
  | `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` |
947
1077
  | `getTweetStatement(payload, options?)` | Same as `tweetStatement()`, with the original payload shape |
948
1078
 
@@ -953,15 +1083,17 @@ Returns `transcript_analysis` containing:
953
1083
  - `key_subjects` — important topics (name, description, importance)
954
1084
  - `query_answer` — direct answer to your query (when provided) with `answer`, `best_segment_index`, and `relevant_segments`
955
1085
 
1086
+ 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`.
1087
+
956
1088
  ### Extraction
957
1089
 
958
1090
  | Method | Description |
959
1091
  |--------|-------------|
960
- | `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? }` |
1092
+ | `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? }` |
961
1093
  | `extractVideoData(payload, options?)` | Same as `extractVideo()`, with the original payload shape (`include_usage` in the payload) |
962
- | `extractFileData(payload)` | Extract structured data from an uploaded file transcript |
1094
+ | `extractFileData(payload)` | Extract structured data from an uploaded file transcript, and from its scenes with `include_scenes`. Returns `{ data, file_info, frames_analyzed?, usage? }` |
963
1095
 
964
- **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`)
1096
+ **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`)
965
1097
 
966
1098
  **Schema field types:** `String`, `Number`, `Boolean`, `Integer`, `Object`, `Array`, `Enum`
967
1099
 
@@ -1016,6 +1148,7 @@ try {
1016
1148
  | `InsufficientCreditsError` | 402 | A job could not start: not enough credits (`limit_exceeded`). Extends `PaymentRequiredError` |
1017
1149
  | `AccessDeniedError` | 403 | Insufficient permissions |
1018
1150
  | `NotFoundError` | 404 | Resource does not exist, or a job's `task_id` is unknown or expired (`task_not_found`) |
1151
+ | `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` |
1019
1152
  | `StorageQuotaExceededError` | 413 | Storage quota exceeded |
1020
1153
  | `RateLimitExceededError` | 429 | Too many requests |
1021
1154
  | `TooManyActiveJobsError` | 429 | A job could not start: too many of your jobs are already running (`too_many_active_jobs`). Extends `RateLimitExceededError` |
@@ -1034,7 +1167,7 @@ All API responses are parsed into typed classes with static `fromJSON()` constru
1034
1167
  | Class | Description |
1035
1168
  |-------|-------------|
1036
1169
  | `VideoInfo` | Video metadata: title, channel, duration, views, likes, published date, keywords, carousel info |
1037
- | `FileInfo` | Uploaded file: name, size, type, duration, status, `namespace_ids`, `namespaces` |
1170
+ | `FileInfo` | Uploaded file: name, size, type, duration, status, `namespace_ids`, `namespaces`, and where its scene analysis stands: `scenes_status`, `frames_analyzed`, `scenes_error` |
1038
1171
  | `TranscriptSegment` | Timed segment: `text`, `start`, `end` (seconds) |
1039
1172
  | `AnalysisResult` | AI analysis: summary, people, places, key subjects, query answer |
1040
1173
  | `Namespace` | Full namespace: id, name, created/updated timestamps |
@@ -1048,9 +1181,9 @@ All API responses are parsed into typed classes with static `fromJSON()` constru
1048
1181
  | `CarouselInfo` | Carousel summary: total items, video/image count, transcribed count, total duration |
1049
1182
  | `CarouselVideoResult` | Per-video result in a carousel: index, status, video info, transcript |
1050
1183
  | `Job` | Handle returned by `.submit()` / `.resume()`: `task_id`, `status()`, `refresh()`, `result()`, `wait()` |
1051
- | `AsyncJob<T>` | Task snapshot of a transcription, watch, extraction, or tweet job (from `job.refresh()` / `job.wait()`): `task_status`, `result`, `error`, `webhook`, `request`, timestamps |
1184
+ | `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 |
1052
1185
  | `WatchResult` | A watched video, from `watch()`: `video_info`, `transcript` (left out with `include_transcript: false`), `transcript_error`, `scenes`, `frames_analyzed`, `usage` |
1053
- | `VideoScene` | What a video shows between `start` and `end` (seconds): `description`, `on_screen_text` |
1186
+ | `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` |
1054
1187
  | `TikTokProfileScrapeSubmission` | Async scrape submission: `task_id`, status, profile URL, expiry, `webhook_url` |
1055
1188
  | `TikTokProfileTask` | TikTok profile scrape task with status, profile metadata, videos, pagination, `download_url`, `error`, `webhook` |
1056
1189
  | `TikTokVideo` | Public TikTok video metadata returned by profile scraping, including `published_at` as a `Date` and integer counters |
@@ -1063,6 +1196,18 @@ All API responses are parsed into typed classes with static `fromJSON()` constru
1063
1196
  | `TikTokLiveRoomDetail` | A `TikTokLiveRoom` from `getTikTokLiveRoom`: `status` / `isLive`, `ended_at`, `stats.new_followers`, `author.bio`, `share_url`, `chat_enabled`, `subscribers_only`, `products` |
1064
1197
  | `TweetStatement` | Structured X/Twitter claim analysis, topics, entities, tone, intent, and source text |
1065
1198
 
1199
+ ## What's new in 2.6.0
1200
+
1201
+ - **Extraction takes a standard JSON Schema**, the only schema format the API accepts now: `{ type: 'object', properties: { ... } }`, with lowercase types. A Zod schema converted with `zod-to-json-schema` can be passed as it is. The former format (`{ field: { type: 'String', ... } }`) is refused with `invalid_schema`. The `ExtractionSchema` and `ExtractionField` types describe the new format.
1202
+ - **Extraction without a schema:** `extractVideoData`, `vn.extractVideo` and `extractFileData` take `what_to_extract` alone; the schema written for it comes back as `schema` on the result (and on the `extract_video.completed` webhook event).
1203
+
1204
+ ## What's new in 2.5.0
1205
+
1206
+ - **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.
1207
+ - **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.
1208
+ - **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.
1209
+ - **`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.
1210
+
1066
1211
  ## What's new in 2.4.0
1067
1212
 
1068
1213
  - **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.
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: