vidnavigator 1.0.4 → 2.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 +453 -106
- package/dist/errors.d.ts +37 -0
- package/dist/errors.js +53 -1
- package/dist/http.d.ts +11 -0
- package/dist/http.js +51 -0
- package/dist/index.d.ts +221 -58
- package/dist/index.js +237 -108
- package/dist/jobs.d.ts +92 -0
- package/dist/jobs.js +132 -0
- package/dist/models/AsyncJob.d.ts +92 -0
- package/dist/models/AsyncJob.js +45 -0
- package/dist/models/TikTok.d.ts +54 -0
- package/dist/models/TikTok.js +10 -0
- package/dist/models/TweetStatement.d.ts +4 -0
- package/dist/models/Usage.d.ts +71 -0
- package/dist/models/Usage.js +70 -1
- package/dist/models/index.d.ts +1 -0
- package/dist/models/index.js +1 -0
- package/dist/webhooks.d.ts +63 -0
- package/dist/webhooks.js +98 -0
- package/package.json +1 -1
- package/src/errors.ts +59 -1
- package/src/http.ts +77 -0
- package/src/index.ts +520 -236
- package/src/jobs.ts +215 -0
- package/src/models/AsyncJob.ts +130 -0
- package/src/models/TikTok.ts +521 -448
- package/src/models/TweetStatement.ts +89 -84
- package/src/models/Usage.ts +127 -0
- package/src/models/index.ts +2 -1
- package/src/webhooks.ts +156 -0
package/dist/errors.d.ts
CHANGED
|
@@ -10,6 +10,12 @@ export declare class VidNavigatorError extends Error {
|
|
|
10
10
|
readonly error_code?: string;
|
|
11
11
|
readonly error_message?: string;
|
|
12
12
|
readonly details?: any;
|
|
13
|
+
/**
|
|
14
|
+
* Set on every error raised while submitting, polling, or waiting for an async job once a
|
|
15
|
+
* `task_id` exists. The job keeps running server-side and its result stays readable for 1 hour
|
|
16
|
+
* after it finishes, so keep this id to resume with `vn.<operation>.resume(task_id)`.
|
|
17
|
+
*/
|
|
18
|
+
task_id?: string;
|
|
13
19
|
constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any);
|
|
14
20
|
}
|
|
15
21
|
/**
|
|
@@ -73,3 +79,34 @@ export declare class SystemOverloadError extends VidNavigatorError {
|
|
|
73
79
|
readonly retry_after_seconds?: number;
|
|
74
80
|
constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any, retry_after_seconds?: number);
|
|
75
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Raised when an async job could not be submitted because the account is out of credits
|
|
84
|
+
* (HTTP 402, `limit_exceeded`), e.g. less than 60 seconds of transcription credit left.
|
|
85
|
+
* No task is created. Extends `PaymentRequiredError`.
|
|
86
|
+
*/
|
|
87
|
+
export declare class InsufficientCreditsError extends PaymentRequiredError {
|
|
88
|
+
constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Raised when an async job could not be submitted because too many jobs are already running
|
|
92
|
+
* for this account (HTTP 429, `too_many_active_jobs`). No task is created; retry once some
|
|
93
|
+
* of your running jobs finish. Extends `RateLimitExceededError`.
|
|
94
|
+
*/
|
|
95
|
+
export declare class TooManyActiveJobsError extends RateLimitExceededError {
|
|
96
|
+
constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Raised when waiting for a job exceeds `timeoutMs`. Always carries `task_id`: the job keeps
|
|
100
|
+
* running server-side and its result stays readable for 1 hour after it finishes, so resume it
|
|
101
|
+
* with `vn.<operation>.resume(err.task_id)`.
|
|
102
|
+
*/
|
|
103
|
+
export declare class TaskTimeoutError extends VidNavigatorError {
|
|
104
|
+
constructor(message: string, task_id: string);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Raised by `constructWebhookEvent()` when a webhook delivery's signature is missing,
|
|
108
|
+
* malformed, does not match, or is older than the allowed tolerance.
|
|
109
|
+
*/
|
|
110
|
+
export declare class WebhookSignatureError extends VidNavigatorError {
|
|
111
|
+
constructor(message: string);
|
|
112
|
+
}
|
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.SystemOverloadError = exports.GeoRestrictedError = exports.StorageQuotaExceededError = exports.ServerError = exports.PaymentRequiredError = exports.RateLimitExceededError = exports.NotFoundError = exports.AccessDeniedError = exports.BadRequestError = exports.AuthenticationError = exports.VidNavigatorError = void 0;
|
|
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;
|
|
7
7
|
/**
|
|
8
8
|
* Base class for all VidNavigator SDK errors.
|
|
9
9
|
* Contains additional information from the API response when available.
|
|
@@ -131,3 +131,55 @@ class SystemOverloadError extends VidNavigatorError {
|
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
exports.SystemOverloadError = SystemOverloadError;
|
|
134
|
+
/**
|
|
135
|
+
* Raised when an async job could not be submitted because the account is out of credits
|
|
136
|
+
* (HTTP 402, `limit_exceeded`), e.g. less than 60 seconds of transcription credit left.
|
|
137
|
+
* No task is created. Extends `PaymentRequiredError`.
|
|
138
|
+
*/
|
|
139
|
+
class InsufficientCreditsError extends PaymentRequiredError {
|
|
140
|
+
constructor(message, status_code, error_code, error_message, details) {
|
|
141
|
+
super(message, status_code, error_code, error_message, details);
|
|
142
|
+
this.name = 'InsufficientCreditsError';
|
|
143
|
+
Object.setPrototypeOf(this, InsufficientCreditsError.prototype);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
exports.InsufficientCreditsError = InsufficientCreditsError;
|
|
147
|
+
/**
|
|
148
|
+
* Raised when an async job could not be submitted because too many jobs are already running
|
|
149
|
+
* for this account (HTTP 429, `too_many_active_jobs`). No task is created; retry once some
|
|
150
|
+
* of your running jobs finish. Extends `RateLimitExceededError`.
|
|
151
|
+
*/
|
|
152
|
+
class TooManyActiveJobsError extends RateLimitExceededError {
|
|
153
|
+
constructor(message, status_code, error_code, error_message, details) {
|
|
154
|
+
super(message, status_code, error_code, error_message, details);
|
|
155
|
+
this.name = 'TooManyActiveJobsError';
|
|
156
|
+
Object.setPrototypeOf(this, TooManyActiveJobsError.prototype);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
exports.TooManyActiveJobsError = TooManyActiveJobsError;
|
|
160
|
+
/**
|
|
161
|
+
* Raised when waiting for a job exceeds `timeoutMs`. Always carries `task_id`: the job keeps
|
|
162
|
+
* running server-side and its result stays readable for 1 hour after it finishes, so resume it
|
|
163
|
+
* with `vn.<operation>.resume(err.task_id)`.
|
|
164
|
+
*/
|
|
165
|
+
class TaskTimeoutError extends VidNavigatorError {
|
|
166
|
+
constructor(message, task_id) {
|
|
167
|
+
super(message);
|
|
168
|
+
this.name = 'TaskTimeoutError';
|
|
169
|
+
this.task_id = task_id;
|
|
170
|
+
Object.setPrototypeOf(this, TaskTimeoutError.prototype);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
exports.TaskTimeoutError = TaskTimeoutError;
|
|
174
|
+
/**
|
|
175
|
+
* Raised by `constructWebhookEvent()` when a webhook delivery's signature is missing,
|
|
176
|
+
* malformed, does not match, or is older than the allowed tolerance.
|
|
177
|
+
*/
|
|
178
|
+
class WebhookSignatureError extends VidNavigatorError {
|
|
179
|
+
constructor(message) {
|
|
180
|
+
super(message);
|
|
181
|
+
this.name = 'WebhookSignatureError';
|
|
182
|
+
Object.setPrototypeOf(this, WebhookSignatureError.prototype);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
exports.WebhookSignatureError = WebhookSignatureError;
|
package/dist/http.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal: maps API error responses to SDK error classes. Not re-exported from the package.
|
|
3
|
+
*/
|
|
4
|
+
import { VidNavigatorError } from './errors';
|
|
5
|
+
export declare function parseApiErrorPayload(data: any): {
|
|
6
|
+
errorCode?: string;
|
|
7
|
+
errorMessage?: string;
|
|
8
|
+
details?: any;
|
|
9
|
+
};
|
|
10
|
+
/** Map an HTTP error status + body to the matching SDK error class. */
|
|
11
|
+
export declare function buildApiError(status: number, data: any, fallbackMessage?: string): VidNavigatorError;
|
package/dist/http.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseApiErrorPayload = parseApiErrorPayload;
|
|
4
|
+
exports.buildApiError = buildApiError;
|
|
5
|
+
/**
|
|
6
|
+
* Internal: maps API error responses to SDK error classes. Not re-exported from the package.
|
|
7
|
+
*/
|
|
8
|
+
const errors_1 = require("./errors");
|
|
9
|
+
function parseApiErrorPayload(data) {
|
|
10
|
+
const errorField = data?.error;
|
|
11
|
+
const errorCode = (typeof errorField === 'string' ? errorField : errorField?.code) ?? data?.error_code;
|
|
12
|
+
const errorMessage = data?.message ??
|
|
13
|
+
(typeof errorField === 'object' ? errorField?.message : undefined);
|
|
14
|
+
return { errorCode, errorMessage, details: data };
|
|
15
|
+
}
|
|
16
|
+
/** Map an HTTP error status + body to the matching SDK error class. */
|
|
17
|
+
function buildApiError(status, data, fallbackMessage) {
|
|
18
|
+
const { errorCode, errorMessage, details } = parseApiErrorPayload(data);
|
|
19
|
+
const message = `API request failed with status ${status}: ${errorMessage || fallbackMessage}`;
|
|
20
|
+
switch (status) {
|
|
21
|
+
case 400:
|
|
22
|
+
return new errors_1.BadRequestError(message, status, errorCode, errorMessage, details);
|
|
23
|
+
case 401:
|
|
24
|
+
return new errors_1.AuthenticationError(message, status, errorCode, errorMessage, details);
|
|
25
|
+
case 402:
|
|
26
|
+
if (errorCode === 'limit_exceeded') {
|
|
27
|
+
return new errors_1.InsufficientCreditsError(message, status, errorCode, errorMessage, details);
|
|
28
|
+
}
|
|
29
|
+
return new errors_1.PaymentRequiredError(message, status, errorCode, errorMessage, details);
|
|
30
|
+
case 403:
|
|
31
|
+
return new errors_1.AccessDeniedError(message, status, errorCode, errorMessage, details);
|
|
32
|
+
case 404:
|
|
33
|
+
return new errors_1.NotFoundError(message, status, errorCode, errorMessage, details);
|
|
34
|
+
case 413:
|
|
35
|
+
return new errors_1.StorageQuotaExceededError(message, status, errorCode, errorMessage, details);
|
|
36
|
+
case 429:
|
|
37
|
+
if (errorCode === 'too_many_active_jobs') {
|
|
38
|
+
return new errors_1.TooManyActiveJobsError(message, status, errorCode, errorMessage, details);
|
|
39
|
+
}
|
|
40
|
+
return new errors_1.RateLimitExceededError(message, status, errorCode, errorMessage, details);
|
|
41
|
+
case 451:
|
|
42
|
+
return new errors_1.GeoRestrictedError(message, status, errorCode, errorMessage, details);
|
|
43
|
+
case 503:
|
|
44
|
+
return new errors_1.SystemOverloadError(message, status, errorCode, errorMessage, details, data?.retry_after_seconds);
|
|
45
|
+
default:
|
|
46
|
+
if (status >= 500) {
|
|
47
|
+
return new errors_1.ServerError(message, status, errorCode, errorMessage, details);
|
|
48
|
+
}
|
|
49
|
+
return new errors_1.VidNavigatorError(message, status, errorCode, errorMessage, details);
|
|
50
|
+
}
|
|
51
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { AxiosRequestConfig } from 'axios';
|
|
2
|
-
import { VideoInfo, TranscriptOutput, FileInfo, AnalysisResult, VideoSearchResult, FileSearchResult, UsageData, Namespace, NamespaceRef, ExtractionSchema,
|
|
2
|
+
import { VideoInfo, TranscriptOutput, FileInfo, AnalysisResult, VideoSearchResult, FileSearchResult, UsageData, Namespace, NamespaceRef, ExtractionSchema, UsageBlock, CarouselInfo, CarouselVideoResult, TikTokProfileScrapeRequest, TikTokProfileScrapeSubmission, TikTokProfileTask, TikTokSearchRequest, TikTokSearchSubmission, TikTokSearchTask, TweetStatement, AsyncJob } from './models';
|
|
3
|
+
import { Job, JobOperation, PollOptions, RunOptions, SubmitOptions } from './jobs';
|
|
3
4
|
export * from './models';
|
|
4
5
|
export * from './errors';
|
|
6
|
+
export * from './webhooks';
|
|
7
|
+
export { Job } from './jobs';
|
|
8
|
+
export type { TaskStatus, PollableTask, PollOptions, JobOperation, SubmitOptions, RunOptions, JobInfo } from './jobs';
|
|
5
9
|
/** SDK version (keep in sync with package.json) */
|
|
6
|
-
export declare const SDK_VERSION = "
|
|
10
|
+
export declare const SDK_VERSION = "2.0.0";
|
|
7
11
|
export interface SDKConfig {
|
|
8
12
|
apiKey: string;
|
|
9
13
|
baseURL?: string;
|
|
@@ -15,21 +19,90 @@ export type TranscriptRequestPayload = {
|
|
|
15
19
|
metadata_only?: boolean;
|
|
16
20
|
fallback_to_metadata?: boolean;
|
|
17
21
|
transcript_text?: boolean;
|
|
22
|
+
include_usage?: boolean;
|
|
18
23
|
};
|
|
19
24
|
export type TranscribeVideoPayload = {
|
|
20
25
|
video_url: string;
|
|
21
26
|
transcript_text?: boolean;
|
|
22
27
|
all_videos?: boolean;
|
|
28
|
+
include_usage?: boolean;
|
|
29
|
+
} & WebhookOption;
|
|
30
|
+
/**
|
|
31
|
+
* Where to POST a notification when an async job finishes. Overrides the account-level default
|
|
32
|
+
* configured in Studio → API; pass an empty string to opt this job out of that default.
|
|
33
|
+
* Must be a publicly reachable https URL. This is a pass-through: polling always works either way.
|
|
34
|
+
*/
|
|
35
|
+
export type WebhookOption = {
|
|
36
|
+
webhook_url?: string;
|
|
37
|
+
};
|
|
38
|
+
/** Input for {@link VidNavigatorClient.transcribe}. A plain string is treated as `video_url`. */
|
|
39
|
+
export type TranscribeInput = {
|
|
40
|
+
video_url: string;
|
|
41
|
+
transcript_text?: boolean;
|
|
42
|
+
/** Instagram carousel posts only: transcribe every video in the post. */
|
|
43
|
+
all_videos?: boolean;
|
|
44
|
+
} & WebhookOption;
|
|
45
|
+
/** Input for {@link VidNavigatorClient.extractVideo}: a JSON `schema`, or a JSON/YAML `schemaFilePath`. */
|
|
46
|
+
export type ExtractVideoInput = ({
|
|
47
|
+
video_url: string;
|
|
48
|
+
schema: ExtractionSchema;
|
|
49
|
+
what_to_extract?: string;
|
|
50
|
+
/** Speech-to-text the audio when no platform transcript exists. Default true. */
|
|
51
|
+
transcribe?: boolean;
|
|
52
|
+
} & WebhookOption) | ({
|
|
53
|
+
video_url: string;
|
|
54
|
+
/** Path to a JSON or YAML schema file (sent as multipart form-data). */
|
|
55
|
+
schemaFilePath: string;
|
|
56
|
+
what_to_extract?: string;
|
|
57
|
+
transcribe?: boolean;
|
|
58
|
+
} & WebhookOption);
|
|
59
|
+
/** Input for {@link VidNavigatorClient.tweetStatement}. A plain string is treated as `tweet_id`. */
|
|
60
|
+
export type TweetStatementInput = {
|
|
61
|
+
tweet_id: string;
|
|
62
|
+
} & WebhookOption;
|
|
63
|
+
export type TranscriptResult = {
|
|
64
|
+
video_info: VideoInfo;
|
|
65
|
+
transcript: TranscriptOutput;
|
|
66
|
+
usage?: UsageBlock;
|
|
23
67
|
};
|
|
24
68
|
export type TranscribeVideoSingleResult = {
|
|
25
69
|
video_info: VideoInfo;
|
|
26
70
|
transcript: TranscriptOutput;
|
|
71
|
+
usage?: UsageBlock;
|
|
27
72
|
};
|
|
28
73
|
export type TranscribeVideoCarouselResult = {
|
|
29
74
|
carousel_info: CarouselInfo;
|
|
30
75
|
videos: CarouselVideoResult[];
|
|
76
|
+
usage?: UsageBlock;
|
|
31
77
|
};
|
|
32
78
|
export type TranscribeVideoResult = TranscribeVideoSingleResult | TranscribeVideoCarouselResult;
|
|
79
|
+
/** Snapshot of a transcription task. `result` has the same shape as {@link VidNavigatorClient.transcribe}'s return value. */
|
|
80
|
+
export type TranscribeAsyncJob = AsyncJob<TranscribeVideoResult>;
|
|
81
|
+
/** Snapshot of an extraction task. `result` is the extracted object, shaped like your schema. */
|
|
82
|
+
export type ExtractVideoAsyncJob = AsyncJob<Record<string, unknown>>;
|
|
83
|
+
/** Snapshot of a tweet claim analysis task. `result` is a {@link TweetStatement}. */
|
|
84
|
+
export type TweetStatementAsyncJob = AsyncJob<TweetStatement>;
|
|
85
|
+
export type TranscribeJob = Job<TranscribeAsyncJob, TranscribeVideoResult>;
|
|
86
|
+
/** Input that always yields a single-video result (the carousel shape needs `all_videos: true`). */
|
|
87
|
+
type SingleTranscribeInput = string | (TranscribeInput & {
|
|
88
|
+
all_videos?: false;
|
|
89
|
+
});
|
|
90
|
+
/**
|
|
91
|
+
* {@link JobOperation} for transcription, typed so that a plain URL (or `all_videos` left off)
|
|
92
|
+
* resolves to {@link TranscribeVideoSingleResult}.
|
|
93
|
+
*/
|
|
94
|
+
export interface TranscribeOperation extends JobOperation<string | TranscribeInput, TranscribeAsyncJob, TranscribeVideoResult> {
|
|
95
|
+
(input: SingleTranscribeInput, options?: RunOptions<TranscribeAsyncJob>): Promise<TranscribeVideoSingleResult>;
|
|
96
|
+
(input: string | TranscribeInput, options?: RunOptions<TranscribeAsyncJob>): Promise<TranscribeVideoResult>;
|
|
97
|
+
submit(input: SingleTranscribeInput, options?: SubmitOptions): Promise<Job<TranscribeAsyncJob, TranscribeVideoSingleResult>>;
|
|
98
|
+
submit(input: string | TranscribeInput, options?: SubmitOptions): Promise<Job<TranscribeAsyncJob, TranscribeVideoResult>>;
|
|
99
|
+
}
|
|
100
|
+
export type ExtractVideoJob = Job<ExtractVideoAsyncJob, ExtractDataResult>;
|
|
101
|
+
export type TweetStatementJob = Job<TweetStatementAsyncJob, TweetStatement>;
|
|
102
|
+
/** `result()` resolves to the completed task with **all** pages of `videos` collected. */
|
|
103
|
+
export type TikTokProfileJob = Job<TikTokProfileTask, TikTokProfileTask>;
|
|
104
|
+
/** `result()` resolves to the completed task with **all** pages of `results` collected. */
|
|
105
|
+
export type TikTokSearchJob = Job<TikTokSearchTask, TikTokSearchTask>;
|
|
33
106
|
export type UploadFileSuccessResult = {
|
|
34
107
|
status: 'success';
|
|
35
108
|
file_id: string;
|
|
@@ -52,15 +125,73 @@ export interface ExtractDataResult {
|
|
|
52
125
|
data: Record<string, unknown>;
|
|
53
126
|
video_info?: VideoInfo;
|
|
54
127
|
file_info?: FileInfo;
|
|
55
|
-
usage?:
|
|
128
|
+
usage?: UsageBlock;
|
|
56
129
|
}
|
|
130
|
+
export type YouTubeSearchFocus = 'relevance' | 'popularity' | 'brevity';
|
|
131
|
+
export type SearchYouTubePayload = {
|
|
132
|
+
query: string;
|
|
133
|
+
use_enhanced_search?: boolean;
|
|
134
|
+
start_year?: number;
|
|
135
|
+
end_year?: number;
|
|
136
|
+
focus?: YouTubeSearchFocus;
|
|
137
|
+
duration?: number;
|
|
138
|
+
max_results?: number;
|
|
139
|
+
include_usage?: boolean;
|
|
140
|
+
};
|
|
141
|
+
export type SearchYouTubeResult = {
|
|
142
|
+
results: VideoSearchResult[];
|
|
143
|
+
query: string;
|
|
144
|
+
total_found: number;
|
|
145
|
+
explanation?: string;
|
|
146
|
+
usage?: UsageBlock;
|
|
147
|
+
/** Present when a 402 partial-results response is returned. */
|
|
148
|
+
status?: 'success' | 'partial';
|
|
149
|
+
/** Present on partial results (e.g. `insufficient_credits_video_search`). */
|
|
150
|
+
error_code?: string;
|
|
151
|
+
};
|
|
152
|
+
export type SearchFilesPayload = {
|
|
153
|
+
query: string;
|
|
154
|
+
namespace_ids?: string[];
|
|
155
|
+
include_usage?: boolean;
|
|
156
|
+
};
|
|
157
|
+
export type SearchFilesResult = {
|
|
158
|
+
results: FileSearchResult[];
|
|
159
|
+
query: string;
|
|
160
|
+
total_found: number;
|
|
161
|
+
explanation?: string;
|
|
162
|
+
usage?: UsageBlock;
|
|
163
|
+
};
|
|
164
|
+
export type AnalyzeVideoPayload = {
|
|
165
|
+
video_url: string;
|
|
166
|
+
query?: string;
|
|
167
|
+
transcript_text?: boolean;
|
|
168
|
+
include_usage?: boolean;
|
|
169
|
+
};
|
|
170
|
+
export type AnalyzeFilePayload = {
|
|
171
|
+
file_id: string;
|
|
172
|
+
query?: string;
|
|
173
|
+
transcript_text?: boolean;
|
|
174
|
+
include_usage?: boolean;
|
|
175
|
+
};
|
|
176
|
+
export type AnalyzeVideoResult = {
|
|
177
|
+
video_info: VideoInfo;
|
|
178
|
+
transcript: TranscriptOutput;
|
|
179
|
+
transcript_analysis: AnalysisResult;
|
|
180
|
+
usage?: UsageBlock;
|
|
181
|
+
};
|
|
182
|
+
export type AnalyzeFileResult = {
|
|
183
|
+
file_info: FileInfo;
|
|
184
|
+
transcript: TranscriptOutput;
|
|
185
|
+
transcript_analysis: AnalysisResult;
|
|
186
|
+
usage?: UsageBlock;
|
|
187
|
+
};
|
|
57
188
|
export type ExtractVideoDataPayload = {
|
|
58
189
|
video_url: string;
|
|
59
190
|
schema: ExtractionSchema;
|
|
60
191
|
what_to_extract?: string;
|
|
61
192
|
transcribe?: boolean;
|
|
62
193
|
include_usage?: boolean;
|
|
63
|
-
};
|
|
194
|
+
} & WebhookOption;
|
|
64
195
|
export type ExtractVideoDataMultipartPayload = {
|
|
65
196
|
video_url: string;
|
|
66
197
|
/** Path to a JSON or YAML schema file. The API accepts either a raw schema or a full extraction request object. */
|
|
@@ -68,7 +199,10 @@ export type ExtractVideoDataMultipartPayload = {
|
|
|
68
199
|
what_to_extract?: string;
|
|
69
200
|
transcribe?: boolean;
|
|
70
201
|
include_usage?: boolean;
|
|
71
|
-
};
|
|
202
|
+
} & WebhookOption;
|
|
203
|
+
export type TweetStatementPayload = {
|
|
204
|
+
tweet_id: string;
|
|
205
|
+
} & WebhookOption;
|
|
72
206
|
export type ExtractFileDataPayload = {
|
|
73
207
|
file_id: string;
|
|
74
208
|
schema: ExtractionSchema;
|
|
@@ -84,26 +218,69 @@ export type ExtractFileDataMultipartPayload = {
|
|
|
84
218
|
};
|
|
85
219
|
export declare class VidNavigatorClient {
|
|
86
220
|
private client;
|
|
221
|
+
/**
|
|
222
|
+
* Speech-to-text transcription of any length (Instagram, TikTok, X, Facebook, Vimeo, ...),
|
|
223
|
+
* built on `POST /transcribe/async`.
|
|
224
|
+
*
|
|
225
|
+
* - `await vn.transcribe(url)` submits, polls, and returns the result.
|
|
226
|
+
* - `await vn.transcribe.submit(url)` returns a {@link Job} handle right away.
|
|
227
|
+
* - `vn.transcribe.resume(task_id)` reattaches to a job you already submitted.
|
|
228
|
+
*/
|
|
229
|
+
readonly transcribe: TranscribeOperation;
|
|
230
|
+
/**
|
|
231
|
+
* Structured-data extraction from a video of any length, built on `POST /extract/video/async`.
|
|
232
|
+
* The schema is validated when you submit. Same shapes as {@link VidNavigatorClient.transcribe}.
|
|
233
|
+
*/
|
|
234
|
+
readonly extractVideo: JobOperation<ExtractVideoInput, ExtractVideoAsyncJob, ExtractDataResult>;
|
|
235
|
+
/**
|
|
236
|
+
* Structured claim analysis of an X/Twitter tweet (attached media of any length), built on
|
|
237
|
+
* `POST /tweet/statement/async`. Same shapes as {@link VidNavigatorClient.transcribe}.
|
|
238
|
+
*/
|
|
239
|
+
readonly tweetStatement: JobOperation<string | TweetStatementInput, TweetStatementAsyncJob, TweetStatement>;
|
|
240
|
+
/**
|
|
241
|
+
* TikTok profile scrape, built on `POST /tiktok/profile`. The result is the completed task with
|
|
242
|
+
* every page of `videos` collected. Same shapes as {@link VidNavigatorClient.transcribe}.
|
|
243
|
+
*/
|
|
244
|
+
readonly tiktokProfile: JobOperation<string | TikTokProfileScrapeRequest, TikTokProfileTask, TikTokProfileTask>;
|
|
245
|
+
/**
|
|
246
|
+
* TikTok keyword search, built on `POST /tiktok/search`. The result is the completed task with
|
|
247
|
+
* every page of `results` collected. Same shapes as {@link VidNavigatorClient.transcribe}.
|
|
248
|
+
*/
|
|
249
|
+
readonly tiktokSearch: JobOperation<string | TikTokSearchRequest, TikTokSearchTask, TikTokSearchTask>;
|
|
87
250
|
constructor(config: SDKConfig);
|
|
251
|
+
private defineOperation;
|
|
252
|
+
private submitAsyncJob;
|
|
253
|
+
private submitExtractVideo;
|
|
254
|
+
private getAsyncJob;
|
|
88
255
|
private request;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
256
|
+
/**
|
|
257
|
+
* Get a transcript for any supported video. The endpoint auto-detects the
|
|
258
|
+
* platform (YouTube, Vimeo, X/Twitter, TikTok, Facebook, Dailymotion, Loom, etc.)
|
|
259
|
+
* from `video_url`. For Instagram, use {@link VidNavigatorClient.transcribeVideo}.
|
|
260
|
+
*/
|
|
261
|
+
getTranscript(payload: TranscriptRequestPayload): Promise<TranscriptResult>;
|
|
262
|
+
/**
|
|
263
|
+
* @deprecated There is now a single `/transcript` endpoint that auto-detects the
|
|
264
|
+
* platform. Use {@link VidNavigatorClient.getTranscript} instead. This alias
|
|
265
|
+
* forwards to `getTranscript` and will be removed in a future release.
|
|
266
|
+
*/
|
|
267
|
+
getYouTubeTranscript(payload: TranscriptRequestPayload): Promise<TranscriptResult>;
|
|
268
|
+
/**
|
|
269
|
+
* Speech-to-text transcription. Blocking convenience wrapper around {@link VidNavigatorClient.transcribe}:
|
|
270
|
+
* submits to `POST /transcribe/async` and polls until the job finishes, so media of any length works.
|
|
271
|
+
*/
|
|
272
|
+
transcribeVideo(payload: TranscribeVideoPayload, options?: PollOptions<TranscribeAsyncJob>): Promise<TranscribeVideoResult>;
|
|
98
273
|
submitTikTokProfileScrape(payload: TikTokProfileScrapeRequest): Promise<TikTokProfileScrapeSubmission>;
|
|
99
274
|
getTikTokProfileScrape(task_id: string, query?: {
|
|
100
275
|
cursor?: string;
|
|
101
276
|
limit?: number;
|
|
277
|
+
include_usage?: boolean;
|
|
102
278
|
}): Promise<TikTokProfileTask>;
|
|
103
279
|
submitTikTokSearch(payload: TikTokSearchRequest): Promise<TikTokSearchSubmission>;
|
|
104
280
|
getTikTokSearch(task_id: string, query?: {
|
|
105
281
|
cursor?: string;
|
|
106
282
|
limit?: number;
|
|
283
|
+
include_usage?: boolean;
|
|
107
284
|
}): Promise<TikTokSearchTask>;
|
|
108
285
|
getFiles(query?: {
|
|
109
286
|
limit?: number;
|
|
@@ -167,51 +344,37 @@ export declare class VidNavigatorClient {
|
|
|
167
344
|
namespace_ids: string[];
|
|
168
345
|
namespaces: NamespaceRef[];
|
|
169
346
|
}>;
|
|
170
|
-
analyzeVideo(payload:
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
file_info: FileInfo;
|
|
185
|
-
transcript: TranscriptOutput;
|
|
186
|
-
transcript_analysis: AnalysisResult;
|
|
187
|
-
}>;
|
|
188
|
-
getTweetStatement(payload: {
|
|
189
|
-
tweet_id: string;
|
|
190
|
-
}): Promise<TweetStatement>;
|
|
191
|
-
extractVideoData(payload: ExtractVideoDataPayload | ExtractVideoDataMultipartPayload): Promise<ExtractDataResult>;
|
|
347
|
+
analyzeVideo(payload: AnalyzeVideoPayload): Promise<AnalyzeVideoResult>;
|
|
348
|
+
analyzeFile(payload: AnalyzeFilePayload): Promise<AnalyzeFileResult>;
|
|
349
|
+
/**
|
|
350
|
+
* Structured claim analysis of an X/Twitter tweet. Blocking convenience wrapper around
|
|
351
|
+
* {@link VidNavigatorClient.tweetStatement}: submits to `POST /tweet/statement/async` and polls.
|
|
352
|
+
*/
|
|
353
|
+
getTweetStatement(payload: TweetStatementPayload, options?: RunOptions<TweetStatementAsyncJob>): Promise<TweetStatement>;
|
|
354
|
+
/**
|
|
355
|
+
* Structured-data extraction from an online video. Blocking convenience wrapper around
|
|
356
|
+
* {@link VidNavigatorClient.extractVideo}: submits to `POST /extract/video/async` and polls, so
|
|
357
|
+
* media of any length works. The async API does not return `video_info`; use
|
|
358
|
+
* {@link VidNavigatorClient.getTranscript} with `metadata_only: true` if you need it.
|
|
359
|
+
*/
|
|
360
|
+
extractVideoData(payload: ExtractVideoDataPayload | ExtractVideoDataMultipartPayload, options?: PollOptions<ExtractVideoAsyncJob>): Promise<ExtractDataResult>;
|
|
192
361
|
extractFileData(payload: ExtractFileDataPayload | ExtractFileDataMultipartPayload): Promise<ExtractDataResult>;
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}): Promise<{
|
|
210
|
-
results: FileSearchResult[];
|
|
211
|
-
query: string;
|
|
212
|
-
total_found: number;
|
|
213
|
-
explanation?: string;
|
|
214
|
-
}>;
|
|
362
|
+
/**
|
|
363
|
+
* Search YouTube for videos with AI analysis and ranking.
|
|
364
|
+
*
|
|
365
|
+
* If the account runs out of `residential_request` credits mid-search, the API
|
|
366
|
+
* returns HTTP 402 with `status: "partial"` and the videos analysed so far. The
|
|
367
|
+
* SDK surfaces that partial payload (results, `status: "partial"`, `error_code`,
|
|
368
|
+
* and `usage` when requested) instead of throwing.
|
|
369
|
+
*/
|
|
370
|
+
searchYouTube(payload: SearchYouTubePayload): Promise<SearchYouTubeResult>;
|
|
371
|
+
/**
|
|
372
|
+
* @deprecated `/search/video` moved to `/youtube/search`. Use
|
|
373
|
+
* {@link VidNavigatorClient.searchYouTube} instead. This alias forwards to
|
|
374
|
+
* `searchYouTube` and will be removed in a future release.
|
|
375
|
+
*/
|
|
376
|
+
searchVideos(payload: SearchYouTubePayload): Promise<SearchYouTubeResult>;
|
|
377
|
+
searchFiles(payload: SearchFilesPayload): Promise<SearchFilesResult>;
|
|
215
378
|
getUsage(): Promise<UsageData>;
|
|
216
379
|
healthCheck(): Promise<{
|
|
217
380
|
status?: string;
|