vidnavigator 0.1.5 → 1.0.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 +375 -77
- package/dist/errors.d.ts +19 -0
- package/dist/errors.js +35 -1
- package/dist/index.d.ts +110 -20
- package/dist/index.js +150 -31
- package/dist/models/Carousel.d.ts +30 -0
- package/dist/models/Carousel.js +21 -0
- package/dist/models/CarouselVideoResult.d.ts +28 -0
- package/dist/models/CarouselVideoResult.js +21 -0
- package/dist/models/Extraction.d.ts +27 -0
- package/dist/models/Extraction.js +14 -0
- package/dist/models/FileInfo.d.ts +5 -0
- package/dist/models/FileInfo.js +3 -0
- package/dist/models/Namespace.d.ts +29 -0
- package/dist/models/Namespace.js +37 -0
- package/dist/models/SearchResult.d.ts +29 -0
- package/dist/models/SearchResult.js +12 -0
- package/dist/models/TranscriptSegment.d.ts +7 -0
- package/dist/models/TranscriptSegment.js +11 -0
- package/dist/models/Usage.d.ts +68 -22
- package/dist/models/Usage.js +45 -13
- package/dist/models/VideoInfo.d.ts +6 -1
- package/dist/models/VideoInfo.js +9 -1
- package/dist/models/index.d.ts +4 -0
- package/dist/models/index.js +4 -0
- package/package.json +1 -1
- package/src/errors.ts +43 -0
- package/src/index.ts +450 -114
- package/src/models/Carousel.ts +45 -0
- package/src/models/CarouselVideoResult.ts +44 -0
- package/src/models/Extraction.ts +47 -0
- package/src/models/FileInfo.ts +8 -0
- package/src/models/Namespace.ts +60 -0
- package/src/models/SearchResult.ts +45 -1
- package/src/models/TranscriptSegment.ts +16 -0
- package/src/models/Usage.ts +183 -105
- package/src/models/VideoInfo.ts +15 -2
- package/src/models/index.ts +4 -0
package/README.md
CHANGED
|
@@ -1,28 +1,58 @@
|
|
|
1
|
-
# VidNavigator JavaScript
|
|
1
|
+
# VidNavigator SDK for JavaScript
|
|
2
2
|
|
|
3
|
-
The official JavaScript SDK for the [VidNavigator Developer API](https://vidnavigator.com).
|
|
3
|
+
The official JavaScript/TypeScript SDK for the [VidNavigator Developer API](https://vidnavigator.com). Transcribe, analyze, search, and extract structured data from video and audio — YouTube, Instagram, TikTok, X/Twitter, Vimeo, Facebook, Dailymotion, Loom, and your own uploaded files.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/vidnavigator)
|
|
6
|
+
[](https://github.com/vidnavigator/vidnavigator-js/blob/main/LICENSE)
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
---
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
10
|
+
## Why VidNavigator?
|
|
11
|
+
|
|
12
|
+
- **Multi-platform transcription** — YouTube, Instagram Reels & carousel posts, TikTok, X/Twitter, Vimeo, Facebook, Dailymotion, Loom, and more.
|
|
13
|
+
- **Instagram carousel support** — select a specific video by index, or transcribe every video in a carousel post with one call.
|
|
14
|
+
- **AI-powered analysis** — get summaries, people mentioned, places, key subjects, and direct answers to questions about any video or audio.
|
|
15
|
+
- **Structured data extraction** — define a JSON schema and receive typed, structured fields extracted from any transcript (powered by LLMs).
|
|
16
|
+
- **Semantic search** — vector-based search with AI reranking across your indexed YouTube channels and uploaded file libraries.
|
|
17
|
+
- **File management with namespaces** — upload audio/video files, organize them into namespaces, and scope searches and analysis by folder.
|
|
18
|
+
- **Full TypeScript support** — rich types, autocompletion, and compile-time safety out of the box.
|
|
19
|
+
- **Comprehensive error handling** — dedicated error classes for every API error code (`AuthenticationError`, `RateLimitExceededError`, `GeoRestrictedError`, and more).
|
|
20
|
+
- **Lightweight** — only two runtime dependencies: `axios` and `form-data`.
|
|
21
|
+
|
|
22
|
+
## Supported Platforms
|
|
23
|
+
|
|
24
|
+
| Platform | Transcript | Transcribe (speech-to-text) | Carousel |
|
|
25
|
+
|----------|:----------:|:---------------------------:|:--------:|
|
|
26
|
+
| YouTube | Yes | - | - |
|
|
27
|
+
| Instagram Reels | - | Yes | Yes |
|
|
28
|
+
| Instagram Posts | - | Yes | Yes (`all_videos`) |
|
|
29
|
+
| TikTok | - | Yes | - |
|
|
30
|
+
| X / Twitter | - | Yes | - |
|
|
31
|
+
| Vimeo | - | Yes | - |
|
|
32
|
+
| Facebook | - | Yes | - |
|
|
33
|
+
| Dailymotion | - | Yes | - |
|
|
34
|
+
| Loom | - | Yes | - |
|
|
35
|
+
| Uploaded files | Yes | Yes | - |
|
|
36
|
+
|
|
37
|
+
> **Transcript** = fast caption/subtitle extraction. **Transcribe** = speech-to-text via AI models (works when captions are unavailable).
|
|
14
38
|
|
|
15
39
|
## Installation
|
|
16
40
|
|
|
17
41
|
```bash
|
|
18
42
|
npm install vidnavigator
|
|
19
|
-
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
```bash
|
|
20
46
|
yarn add vidnavigator
|
|
21
47
|
```
|
|
22
48
|
|
|
23
|
-
|
|
49
|
+
```bash
|
|
50
|
+
pnpm add vidnavigator
|
|
51
|
+
```
|
|
24
52
|
|
|
25
|
-
|
|
53
|
+
**Requirements:** Node.js 16+ and a [VidNavigator API key](https://vidnavigator.com).
|
|
54
|
+
|
|
55
|
+
## Quick Start
|
|
26
56
|
|
|
27
57
|
```ts
|
|
28
58
|
import { VidNavigatorClient } from 'vidnavigator';
|
|
@@ -32,104 +62,372 @@ const vn = new VidNavigatorClient({
|
|
|
32
62
|
});
|
|
33
63
|
```
|
|
34
64
|
|
|
35
|
-
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Examples
|
|
36
68
|
|
|
37
|
-
###
|
|
69
|
+
### 1. YouTube transcript
|
|
38
70
|
|
|
39
71
|
```ts
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
console.log('First 3 transcript segments:');
|
|
53
|
-
transcript.slice(0, 3).forEach(segment => {
|
|
54
|
-
console.log(` [${segment.start.toFixed(2)}s]: ${segment.text}`);
|
|
55
|
-
});
|
|
56
|
-
} catch (error) {
|
|
57
|
-
console.error('Failed to get transcript:', error);
|
|
58
|
-
}
|
|
72
|
+
const { video_info, transcript } = await vn.getYouTubeTranscript({
|
|
73
|
+
video_url: 'https://youtube.com/watch?v=dQw4w9WgXcQ',
|
|
74
|
+
language: 'en',
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
console.log(video_info.title); // "Rick Astley - Never Gonna Give You Up"
|
|
78
|
+
console.log(video_info.channel); // "Rick Astley"
|
|
79
|
+
console.log(video_info.duration); // 212
|
|
80
|
+
|
|
81
|
+
// Timed segments by default
|
|
82
|
+
for (const seg of transcript.slice(0, 3)) {
|
|
83
|
+
console.log(`[${seg.start.toFixed(1)}s] ${seg.text}`);
|
|
59
84
|
}
|
|
85
|
+
// [0.0s] We're no strangers to love
|
|
86
|
+
// [3.4s] You know the rules and so do I
|
|
87
|
+
// [6.8s] A full commitment's what I'm thinking of
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Pass `transcript_text: true` to get the full transcript as a single plain-text string instead of segments.
|
|
91
|
+
|
|
92
|
+
### 2. Instagram Reel / TikTok / X / Vimeo
|
|
93
|
+
|
|
94
|
+
For any non-YouTube platform, use `getTranscript` (caption-based) or `transcribeVideo` (speech-to-text):
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
// Instagram Reel
|
|
98
|
+
const { video_info, transcript } = await vn.transcribeVideo({
|
|
99
|
+
video_url: 'https://www.instagram.com/reel/C86ZvEaqRmo/',
|
|
100
|
+
});
|
|
101
|
+
console.log(video_info.title);
|
|
102
|
+
console.log(transcript[0].text);
|
|
103
|
+
|
|
104
|
+
// TikTok
|
|
105
|
+
const tiktok = await vn.transcribeVideo({
|
|
106
|
+
video_url: 'https://www.tiktok.com/@user/video/1234567890',
|
|
107
|
+
});
|
|
60
108
|
|
|
61
|
-
|
|
109
|
+
// X / Twitter
|
|
110
|
+
const tweet = await vn.getTranscript({
|
|
111
|
+
video_url: 'https://twitter.com/user/status/1234567890',
|
|
112
|
+
});
|
|
62
113
|
```
|
|
63
114
|
|
|
64
|
-
###
|
|
115
|
+
### 3. Instagram carousel posts (multiple videos)
|
|
116
|
+
|
|
117
|
+
Instagram carousel posts can contain multiple videos. You can select a specific video by index, or transcribe them all at once:
|
|
65
118
|
|
|
66
119
|
```ts
|
|
67
|
-
|
|
120
|
+
// Transcribe the 2nd video in a carousel
|
|
121
|
+
const single = await vn.transcribeVideo({
|
|
122
|
+
video_url: 'https://www.instagram.com/p/ABC123/?img_index=2',
|
|
123
|
+
});
|
|
124
|
+
console.log(single.video_info.title);
|
|
125
|
+
console.log(single.video_info.carousel_info);
|
|
126
|
+
// { total_items: 5, video_count: 3, image_count: 2, selected_index: 2 }
|
|
127
|
+
|
|
128
|
+
// Transcribe ALL videos in a carousel at once
|
|
129
|
+
const all = await vn.transcribeVideo({
|
|
130
|
+
video_url: 'https://www.instagram.com/p/ABC123/',
|
|
131
|
+
all_videos: true,
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
if ('carousel_info' in all) {
|
|
135
|
+
console.log(`${all.carousel_info.transcribed_count} of ${all.carousel_info.video_count} videos transcribed`);
|
|
68
136
|
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
wait_for_completion: true
|
|
77
|
-
});
|
|
78
|
-
console.log(`File '${file_info.name}' uploaded successfully.`);
|
|
79
|
-
|
|
80
|
-
// Analyze the uploaded file
|
|
81
|
-
const { transcript_analysis } = await vn.analyzeFile({
|
|
82
|
-
file_id: file_info.id
|
|
83
|
-
});
|
|
84
|
-
console.log('--- Analysis Summary ---');
|
|
85
|
-
console.log(transcript_analysis.summary);
|
|
86
|
-
|
|
87
|
-
} catch (error) {
|
|
88
|
-
console.error('Operation failed:', error);
|
|
137
|
+
for (const video of all.videos) {
|
|
138
|
+
if (video.status === 'success') {
|
|
139
|
+
console.log(`Video #${video.index}: ${video.video_info.title}`);
|
|
140
|
+
console.log(` Transcript: ${video.transcript[0]?.text}...`);
|
|
141
|
+
} else {
|
|
142
|
+
console.log(`Video #${video.index}: failed — ${video.message}`);
|
|
143
|
+
}
|
|
89
144
|
}
|
|
90
145
|
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### 4. Upload and analyze a local file
|
|
149
|
+
|
|
150
|
+
Upload audio or video files for transcription, analysis, and search. Supported formats: mp4, webm, mov, avi, wmv, flv, mkv, m4a, mp3, mpeg, mpga, wav.
|
|
151
|
+
|
|
152
|
+
```ts
|
|
153
|
+
const upload = await vn.uploadFile({
|
|
154
|
+
filePath: './meeting-recording.mp4',
|
|
155
|
+
wait_for_completion: true,
|
|
156
|
+
namespace_ids: ['ns_meetings'], // optional: file goes into a namespace
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
console.log(upload.file_id); // "64a1b2c3d4e5f6789..."
|
|
160
|
+
console.log(upload.file_name); // "meeting-recording.mp4"
|
|
161
|
+
console.log(upload.file_info.namespace_ids); // ["ns_meetings"]
|
|
162
|
+
|
|
163
|
+
// Analyze with a question
|
|
164
|
+
const { transcript_analysis } = await vn.analyzeFile({
|
|
165
|
+
file_id: upload.file_info.id,
|
|
166
|
+
query: 'What action items were discussed?',
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
console.log(transcript_analysis.summary);
|
|
170
|
+
// "The meeting covered Q3 targets, hiring plans, and a product launch timeline..."
|
|
171
|
+
|
|
172
|
+
console.log(transcript_analysis.people);
|
|
173
|
+
// [{ name: "Sarah", context: "VP of Engineering, presented hiring plan" }, ...]
|
|
174
|
+
|
|
175
|
+
console.log(transcript_analysis.key_subjects);
|
|
176
|
+
// [{ name: "Q3 targets", description: "Revenue goals for...", importance: "high" }, ...]
|
|
177
|
+
|
|
178
|
+
console.log(transcript_analysis.query_answer?.answer);
|
|
179
|
+
// "Three action items were discussed: 1) Finalize the hiring..."
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### 5. Extract structured data
|
|
183
|
+
|
|
184
|
+
Define a schema and get back clean, structured data extracted from any video or file transcript. Powered by LLMs with token usage tracking.
|
|
185
|
+
|
|
186
|
+
```ts
|
|
187
|
+
const { data, usage } = await vn.extractVideoData({
|
|
188
|
+
video_url: 'https://youtube.com/watch?v=dQw4w9WgXcQ',
|
|
189
|
+
schema: {
|
|
190
|
+
topic: { type: 'String', description: 'Main topic of the video' },
|
|
191
|
+
language: { type: 'String', description: 'Primary spoken language (ISO 639-1)' },
|
|
192
|
+
tone: { type: 'Enum', description: 'Overall tone',
|
|
193
|
+
enum: ['positive', 'negative', 'neutral', 'mixed'] },
|
|
194
|
+
key_quotes: { type: 'Array', description: 'Top 3 memorable quotes' },
|
|
195
|
+
},
|
|
196
|
+
what_to_extract: 'Determine the topic, language, tone, and notable quotes.',
|
|
197
|
+
include_usage: true,
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
console.log(data);
|
|
201
|
+
// {
|
|
202
|
+
// topic: "A classic pop love song",
|
|
203
|
+
// language: "en",
|
|
204
|
+
// tone: "positive",
|
|
205
|
+
// key_quotes: ["Never gonna give you up", "Never gonna let you down", ...]
|
|
206
|
+
// }
|
|
207
|
+
|
|
208
|
+
console.log(usage?.total_tokens); // 847
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Also works on uploaded files:
|
|
212
|
+
|
|
213
|
+
```ts
|
|
214
|
+
const { data } = await vn.extractFileData({
|
|
215
|
+
file_id: 'your-file-id',
|
|
216
|
+
schema: {
|
|
217
|
+
action_items: { type: 'Array', description: 'List of action items from the meeting' },
|
|
218
|
+
next_meeting: { type: 'String', description: 'When is the next meeting scheduled?' },
|
|
219
|
+
sentiment: { type: 'Enum', description: 'Overall meeting mood',
|
|
220
|
+
enum: ['productive', 'tense', 'casual', 'urgent'] },
|
|
221
|
+
},
|
|
222
|
+
});
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
**Supported schema types:** `String`, `Number`, `Boolean`, `Integer`, `Object`, `Array`, `Enum`
|
|
226
|
+
|
|
227
|
+
### 6. Semantic search
|
|
228
|
+
|
|
229
|
+
Search across your indexed YouTube channels and uploaded file libraries using AI-powered vector search with reranking.
|
|
230
|
+
|
|
231
|
+
```ts
|
|
232
|
+
// Search indexed YouTube videos
|
|
233
|
+
const videoResults = await vn.searchVideos({
|
|
234
|
+
query: 'how to deploy a Node.js app',
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
console.log(`Found ${videoResults.total_found} results`);
|
|
238
|
+
for (const r of videoResults.results) {
|
|
239
|
+
console.log(`${r.title} — score: ${r.relevance_score}`);
|
|
240
|
+
console.log(` ${r.transcript_summary}`);
|
|
241
|
+
}
|
|
91
242
|
|
|
92
|
-
|
|
243
|
+
// Search uploaded files — optionally scoped to a namespace
|
|
244
|
+
const fileResults = await vn.searchFiles({
|
|
245
|
+
query: 'quarterly revenue discussion',
|
|
246
|
+
namespace_ids: ['ns_finance'],
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
for (const r of fileResults.results) {
|
|
250
|
+
console.log(`${r.name} (score: ${r.relevance_score})`);
|
|
251
|
+
console.log(` Answer: ${r.query_answer}`);
|
|
252
|
+
console.log(` Namespaces: ${r.namespaces?.map(n => n.name).join(', ')}`);
|
|
253
|
+
}
|
|
93
254
|
```
|
|
94
255
|
|
|
256
|
+
### 7. Organize files with namespaces
|
|
257
|
+
|
|
258
|
+
```ts
|
|
259
|
+
// Create a namespace
|
|
260
|
+
const ns = await vn.createNamespace({ name: 'Client Calls' });
|
|
261
|
+
|
|
262
|
+
// Assign a file to namespaces
|
|
263
|
+
const updated = await vn.updateFileNamespaces(fileId, {
|
|
264
|
+
namespace_ids: [ns.id],
|
|
265
|
+
});
|
|
266
|
+
console.log(updated.namespaces);
|
|
267
|
+
// [{ id: "...", name: "Client Calls" }]
|
|
268
|
+
|
|
269
|
+
// List files filtered by namespace
|
|
270
|
+
const files = await vn.getFiles({ namespace_id: ns.id });
|
|
271
|
+
|
|
272
|
+
// List all namespaces
|
|
273
|
+
const all = await vn.getNamespaces();
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### 8. Usage and credits
|
|
277
|
+
|
|
278
|
+
```ts
|
|
279
|
+
const usage = await vn.getUsage();
|
|
280
|
+
|
|
281
|
+
console.log(`Credits remaining: ${usage.credits.monthly_remaining}`);
|
|
282
|
+
console.log(`Video transcripts used: ${usage.usage.videoTranscripts.used}`);
|
|
283
|
+
console.log(`YouTube transcripts used: ${usage.usage.youtubeTranscripts.used}`);
|
|
284
|
+
console.log(`Storage: ${usage.storage.used_formatted} / ${usage.storage.limit_formatted}`);
|
|
285
|
+
console.log(`Channels indexed: ${usage.channelsIndexed.used} / ${usage.channelsIndexed.limit}`);
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
95
290
|
## API Reference
|
|
96
291
|
|
|
97
|
-
All methods return a `Promise
|
|
292
|
+
All methods return a `Promise`. Responses are automatically parsed into typed model classes.
|
|
98
293
|
|
|
99
294
|
### Transcripts
|
|
100
|
-
- `vn.getTranscript(payload)`
|
|
101
295
|
|
|
102
|
-
|
|
103
|
-
|
|
296
|
+
| Method | Description |
|
|
297
|
+
|--------|-------------|
|
|
298
|
+
| `getYouTubeTranscript(payload)` | Get transcript for a YouTube video (fast, caption-based) |
|
|
299
|
+
| `getTranscript(payload)` | Get transcript for non-YouTube videos (Vimeo, X/Twitter, TikTok, etc.) |
|
|
300
|
+
| `transcribeVideo(payload)` | Speech-to-text transcription via AI models; supports Instagram carousel with `all_videos` |
|
|
301
|
+
|
|
302
|
+
**Common options:** `video_url`, `language`, `metadata_only`, `fallback_to_metadata`, `transcript_text`
|
|
104
303
|
|
|
105
304
|
### Files
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
305
|
+
|
|
306
|
+
| Method | Description |
|
|
307
|
+
|--------|-------------|
|
|
308
|
+
| `getFiles(query?)` | List uploaded files (paginated). Filter by `status` or `namespace_id` |
|
|
309
|
+
| `getFile(file_id, query?)` | Get file info and transcript. Pass `transcript_text: true` for plain text |
|
|
310
|
+
| `uploadFile(options)` | Upload audio/video. Options: `filePath`, `wait_for_completion`, `namespace_ids` |
|
|
311
|
+
| `deleteFile(file_id)` | Delete a file |
|
|
312
|
+
| `getFileUrl(file_id)` | Get a signed download URL |
|
|
313
|
+
| `retryFileProcessing(file_id)` | Retry a failed processing job |
|
|
314
|
+
| `cancelFileUpload(file_id)` | Cancel an in-progress upload |
|
|
315
|
+
|
|
316
|
+
**Supported formats:** mp4, webm, mov, avi, wmv, flv, mkv, m4a, mp3, mpeg, mpga, wav
|
|
317
|
+
|
|
318
|
+
### Namespaces
|
|
319
|
+
|
|
320
|
+
| Method | Description |
|
|
321
|
+
|--------|-------------|
|
|
322
|
+
| `getNamespaces()` | List all namespaces |
|
|
323
|
+
| `createNamespace({ name })` | Create a new namespace |
|
|
324
|
+
| `updateNamespace(id, { name })` | Rename a namespace |
|
|
325
|
+
| `deleteNamespace(id)` | Delete a namespace |
|
|
326
|
+
| `updateFileNamespaces(file_id, { namespace_ids })` | Assign a file to namespaces. Returns updated `namespace_ids` and `namespaces` |
|
|
110
327
|
|
|
111
328
|
### Analysis
|
|
112
|
-
|
|
113
|
-
|
|
329
|
+
|
|
330
|
+
| Method | Description |
|
|
331
|
+
|--------|-------------|
|
|
332
|
+
| `analyzeVideo(payload)` | Analyze an online video with an optional natural language query |
|
|
333
|
+
| `analyzeFile(payload)` | Analyze an uploaded file with an optional natural language query |
|
|
334
|
+
|
|
335
|
+
Returns `transcript_analysis` containing:
|
|
336
|
+
- `summary` — content overview
|
|
337
|
+
- `people` — people mentioned (name + context)
|
|
338
|
+
- `places` — locations referenced
|
|
339
|
+
- `key_subjects` — important topics (name, description, importance)
|
|
340
|
+
- `query_answer` — direct answer to your query (when provided) with `answer`, `best_segment_index`, and `relevant_segments`
|
|
341
|
+
|
|
342
|
+
### Extraction
|
|
343
|
+
|
|
344
|
+
| Method | Description |
|
|
345
|
+
|--------|-------------|
|
|
346
|
+
| `extractVideoData(payload)` | Extract structured data from an online video transcript |
|
|
347
|
+
| `extractFileData(payload)` | Extract structured data from an uploaded file transcript |
|
|
348
|
+
|
|
349
|
+
**Options:** `schema` (required), `what_to_extract` (optional guidance), `include_usage` (token tracking)
|
|
350
|
+
|
|
351
|
+
**Schema field types:** `String`, `Number`, `Boolean`, `Integer`, `Object`, `Array`, `Enum`
|
|
114
352
|
|
|
115
353
|
### Search
|
|
116
|
-
- `vn.searchVideos(payload)`
|
|
117
|
-
- `vn.searchFiles(payload)`
|
|
118
354
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
355
|
+
| Method | Description |
|
|
356
|
+
|--------|-------------|
|
|
357
|
+
| `searchVideos(payload)` | Semantic search across indexed YouTube channels |
|
|
358
|
+
| `searchFiles(payload)` | Semantic search across uploaded files, with optional `namespace_ids` scope |
|
|
122
359
|
|
|
123
|
-
|
|
360
|
+
Results include `relevance_score`, `transcript_summary`, `people`, `places`, `key_subjects`, `query_answer`, `timestamps`, and `relevant_text`.
|
|
124
361
|
|
|
362
|
+
### System
|
|
363
|
+
|
|
364
|
+
| Method | Description |
|
|
365
|
+
|--------|-------------|
|
|
366
|
+
| `getUsage()` | Credits, activity counters, storage, channels indexed, subscription info |
|
|
367
|
+
| `healthCheck()` | API health status (no auth required) |
|
|
125
368
|
|
|
126
|
-
##
|
|
369
|
+
## Error Handling
|
|
127
370
|
|
|
128
|
-
|
|
371
|
+
Every API error is mapped to a specific exception class, all extending `VidNavigatorError`:
|
|
129
372
|
|
|
130
|
-
|
|
373
|
+
```ts
|
|
374
|
+
import {
|
|
375
|
+
VidNavigatorClient,
|
|
376
|
+
AuthenticationError,
|
|
377
|
+
NotFoundError,
|
|
378
|
+
RateLimitExceededError,
|
|
379
|
+
} from 'vidnavigator';
|
|
380
|
+
|
|
381
|
+
try {
|
|
382
|
+
await vn.getFile('nonexistent-id');
|
|
383
|
+
} catch (error) {
|
|
384
|
+
if (error instanceof NotFoundError) {
|
|
385
|
+
console.log(error.status_code); // 404
|
|
386
|
+
console.log(error.error_message); // "File not found"
|
|
387
|
+
} else if (error instanceof RateLimitExceededError) {
|
|
388
|
+
console.log('Slow down! Rate limited.');
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
```
|
|
131
392
|
|
|
393
|
+
| Error Class | HTTP | When |
|
|
394
|
+
|-------------|:----:|------|
|
|
395
|
+
| `BadRequestError` | 400 | Invalid parameters |
|
|
396
|
+
| `AuthenticationError` | 401 | Invalid or missing API key |
|
|
397
|
+
| `PaymentRequiredError` | 402 | Credit limit reached |
|
|
398
|
+
| `AccessDeniedError` | 403 | Insufficient permissions |
|
|
399
|
+
| `NotFoundError` | 404 | Resource does not exist |
|
|
400
|
+
| `StorageQuotaExceededError` | 413 | Storage quota exceeded |
|
|
401
|
+
| `RateLimitExceededError` | 429 | Too many requests |
|
|
402
|
+
| `GeoRestrictedError` | 451 | Content unavailable in your region |
|
|
403
|
+
| `ServerError` | 5xx | Unexpected server error |
|
|
404
|
+
| `SystemOverloadError` | 503 | Temporary overload (has `retry_after_seconds`) |
|
|
405
|
+
|
|
406
|
+
## TypeScript Models
|
|
407
|
+
|
|
408
|
+
All API responses are parsed into typed classes with static `fromJSON()` constructors:
|
|
409
|
+
|
|
410
|
+
| Class | Description |
|
|
411
|
+
|-------|-------------|
|
|
412
|
+
| `VideoInfo` | Video metadata: title, channel, duration, views, likes, published date, keywords, carousel info |
|
|
413
|
+
| `FileInfo` | Uploaded file: name, size, type, duration, status, `namespace_ids`, `namespaces` |
|
|
414
|
+
| `TranscriptSegment` | Timed segment: `text`, `start`, `end` (seconds) |
|
|
415
|
+
| `AnalysisResult` | AI analysis: summary, people, places, key subjects, query answer |
|
|
416
|
+
| `Namespace` | Full namespace: id, name, created/updated timestamps |
|
|
417
|
+
| `NamespaceRef` | Lightweight `{ id, name }` reference embedded in file and search responses |
|
|
418
|
+
| `VideoSearchResult` | Extends `VideoInfo` with `relevance_score`, `transcript_summary`, search metadata |
|
|
419
|
+
| `FileSearchResult` | Extends `FileInfo` with `relevance_score`, `query_answer`, timestamps, signed URL |
|
|
420
|
+
| `UsageData` | Credits info, per-service activity counts, storage metrics, subscription details |
|
|
421
|
+
| `ExtractionTokenUsage` | `prompt_tokens`, `completion_tokens`, `total_tokens` |
|
|
422
|
+
| `CarouselInfo` | Carousel summary: total items, video/image count, transcribed count, total duration |
|
|
423
|
+
| `CarouselVideoResult` | Per-video result in a carousel: index, status, video info, transcript |
|
|
424
|
+
|
|
425
|
+
## Links
|
|
426
|
+
|
|
427
|
+
- [VidNavigator Website](https://vidnavigator.com)
|
|
428
|
+
- [API Documentation](https://docs.vidnavigator.com)
|
|
429
|
+
- [GitHub Repository](https://github.com/vidnavigator/vidnavigator-js)
|
|
132
430
|
|
|
133
431
|
## License
|
|
134
432
|
|
|
135
|
-
[Apache-2.0](./LICENSE)
|
|
433
|
+
[Apache-2.0](./LICENSE)
|
package/dist/errors.d.ts
CHANGED
|
@@ -54,3 +54,22 @@ export declare class PaymentRequiredError extends VidNavigatorError {
|
|
|
54
54
|
export declare class ServerError extends VidNavigatorError {
|
|
55
55
|
constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any);
|
|
56
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Raised when storage quota is exceeded (HTTP 413).
|
|
59
|
+
*/
|
|
60
|
+
export declare class StorageQuotaExceededError extends VidNavigatorError {
|
|
61
|
+
constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Raised when content is not available in the user's region (HTTP 451).
|
|
65
|
+
*/
|
|
66
|
+
export declare class GeoRestrictedError extends VidNavigatorError {
|
|
67
|
+
constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Raised when the system is temporarily overloaded (HTTP 503), e.g. extraction overload.
|
|
71
|
+
*/
|
|
72
|
+
export declare class SystemOverloadError extends VidNavigatorError {
|
|
73
|
+
readonly retry_after_seconds?: number;
|
|
74
|
+
constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any, retry_after_seconds?: number);
|
|
75
|
+
}
|
package/dist/errors.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Custom exception classes for VidNavigator SDK.
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ServerError = exports.PaymentRequiredError = exports.RateLimitExceededError = exports.NotFoundError = exports.AccessDeniedError = exports.BadRequestError = exports.AuthenticationError = exports.VidNavigatorError = void 0;
|
|
6
|
+
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
7
|
/**
|
|
8
8
|
* Base class for all VidNavigator SDK errors.
|
|
9
9
|
* Contains additional information from the API response when available.
|
|
@@ -97,3 +97,37 @@ class ServerError extends VidNavigatorError {
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
exports.ServerError = ServerError;
|
|
100
|
+
/**
|
|
101
|
+
* Raised when storage quota is exceeded (HTTP 413).
|
|
102
|
+
*/
|
|
103
|
+
class StorageQuotaExceededError extends VidNavigatorError {
|
|
104
|
+
constructor(message, status_code, error_code, error_message, details) {
|
|
105
|
+
super(message, status_code, error_code, error_message, details);
|
|
106
|
+
this.name = 'StorageQuotaExceededError';
|
|
107
|
+
Object.setPrototypeOf(this, StorageQuotaExceededError.prototype);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
exports.StorageQuotaExceededError = StorageQuotaExceededError;
|
|
111
|
+
/**
|
|
112
|
+
* Raised when content is not available in the user's region (HTTP 451).
|
|
113
|
+
*/
|
|
114
|
+
class GeoRestrictedError extends VidNavigatorError {
|
|
115
|
+
constructor(message, status_code, error_code, error_message, details) {
|
|
116
|
+
super(message, status_code, error_code, error_message, details);
|
|
117
|
+
this.name = 'GeoRestrictedError';
|
|
118
|
+
Object.setPrototypeOf(this, GeoRestrictedError.prototype);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
exports.GeoRestrictedError = GeoRestrictedError;
|
|
122
|
+
/**
|
|
123
|
+
* Raised when the system is temporarily overloaded (HTTP 503), e.g. extraction overload.
|
|
124
|
+
*/
|
|
125
|
+
class SystemOverloadError extends VidNavigatorError {
|
|
126
|
+
constructor(message, status_code, error_code, error_message, details, retry_after_seconds) {
|
|
127
|
+
super(message, status_code, error_code, error_message, details);
|
|
128
|
+
this.name = 'SystemOverloadError';
|
|
129
|
+
this.retry_after_seconds = retry_after_seconds;
|
|
130
|
+
Object.setPrototypeOf(this, SystemOverloadError.prototype);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
exports.SystemOverloadError = SystemOverloadError;
|