vidnavigator 2.7.0 → 3.0.1
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 +97 -109
- package/dist/index.d.ts +17 -109
- package/dist/index.js +14 -54
- package/dist/models/AsyncJob.d.ts +2 -2
- package/dist/models/SearchResult.d.ts +13 -7
- package/dist/models/SearchResult.js +16 -6
- package/dist/models/TweetStatement.d.ts +10 -0
- package/dist/models/index.d.ts +0 -1
- package/dist/models/index.js +0 -1
- package/dist/webhooks.d.ts +2 -2
- package/package.json +1 -1
- package/src/index.ts +26 -172
- package/src/models/AsyncJob.ts +2 -2
- package/src/models/SearchResult.ts +31 -14
- package/src/models/TweetStatement.ts +10 -0
- package/src/models/index.ts +0 -1
- package/src/webhooks.ts +1 -3
- package/src/models/AnalysisResult.ts +0 -51
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,
|
|
3
|
+
The official JavaScript/TypeScript SDK for the [VidNavigator Developer API](https://vidnavigator.com). Transcribe, watch, 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)
|
|
@@ -12,14 +12,13 @@ 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
|
|
15
|
+
- **Scenes in extraction and tweet analysis** — with `include_scenes`, an extraction reads what the video shows as well as what it says, for online videos and for uploaded files, and a tweet analysis reads what the post's videos show.
|
|
16
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.
|
|
17
17
|
- **TikTok LIVE room** — check one room or streamer right away, with its latest comments, pinned comment and top viewers.
|
|
18
18
|
- **Instagram carousel support** — select a specific video by index, or transcribe every video in a carousel post with one call.
|
|
19
|
-
- **
|
|
20
|
-
- **Structured data extraction** — define a JSON schema and receive typed, structured fields extracted from any transcript (powered by LLMs).
|
|
19
|
+
- **Structured data extraction** — say in plain words what to extract (`what_to_extract`), or define a JSON Schema, and receive typed fields from what a video or a file says and shows, with the moments each value comes from (`evidence`).
|
|
21
20
|
- **AI search and reranking** — YouTube search and file search with AI ranking/reranking and rich result metadata.
|
|
22
|
-
- **File management with namespaces** — upload audio/video files, organize them into namespaces, and scope searches
|
|
21
|
+
- **File management with namespaces** — upload audio/video files, organize them into namespaces, and scope searches by folder.
|
|
23
22
|
- **Full TypeScript support** — rich types, autocompletion, and compile-time safety out of the box.
|
|
24
23
|
- **Comprehensive error handling** — dedicated error classes for every API error code (`AuthenticationError`, `RateLimitExceededError`, `GeoRestrictedError`, and more).
|
|
25
24
|
- **Lightweight** — only two runtime dependencies: `axios` and `form-data`.
|
|
@@ -40,7 +39,7 @@ The official JavaScript/TypeScript SDK for the [VidNavigator Developer API](http
|
|
|
40
39
|
| Snapchat | Yes, when Snapchat has a transcript | Yes | Yes | Yes (highlights: `img_index`, `all_videos`) |
|
|
41
40
|
| Uploaded files | Yes | Yes | Yes (`include_scenes` at upload, or `analyzeFileScenes()`) | - |
|
|
42
41
|
|
|
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
|
|
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()`. The same scenes can feed an extraction with `include_scenes: true`.
|
|
44
43
|
|
|
45
44
|
## Installation
|
|
46
45
|
|
|
@@ -92,6 +91,10 @@ const vn = new VidNavigatorClient({
|
|
|
92
91
|
|
|
93
92
|
`axiosConfig.timeout` limits each HTTP request. How long the SDK waits for a background job to finish is set per call with `timeoutMs` (see [Background jobs](#3-background-jobs-one-call-or-many-at-once)).
|
|
94
93
|
|
|
94
|
+
### Upgrading to 3.0
|
|
95
|
+
|
|
96
|
+
3.0 removes the analysis methods, together with the API endpoints they called. Ask the same questions with an extraction: say in plain words what you want (`what_to_extract`), give a JSON Schema, or both. [What's new in 3.0.0](#whats-new-in-300) shows how each call moves.
|
|
97
|
+
|
|
95
98
|
### Upgrading from 1.x
|
|
96
99
|
|
|
97
100
|
Transcription, structured extraction, and tweet analysis now always run as background jobs, so they work on videos of any length. Your existing calls keep working with the same arguments, with one difference:
|
|
@@ -215,7 +218,7 @@ Errors worth handling: `NotFoundError` with `error_code` `'frames_not_available'
|
|
|
215
218
|
|
|
216
219
|
### 3. Background jobs: one call, or many at once
|
|
217
220
|
|
|
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.
|
|
221
|
+
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.
|
|
219
222
|
|
|
220
223
|
Each of these operations comes in two shapes:
|
|
221
224
|
|
|
@@ -223,7 +226,6 @@ Each of these operations comes in two shapes:
|
|
|
223
226
|
|---|---|---|
|
|
224
227
|
| Transcription | `await vn.transcribe(url)` | `await vn.transcribe.submit(url)` |
|
|
225
228
|
| 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)` |
|
|
227
229
|
| Structured extraction | `await vn.extractVideo({ video_url, schema })` | `await vn.extractVideo.submit({ ... })` |
|
|
228
230
|
| Tweet claim analysis | `await vn.tweetStatement(tweetId)` | `await vn.tweetStatement.submit(tweetId)` |
|
|
229
231
|
| TikTok profile scrape | `await vn.tiktokProfile(profileUrl)` | `await vn.tiktokProfile.submit(profileUrl)` |
|
|
@@ -376,7 +378,7 @@ function pending(): string[] {
|
|
|
376
378
|
|
|
377
379
|
### 4. Webhooks
|
|
378
380
|
|
|
379
|
-
You can also have VidNavigator call your server when a job finishes. Pass `webhook_url` to any of the operations above (transcription, watch,
|
|
381
|
+
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`.
|
|
380
382
|
|
|
381
383
|
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.
|
|
382
384
|
|
|
@@ -425,7 +427,7 @@ app.post('/hooks/vidnavigator', express.raw({ type: 'application/json' }), async
|
|
|
425
427
|
});
|
|
426
428
|
```
|
|
427
429
|
|
|
428
|
-
- `event.data.result` holds the raw result for transcription, watch,
|
|
430
|
+
- `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.
|
|
429
431
|
- `verifyWebhookSignature(rawBody, signatureHeader, secret)` returns `true` or `false` instead of throwing.
|
|
430
432
|
- Deliveries older than 5 minutes are rejected by default. Change this with `{ toleranceSeconds }`; `0` turns the check off.
|
|
431
433
|
- Failed deliveries (5xx, 429, network errors) are retried 5 times over about 13 minutes. Other 4xx responses are not retried.
|
|
@@ -615,9 +617,9 @@ if ('carousel_info' in all) {
|
|
|
615
617
|
}
|
|
616
618
|
```
|
|
617
619
|
|
|
618
|
-
### 8. Upload
|
|
620
|
+
### 8. Upload a local file
|
|
619
621
|
|
|
620
|
-
Upload audio or video files for transcription,
|
|
622
|
+
Upload audio or video files for transcription, extraction, and search. Supported formats: mp4, webm, mov, avi, wmv, flv, mkv, m4a, mp3, mpeg, mpga, wav.
|
|
621
623
|
|
|
622
624
|
```ts
|
|
623
625
|
const upload = await vn.uploadFile({
|
|
@@ -630,23 +632,18 @@ console.log(upload.file_id); // "64a1b2c3d4e5f6789..."
|
|
|
630
632
|
console.log(upload.file_name); // "meeting-recording.mp4"
|
|
631
633
|
console.log(upload.file_info?.namespace_ids); // ["ns_meetings"]
|
|
632
634
|
|
|
633
|
-
//
|
|
634
|
-
const {
|
|
635
|
+
// Ask about it in plain words (see Extract structured data below)
|
|
636
|
+
const { data } = await vn.extractFileData({
|
|
635
637
|
file_id: upload.file_id,
|
|
636
|
-
|
|
638
|
+
what_to_extract: 'A short summary, the people who speak with their role, and every action item',
|
|
637
639
|
});
|
|
638
640
|
|
|
639
|
-
console.log(
|
|
640
|
-
//
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
// [
|
|
644
|
-
|
|
645
|
-
console.log(transcript_analysis.key_subjects);
|
|
646
|
-
// [{ name: "Q3 targets", description: "Revenue goals for...", importance: "high" }, ...]
|
|
647
|
-
|
|
648
|
-
console.log(transcript_analysis.query_answer?.answer);
|
|
649
|
-
// "Three action items were discussed: 1) Finalize the hiring..."
|
|
641
|
+
console.log(data);
|
|
642
|
+
// {
|
|
643
|
+
// summary: "The meeting covered Q3 targets, hiring plans, and a product launch timeline...",
|
|
644
|
+
// people: [{ name: "Sarah", role: "VP of Engineering" }, ...],
|
|
645
|
+
// action_items: ["Finalize the hiring plan", ...]
|
|
646
|
+
// }
|
|
650
647
|
```
|
|
651
648
|
|
|
652
649
|
Without `wait_for_completion`, the upload returns right away (`status: 'accepted'`) while the file is processed. Check on it with `getFile()`, then work with it:
|
|
@@ -697,12 +694,12 @@ const { scenes_status } = await vn.analyzeFileScenes(file_id);
|
|
|
697
694
|
// 'processing': started, or already running. 'completed': the scenes are already there.
|
|
698
695
|
```
|
|
699
696
|
|
|
700
|
-
`
|
|
697
|
+
`extractFileData()` then reads the scenes with `include_scenes: true`. The fields are extracted from the transcript of the file and its scenes together, and the result also has `frames_analyzed`:
|
|
701
698
|
|
|
702
699
|
```ts
|
|
703
|
-
const {
|
|
700
|
+
const { data, frames_analyzed } = await vn.extractFileData({
|
|
704
701
|
file_id,
|
|
705
|
-
|
|
702
|
+
what_to_extract: 'Every ingredient with its quantity',
|
|
706
703
|
include_scenes: true,
|
|
707
704
|
});
|
|
708
705
|
```
|
|
@@ -713,7 +710,7 @@ A file that has no scenes to read is refused with `ScenesNotAvailableError` (HTT
|
|
|
713
710
|
import { ScenesNotAvailableError } from 'vidnavigator';
|
|
714
711
|
|
|
715
712
|
try {
|
|
716
|
-
await vn.
|
|
713
|
+
await vn.extractFileData({ file_id, what_to_extract: 'Every ingredient with its quantity', include_scenes: true });
|
|
717
714
|
} catch (err) {
|
|
718
715
|
if (err instanceof ScenesNotAvailableError && err.scenes_status === 'none') {
|
|
719
716
|
await vn.analyzeFileScenes(file_id); // then wait for scenes_status 'completed' and call again
|
|
@@ -723,56 +720,11 @@ try {
|
|
|
723
720
|
}
|
|
724
721
|
```
|
|
725
722
|
|
|
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
|
|
727
|
-
|
|
728
|
-
### Analyze an online video
|
|
729
|
-
|
|
730
|
-
```ts
|
|
731
|
-
const { video_info, transcript_analysis } = await vn.analyzeVideo({
|
|
732
|
-
video_url: 'https://www.youtube.com/watch?v=4czjS9h4Fpg',
|
|
733
|
-
query: 'Where did the rover land?',
|
|
734
|
-
include_usage: true,
|
|
735
|
-
});
|
|
736
|
-
|
|
737
|
-
console.log(transcript_analysis.summary);
|
|
738
|
-
console.log(transcript_analysis.query_answer?.answer); // direct answer to your question
|
|
739
|
-
console.log(transcript_analysis.query_answer?.relevant_segments); // supporting transcript excerpts
|
|
740
|
-
```
|
|
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
|
-
```
|
|
723
|
+
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 extracted from its scenes alone, and the result has a `transcript_error`.
|
|
772
724
|
|
|
773
725
|
### 9. Extract structured data
|
|
774
726
|
|
|
775
|
-
Define a schema, as a standard JSON Schema, and get back clean, structured data extracted from any video or file
|
|
727
|
+
Define a schema, as a standard JSON Schema, and get back clean, structured data extracted from what any video or file says and, with `include_scenes`, what it shows. Or skip the schema and say what you want in plain words with `what_to_extract`: a summary, the people and places mentioned, the answer to a question, anything you would have asked of an analysis. Per-call usage tracking included (see [Per-call usage](#per-call-usage)).
|
|
776
728
|
|
|
777
729
|
```ts
|
|
778
730
|
const { data, usage } = await vn.extractVideoData({
|
|
@@ -847,7 +799,7 @@ const { data, frames_analyzed } = await vn.extractVideoData({
|
|
|
847
799
|
console.log(data, frames_analyzed); // quantities that are only written on screen are found too
|
|
848
800
|
```
|
|
849
801
|
|
|
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)).
|
|
802
|
+
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)). 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.
|
|
851
803
|
|
|
852
804
|
**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
805
|
|
|
@@ -865,6 +817,20 @@ console.log(schema); // { type: "object", properties: { mood: {...}, topics: {..
|
|
|
865
817
|
|
|
866
818
|
> `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.
|
|
867
819
|
|
|
820
|
+
### 9b. Claims in an X post
|
|
821
|
+
|
|
822
|
+
`vn.tweetStatement()` reads an X/Twitter post, the post it quotes and their media, and returns its core claim, topics, entities and classification (`claim_type`, `intent`, `tone`, `emotion`, `authority`). Pass `include_scenes: true` to also read what the post's video and the quoted post's video show, with the text readable on screen:
|
|
823
|
+
|
|
824
|
+
```ts
|
|
825
|
+
const statement = await vn.tweetStatement({ tweet_id: '1585841080431321088', include_scenes: true });
|
|
826
|
+
|
|
827
|
+
console.log(statement.final_statement);
|
|
828
|
+
console.log(statement.frames_analyzed); // frames read to follow the videos' picture
|
|
829
|
+
if (statement.scenes_error) console.log(statement.scenes_error.error); // a video's picture could not be read
|
|
830
|
+
```
|
|
831
|
+
|
|
832
|
+
When a video's picture cannot be read, the analysis still succeeds: that video is summarized from its transcript alone, and `scenes_error` says why.
|
|
833
|
+
|
|
868
834
|
### 10. Semantic search
|
|
869
835
|
|
|
870
836
|
Search YouTube videos and uploaded files with AI-powered ranking/reranking.
|
|
@@ -911,7 +877,7 @@ for (const r of fileResults.results) {
|
|
|
911
877
|
}
|
|
912
878
|
```
|
|
913
879
|
|
|
914
|
-
> **Deprecated:** `searchVideos()` still works but is deprecated — it
|
|
880
|
+
> **Deprecated:** `searchVideos()` still works but is deprecated — it forwards to `searchYouTube()` and emits a deprecation warning. Use `searchYouTube()` instead.
|
|
915
881
|
|
|
916
882
|
### 11. Organize files with namespaces
|
|
917
883
|
|
|
@@ -947,7 +913,7 @@ console.log(`Channels indexed: ${usage.channelsIndexed.used} / ${usage.channelsI
|
|
|
947
913
|
|
|
948
914
|
### Per-call usage
|
|
949
915
|
|
|
950
|
-
Pass `include_usage: true` to most endpoints (`getTranscript`, `transcribeVideo`, `watchVideo`, `
|
|
916
|
+
Pass `include_usage: true` to most endpoints (`getTranscript`, `transcribeVideo`, `watchVideo`, `extractVideoData`, `extractFileData`, `searchYouTube`, `searchFiles`) to receive a `usage` block describing exactly what the request cost. For background jobs (`vn.transcribe`, `vn.watch`, `vn.extractVideo`, ...), 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.
|
|
951
917
|
|
|
952
918
|
The `usage` field is a `UsageBlock`:
|
|
953
919
|
|
|
@@ -973,7 +939,7 @@ if (usage) {
|
|
|
973
939
|
}
|
|
974
940
|
```
|
|
975
941
|
|
|
976
|
-
`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
|
|
942
|
+
`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/*` 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, the entry carries `waived: true` + `credits_saved`, and the block carries a top-level `waived.credits_saved`.
|
|
977
943
|
|
|
978
944
|
---
|
|
979
945
|
|
|
@@ -1003,7 +969,7 @@ All methods return a `Promise`. Responses are automatically parsed into typed mo
|
|
|
1003
969
|
|
|
1004
970
|
| Member | Description |
|
|
1005
971
|
|--------|-------------|
|
|
1006
|
-
| `vn.transcribe`, `vn.watch`, `vn.
|
|
972
|
+
| `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` |
|
|
1007
973
|
| `.submit(input, { include_usage? })` | Start the job and return a `Job` immediately |
|
|
1008
974
|
| `.resume(task_id, { include_usage? })` | Get a `Job` for a job you already started (no request is made) |
|
|
1009
975
|
| `job.task_id`, `job.job_type`, `job.check_status_url`, `job.webhook_url` | Job details from the submit response |
|
|
@@ -1012,7 +978,7 @@ All methods return a `Promise`. Responses are automatically parsed into typed mo
|
|
|
1012
978
|
| `job.result(options?)` | Wait until finished and return the result. Throws on failure or timeout; every error carries `task_id` |
|
|
1013
979
|
| `job.wait(options?)` | Wait until finished and return the final task, without throwing on failure |
|
|
1014
980
|
|
|
1015
|
-
Results: `transcribe` → same shape as `transcribeVideo()`; `watch` → `WatchResult` (`video_info`, `transcript`, `scenes`, `frames_analyzed`, `usage?`); `
|
|
981
|
+
Results: `transcribe` → same shape as `transcribeVideo()`; `watch` → `WatchResult` (`video_info`, `transcript`, `scenes`, `frames_analyzed`, `usage?`); `extractVideo` → `{ data, video_info, frames_analyzed?, schema?, evidence?, usage? }`; `tweetStatement` → `TweetStatement`; `tiktokProfile` / `tiktokSearch` / `tiktokLiveSearch` → the completed task with every page of `videos` / `results`.
|
|
1016
982
|
|
|
1017
983
|
### Webhooks
|
|
1018
984
|
|
|
@@ -1022,7 +988,7 @@ Results: `transcribe` → same shape as `transcribeVideo()`; `watch` → `WatchR
|
|
|
1022
988
|
| `verifyWebhookSignature(rawBody, signatureHeader, secret, options?)` | Same check, returning `true` / `false` |
|
|
1023
989
|
| `WEBHOOK_HEADERS` | Header names: `signature`, `delivery`, `event`, `taskId` |
|
|
1024
990
|
|
|
1025
|
-
`options`: `toleranceSeconds` (default `300`, `0` turns the check off). Event types: `transcribe.*`, `watch.*`, `
|
|
991
|
+
`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`.
|
|
1026
992
|
|
|
1027
993
|
### TikTok
|
|
1028
994
|
|
|
@@ -1066,36 +1032,26 @@ Completed profile tasks include `videos`; completed search tasks include `result
|
|
|
1066
1032
|
| `deleteNamespace(id)` | Delete a namespace |
|
|
1067
1033
|
| `updateFileNamespaces(file_id, { namespace_ids })` | Assign a file to namespaces. Returns updated `namespace_ids` and `namespaces` |
|
|
1068
1034
|
|
|
1069
|
-
###
|
|
1035
|
+
### Extraction
|
|
1070
1036
|
|
|
1071
1037
|
| Method | Description |
|
|
1072
1038
|
|--------|-------------|
|
|
1073
|
-
| `
|
|
1074
|
-
| `
|
|
1075
|
-
| `
|
|
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` |
|
|
1077
|
-
| `getTweetStatement(payload, options?)` | Same as `tweetStatement()`, with the original payload shape |
|
|
1039
|
+
| `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?, schema?, evidence?, usage? }` |
|
|
1040
|
+
| `extractVideoData(payload, options?)` | Same as `extractVideo()`, with the original payload shape (`include_usage` in the payload) |
|
|
1041
|
+
| `extractFileData(payload)` | Extract structured data from an uploaded file transcript, and from its scenes with `include_scenes`. Returns `{ data, file_info, frames_analyzed?, schema?, evidence?, usage? }`. A file that has no scenes throws `ScenesNotAvailableError` with `include_scenes` |
|
|
1078
1042
|
|
|
1079
|
-
|
|
1080
|
-
- `summary` — content overview
|
|
1081
|
-
- `people` — people mentioned (name + context)
|
|
1082
|
-
- `places` — locations referenced
|
|
1083
|
-
- `key_subjects` — important topics (name, description, importance)
|
|
1084
|
-
- `query_answer` — direct answer to your query (when provided) with `answer`, `best_segment_index`, and `relevant_segments`
|
|
1043
|
+
**Options:** `schema` (a standard JSON Schema; optional when `what_to_extract` is given), `schemaFilePath` (JSON/YAML schema file via multipart form-data), `what_to_extract` (what to extract, in plain words: guides the extraction, or alone, writes the schema), `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`)
|
|
1085
1044
|
|
|
1086
|
-
|
|
1045
|
+
**Schema property types:** `string`, `number`, `integer`, `boolean`, `array`, `object`, and `enum` to restrict a property to a list of values
|
|
1087
1046
|
|
|
1088
|
-
###
|
|
1047
|
+
### X posts
|
|
1089
1048
|
|
|
1090
1049
|
| Method | Description |
|
|
1091
1050
|
|--------|-------------|
|
|
1092
|
-
| `
|
|
1093
|
-
| `
|
|
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? }` |
|
|
1095
|
-
|
|
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`)
|
|
1051
|
+
| `tweetStatement(tweetIdOrInput, options?)` | Structured claim analysis of an X/Twitter tweet, including attached media of any length. Input: `tweet_id`, `include_scenes` (also read what the post's video and the quoted post's video show), `webhook_url`. Returns a `TweetStatement`. See [Background jobs](#background-jobs) |
|
|
1052
|
+
| `getTweetStatement(payload, options?)` | Same as `tweetStatement()`, with the original payload shape |
|
|
1097
1053
|
|
|
1098
|
-
|
|
1054
|
+
With `include_scenes: true`, the `TweetStatement` also has `frames_analyzed`, and `scenes_error` (`{ error, message }`) when a video's picture could not be read: that video is then summarized from its transcript alone.
|
|
1099
1055
|
|
|
1100
1056
|
### Search
|
|
1101
1057
|
|
|
@@ -1169,7 +1125,6 @@ All API responses are parsed into typed classes with static `fromJSON()` constru
|
|
|
1169
1125
|
| `VideoInfo` | Video metadata: title, channel, duration, views, likes, published date, keywords, carousel info |
|
|
1170
1126
|
| `FileInfo` | Uploaded file: name, size, type, duration, status, `namespace_ids`, `namespaces`, and where its scene analysis stands: `scenes_status`, `frames_analyzed`, `scenes_error` |
|
|
1171
1127
|
| `TranscriptSegment` | Timed segment: `text`, `start`, `end` (seconds) |
|
|
1172
|
-
| `AnalysisResult` | AI analysis: summary, people, places, key subjects, query answer |
|
|
1173
1128
|
| `Namespace` | Full namespace: id, name, created/updated timestamps |
|
|
1174
1129
|
| `NamespaceRef` | Lightweight `{ id, name }` reference embedded in file and search responses |
|
|
1175
1130
|
| `VideoSearchResult` | Extends `VideoInfo` with `relevance_score`, `transcript_summary`, search metadata |
|
|
@@ -1181,9 +1136,9 @@ All API responses are parsed into typed classes with static `fromJSON()` constru
|
|
|
1181
1136
|
| `CarouselInfo` | Carousel summary: total items, video/image count, transcribed count, total duration |
|
|
1182
1137
|
| `CarouselVideoResult` | Per-video result in a carousel: index, status, video info, transcript |
|
|
1183
1138
|
| `Job` | Handle returned by `.submit()` / `.resume()`: `task_id`, `status()`, `refresh()`, `result()`, `wait()` |
|
|
1184
|
-
| `AsyncJob<T>` | Task snapshot of a transcription, watch,
|
|
1139
|
+
| `AsyncJob<T>` | Task snapshot of a transcription, watch, extraction, or tweet job (from `job.refresh()` / `job.wait()`): `task_status`, `result`, `error`, `webhook`, `request`, timestamps |
|
|
1185
1140
|
| `WatchResult` | A watched video, from `watch()`: `video_info`, `transcript` (left out with `include_transcript: false`), `transcript_error`, `scenes`, `frames_analyzed`, `usage` |
|
|
1186
|
-
| `VideoScene` | What a video or an uploaded file shows between `start` and `end` (seconds): `description`, `on_screen_text`. Returned by `watch()
|
|
1141
|
+
| `VideoScene` | What a video or an uploaded file shows between `start` and `end` (seconds): `description`, `on_screen_text`. Returned by `watch()` and by `getFile()` |
|
|
1187
1142
|
| `TikTokProfileScrapeSubmission` | Async scrape submission: `task_id`, status, profile URL, expiry, `webhook_url` |
|
|
1188
1143
|
| `TikTokProfileTask` | TikTok profile scrape task with status, profile metadata, videos, pagination, `download_url`, `error`, `webhook` |
|
|
1189
1144
|
| `TikTokVideo` | Public TikTok video metadata returned by profile scraping, including `published_at` as a `Date` and integer counters |
|
|
@@ -1194,7 +1149,40 @@ All API responses are parsed into typed classes with static `fromJSON()` constru
|
|
|
1194
1149
|
| `TikTokLiveSearchTask` | TikTok LIVE search task with status, rooms, pagination, `download_url`, `error`, `webhook`; `stats.rooms_fetched` is what is billed |
|
|
1195
1150
|
| `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) |
|
|
1196
1151
|
| `TikTokLiveRoomDetail` | A `TikTokLiveRoom` from `getTikTokLiveRoom`: `status` / `isLive`, `ended_at`, `stats.new_followers`, `author.bio`, `share_url`, `chat_enabled`, `subscribers_only`, `products` |
|
|
1197
|
-
| `TweetStatement` | Structured X/Twitter claim analysis, topics, entities, tone, intent, and source text |
|
|
1152
|
+
| `TweetStatement` | Structured X/Twitter claim analysis, topics, entities, tone, intent, and source text; with `include_scenes`, `frames_analyzed` and `scenes_error` |
|
|
1153
|
+
|
|
1154
|
+
## What's new in 3.0.1
|
|
1155
|
+
|
|
1156
|
+
- **`people`, `places` and `key_subjects` of search results can be read with `.name`.** The API sends them as lists of names (`["Sam Altman"]`), while the types promised objects, so `result.people[0].name` was `undefined`. `VideoSearchResult` and `FileSearchResult` now turn each name into `{ name }`, as the Python SDK does.
|
|
1157
|
+
|
|
1158
|
+
## What's new in 3.0.0
|
|
1159
|
+
|
|
1160
|
+
**Breaking:** the analysis methods are removed, with the API endpoints they called. Ask the same questions with extraction, `extractVideoData()` / `vn.extractVideo()` for an online video and `extractFileData()` for an uploaded file, with `what_to_extract` in plain words and/or a JSON Schema. `include_scenes` works there too, and each value comes with the moments of the video it was taken from (`evidence`).
|
|
1161
|
+
|
|
1162
|
+
| 2.x | 3.0 |
|
|
1163
|
+
|---|---|
|
|
1164
|
+
| `analyzeVideo({ video_url, query })` | `extractVideoData({ video_url, what_to_extract })` |
|
|
1165
|
+
| `vn.analyze(...)`, `vn.analyze.submit(...)`, `vn.analyze.resume(...)` | `vn.extractVideo(...)`, `vn.extractVideo.submit(...)`, `vn.extractVideo.resume(...)` |
|
|
1166
|
+
| `analyzeFile({ file_id, query })` | `extractFileData({ file_id, what_to_extract })` |
|
|
1167
|
+
| `transcript_analysis` (`AnalysisResult`) | `data`: the fields you asked for |
|
|
1168
|
+
| `analyze_video.completed` / `analyze_video.failed` webhook events | `extract_video.completed` / `extract_video.failed` |
|
|
1169
|
+
|
|
1170
|
+
```ts
|
|
1171
|
+
// 2.x
|
|
1172
|
+
const { transcript_analysis } = await vn.analyzeVideo({ video_url, query: 'What are the ingredients?', include_scenes: true });
|
|
1173
|
+
|
|
1174
|
+
// 3.0
|
|
1175
|
+
const { data, evidence } = await vn.extractVideoData({
|
|
1176
|
+
video_url,
|
|
1177
|
+
what_to_extract: 'A short summary, and every ingredient with its quantity',
|
|
1178
|
+
include_scenes: true,
|
|
1179
|
+
});
|
|
1180
|
+
```
|
|
1181
|
+
|
|
1182
|
+
An extraction result has no transcript: get it with `getTranscript()`, or next to the scenes with `vn.watch()`.
|
|
1183
|
+
|
|
1184
|
+
- **Removed:** `analyzeVideo()`, `analyzeFile()`, `vn.analyze()` with `vn.analyze.submit()` and `vn.analyze.resume()`, the `analyze_video.completed` / `analyze_video.failed` webhook events and the `analyze_video` job type, and the types that only they used: `AnalysisResult`, `AnalysisResultJSON`, `KeySubject`, `QueryAnswer`, `AnalyzeVideoPayload`, `AnalyzeFilePayload`, `AnalyzeVideoInput`, `AnalyzeVideoResult`, `AnalyzeFileResult`, `AnalyzeVideoAsyncJob`, `AnalyzeVideoJob`. `analyzeFileScenes()`, which starts the scene analysis of an uploaded file, stays.
|
|
1185
|
+
- **Scenes in tweet analysis:** `include_scenes: true` on `vn.tweetStatement()`, `vn.tweetStatement.submit()` and `getTweetStatement()` also reads what the post's video and the quoted post's video show. The `TweetStatement` then has `frames_analyzed`, and `scenes_error` when a video's picture could not be read.
|
|
1198
1186
|
|
|
1199
1187
|
## What's new in 2.7.0
|
|
1200
1188
|
|
|
@@ -1214,7 +1202,7 @@ for (const moment of evidence?.people ?? []) console.log(moment.in, moment.start
|
|
|
1214
1202
|
## What's new in 2.5.0
|
|
1215
1203
|
|
|
1216
1204
|
- **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.
|
|
1217
|
-
- **Video analysis as a background job:**
|
|
1205
|
+
- **Video analysis as a background job:** `vn.analyze()` 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. (Analysis was removed in 3.0.0.)
|
|
1218
1206
|
- **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.
|
|
1219
1207
|
- **`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.
|
|
1220
1208
|
|