vidnavigator 3.0.1 → 3.0.2
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 +17 -5
- package/dist/errors.d.ts +4 -2
- package/dist/errors.js +4 -2
- package/dist/http.js +3 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/models/TikTok.d.ts +2 -1
- package/dist/models/Usage.d.ts +36 -8
- package/dist/models/Usage.js +11 -5
- package/package.json +1 -1
- package/src/errors.ts +4 -2
- package/src/http.ts +3 -0
- package/src/index.ts +1 -1
- package/src/models/TikTok.ts +2 -1
- package/src/models/Usage.ts +48 -13
package/README.md
CHANGED
|
@@ -563,7 +563,7 @@ for (const room of task.results) {
|
|
|
563
563
|
- Each room has the same `id`, `url`, `author` and `stats` fields as a keyword search result, plus `started_at` (a `Date`), `stats.viewers` / `stats.total_viewers`, `hashtags` (the `#tags` of the title), `category` (the LIVE's category on TikTok, e.g. `'Gaming'`) and `game_tags`.
|
|
564
564
|
- `stream_urls` holds `flv` and `hls` URLs keyed by quality (`origin`, `uhd`, `hd`, `sd`, `ld`), `default_quality`, an `audio_only` stream and `expires_at`. The URLs play while the LIVE is on. They are returned by default; pass `include_stream_urls: false` to leave them out. Not every LIVE offers HLS, so `hls` can be empty.
|
|
565
565
|
- `country` defaults to `'us'`. Results keep TikTok's ranking; a keyword with no LIVE room in that country at that moment completes with zero results.
|
|
566
|
-
- Billing: 1 `residential_request` per 30 rooms returned (`task.stats.results_count`), minimum 1 per search.
|
|
566
|
+
- Billing: 1 `residential_request` per 30 rooms returned (`task.stats.results_count`), minimum 1 per search and 1 per 5 TikTok pages read (`task.stats.pages_fetched`).
|
|
567
567
|
|
|
568
568
|
### 6c. TikTok LIVE room (sync)
|
|
569
569
|
|
|
@@ -907,10 +907,15 @@ const usage = await vn.getUsage();
|
|
|
907
907
|
console.log(`Credits remaining: ${usage.credits.monthly_remaining}`);
|
|
908
908
|
console.log(`Transcription hours used: ${usage.usage.transcriptionHour?.used}`);
|
|
909
909
|
console.log(`Standard requests used: ${usage.usage.standardRequest?.used}`);
|
|
910
|
+
console.log(`Frames analyzed: ${usage.usage.frameAnalysis?.used}`);
|
|
911
|
+
console.log(`Scene analysis hours: ${usage.usage.sceneAnalysisHour?.used}`);
|
|
910
912
|
console.log(`Storage: ${usage.storage.usedFormatted} / ${usage.storage.limitFormatted}`);
|
|
911
913
|
console.log(`Channels indexed: ${usage.channelsIndexed.used} / ${usage.channelsIndexed.limit}`);
|
|
914
|
+
console.log(`Period ends: ${usage.billingPeriod.end?.toISOString() ?? 'no subscription period'}`);
|
|
912
915
|
```
|
|
913
916
|
|
|
917
|
+
`usage.usage` has one counter per meter: `standardRequest`, `residentialRequest`, `searchRequest`, `analysisRequest`, `sceneAnalysisHour`, `transcriptionHour` and `frameAnalysis`. The older `videoTranscripts`, `youtubeTranscripts`, `videoSearches`, `videoAnalyses`, `videoSceneAnalyses` and `videoUploads` are deprecated: the API no longer sends them. `usagePeriod` and `billingPeriod` have `start` and `end` as `Date`s, or `undefined` when the account has no subscription period.
|
|
918
|
+
|
|
914
919
|
### Per-call usage
|
|
915
920
|
|
|
916
921
|
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.
|
|
@@ -925,7 +930,7 @@ const { usage } = await vn.getTranscript({
|
|
|
925
930
|
|
|
926
931
|
if (usage) {
|
|
927
932
|
console.log(usage.total_credits); // net credits deducted by this request
|
|
928
|
-
console.log(usage.credits_remaining_after); //
|
|
933
|
+
console.log(usage.credits_remaining_after); // credits left after the request (undefined without a credit limit)
|
|
929
934
|
|
|
930
935
|
// Every meter that fired, consolidated to one entry per service_type:
|
|
931
936
|
for (const charge of usage.charges) {
|
|
@@ -939,6 +944,8 @@ if (usage) {
|
|
|
939
944
|
}
|
|
940
945
|
```
|
|
941
946
|
|
|
947
|
+
`credits_remaining_after` is the number of credits left on the account (monthly + purchased) after this request's charges. It is `undefined` on plans without a credit limit, where the API leaves it out.
|
|
948
|
+
|
|
942
949
|
`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`.
|
|
943
950
|
|
|
944
951
|
---
|
|
@@ -1061,7 +1068,7 @@ With `include_scenes: true`, the `TweetStatement` also has `frames_analyzed`, an
|
|
|
1061
1068
|
| `searchVideos(payload)` | **Deprecated** — forwards to `searchYouTube()` |
|
|
1062
1069
|
| `searchFiles(payload)` | Semantic search across uploaded files, with optional `namespace_ids` scope |
|
|
1063
1070
|
|
|
1064
|
-
**`searchYouTube` options:** `query` (required), `use_enhanced_search` (default `true`), `start_year` / `end_year` (only videos published in or after / in or before that year), `focus` (what comes first among the matches: `'relevance'` (default) \| `'recency'` \| `'popularity'` \| `'brevity'`), `duration` (maximum length in seconds; longer videos are left out), `max_results` (caps candidates analysed & cost; defaults to your plan ceiling), `include_usage`.
|
|
1071
|
+
**`searchYouTube` options:** `query` (required), `use_enhanced_search` (default `false`: the slower enhanced search runs only when you pass `true`), `start_year` / `end_year` (only videos published in or after / in or before that year), `focus` (what comes first among the matches: `'relevance'` (default) \| `'recency'` \| `'popularity'` \| `'brevity'`), `duration` (maximum length in seconds; longer videos are left out), `max_results` (caps candidates analysed & cost; defaults to your plan ceiling), `include_usage`.
|
|
1065
1072
|
|
|
1066
1073
|
Results include `relevance_score`, `transcript_summary`, `people`, `places`, `key_subjects`, `query_answer`, `timestamps`, and `relevant_text`. If credits run out mid-search the API returns a partial result: `searchYouTube` surfaces it as `{ status: 'partial', error_code: 'insufficient_credits_video_search', results, usage? }` instead of throwing.
|
|
1067
1074
|
|
|
@@ -1105,7 +1112,7 @@ try {
|
|
|
1105
1112
|
| `AccessDeniedError` | 403 | Insufficient permissions |
|
|
1106
1113
|
| `NotFoundError` | 404 | Resource does not exist, or a job's `task_id` is unknown or expired (`task_not_found`) |
|
|
1107
1114
|
| `ScenesNotAvailableError` | 409 | `include_scenes` was asked on an uploaded file that has no scenes to read (`scenes_not_available`). Has `scenes_status` (`'none'`, `'processing'` or `'failed'`) and, when failed, `scenes_error` |
|
|
1108
|
-
| `StorageQuotaExceededError` |
|
|
1115
|
+
| `StorageQuotaExceededError` | 402 | The storage of the plan is full (`storage_quota_exceeded`, on upload). A `PaymentRequiredError`, from 3.0.2 |
|
|
1109
1116
|
| `RateLimitExceededError` | 429 | Too many requests |
|
|
1110
1117
|
| `TooManyActiveJobsError` | 429 | A job could not start: too many of your jobs are already running (`too_many_active_jobs`). Extends `RateLimitExceededError` |
|
|
1111
1118
|
| `GeoRestrictedError` | 451 | Content unavailable in your region |
|
|
@@ -1146,11 +1153,16 @@ All API responses are parsed into typed classes with static `fromJSON()` constru
|
|
|
1146
1153
|
| `TikTokSearchTask` | TikTok keyword search task with status, results, pagination, `download_url`, `error`, `webhook`; `stats` shows the `sort_by` / `published_within` the search ran with |
|
|
1147
1154
|
| `TikTokSearchResult` | Normalized TikTok keyword result, including `published_at` as a `Date` and integer counters |
|
|
1148
1155
|
| `TikTokLiveSearchSubmission` | Async TikTok LIVE search submission: `task_id`, query, country, `include_stream_urls`, expiry, `webhook_url` |
|
|
1149
|
-
| `TikTokLiveSearchTask` | TikTok LIVE search task with status, rooms, pagination, `download_url`, `error`, `webhook`; `stats.
|
|
1156
|
+
| `TikTokLiveSearchTask` | TikTok LIVE search task with status, rooms, pagination, `download_url`, `error`, `webhook`; billing follows `stats.results_count` and `stats.pages_fetched` |
|
|
1150
1157
|
| `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) |
|
|
1151
1158
|
| `TikTokLiveRoomDetail` | A `TikTokLiveRoom` from `getTikTokLiveRoom`: `status` / `isLive`, `ended_at`, `stats.new_followers`, `author.bio`, `share_url`, `chat_enabled`, `subscribers_only`, `products` |
|
|
1152
1159
|
| `TweetStatement` | Structured X/Twitter claim analysis, topics, entities, tone, intent, and source text; with `include_scenes`, `frames_analyzed` and `scenes_error` |
|
|
1153
1160
|
|
|
1161
|
+
## What's new in 3.0.2
|
|
1162
|
+
|
|
1163
|
+
- **`getUsage()` keeps every counter:** `usage.frameAnalysis` and `usage.sceneAnalysisHour` were dropped; they are now there with the other counters. The legacy `videoTranscripts`, `youtubeTranscripts`, `videoSearches`, `videoAnalyses`, `videoSceneAnalyses` and `videoUploads` counters, which the API no longer sends, are marked deprecated.
|
|
1164
|
+
- **`getUsage()` on an account without a subscription period:** the API sends `null` dates then, which became January 1, 1970. `usagePeriod.start`, `usagePeriod.end`, `billingPeriod.start` and `billingPeriod.end` are now `undefined` instead.
|
|
1165
|
+
|
|
1154
1166
|
## What's new in 3.0.1
|
|
1155
1167
|
|
|
1156
1168
|
- **`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.
|
package/dist/errors.d.ts
CHANGED
|
@@ -62,9 +62,11 @@ export declare class ServerError extends VidNavigatorError {
|
|
|
62
62
|
constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any);
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
|
-
* Raised when storage
|
|
65
|
+
* Raised when the storage of the plan is full: HTTP 402 `storage_quota_exceeded`
|
|
66
|
+
* on `uploadFile` (413 is still mapped here too). A `PaymentRequiredError`, so
|
|
67
|
+
* code that catches that one keeps working.
|
|
66
68
|
*/
|
|
67
|
-
export declare class StorageQuotaExceededError extends
|
|
69
|
+
export declare class StorageQuotaExceededError extends PaymentRequiredError {
|
|
68
70
|
constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any);
|
|
69
71
|
}
|
|
70
72
|
/**
|
package/dist/errors.js
CHANGED
|
@@ -95,9 +95,11 @@ class ServerError extends VidNavigatorError {
|
|
|
95
95
|
}
|
|
96
96
|
exports.ServerError = ServerError;
|
|
97
97
|
/**
|
|
98
|
-
* Raised when storage
|
|
98
|
+
* Raised when the storage of the plan is full: HTTP 402 `storage_quota_exceeded`
|
|
99
|
+
* on `uploadFile` (413 is still mapped here too). A `PaymentRequiredError`, so
|
|
100
|
+
* code that catches that one keeps working.
|
|
99
101
|
*/
|
|
100
|
-
class StorageQuotaExceededError extends
|
|
102
|
+
class StorageQuotaExceededError extends PaymentRequiredError {
|
|
101
103
|
constructor(message, status_code, error_code, error_message, details) {
|
|
102
104
|
super(message, status_code, error_code, error_message, details);
|
|
103
105
|
this.name = 'StorageQuotaExceededError';
|
package/dist/http.js
CHANGED
|
@@ -23,6 +23,9 @@ function buildApiError(status, data, fallbackMessage) {
|
|
|
23
23
|
case 401:
|
|
24
24
|
return new errors_1.AuthenticationError(message, status, errorCode, errorMessage, details);
|
|
25
25
|
case 402:
|
|
26
|
+
if (errorCode === 'storage_quota_exceeded') {
|
|
27
|
+
return new errors_1.StorageQuotaExceededError(message, status, errorCode, errorMessage, details);
|
|
28
|
+
}
|
|
26
29
|
if (errorCode === 'limit_exceeded') {
|
|
27
30
|
return new errors_1.InsufficientCreditsError(message, status, errorCode, errorMessage, details);
|
|
28
31
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export * from './webhooks';
|
|
|
7
7
|
export { Job } from './jobs';
|
|
8
8
|
export type { TaskStatus, PollableTask, PollOptions, JobOperation, SubmitOptions, RunOptions, JobInfo } from './jobs';
|
|
9
9
|
/** SDK version (keep in sync with package.json) */
|
|
10
|
-
export declare const SDK_VERSION = "3.0.
|
|
10
|
+
export declare const SDK_VERSION = "3.0.2";
|
|
11
11
|
export interface SDKConfig {
|
|
12
12
|
apiKey: string;
|
|
13
13
|
baseURL?: string;
|
package/dist/index.js
CHANGED
|
@@ -31,7 +31,7 @@ __exportStar(require("./webhooks"), exports);
|
|
|
31
31
|
var jobs_2 = require("./jobs");
|
|
32
32
|
Object.defineProperty(exports, "Job", { enumerable: true, get: function () { return jobs_2.Job; } });
|
|
33
33
|
/** SDK version (keep in sync with package.json) */
|
|
34
|
-
exports.SDK_VERSION = '3.0.
|
|
34
|
+
exports.SDK_VERSION = '3.0.2';
|
|
35
35
|
/**
|
|
36
36
|
* A LIVE room usually answers in 1-5 s, up to ~30 s when the API has to open a TikTok page, and two
|
|
37
37
|
* minutes at worst. A shorter configured axios timeout is raised to this for that call only.
|
package/dist/models/TikTok.d.ts
CHANGED
|
@@ -563,7 +563,8 @@ export interface TikTokLiveSearchStats {
|
|
|
563
563
|
pages_fetched?: number;
|
|
564
564
|
/**
|
|
565
565
|
* Distinct rooms TikTok returned, including any past `max_results`. For information:
|
|
566
|
-
* billing follows `results_count` (1 `residential_request` per 30, minimum 1 per search)
|
|
566
|
+
* billing follows `results_count` (1 `residential_request` per 30, minimum 1 per search)
|
|
567
|
+
* and `pages_fetched` (at least 1 per 5).
|
|
567
568
|
*/
|
|
568
569
|
rooms_fetched?: number;
|
|
569
570
|
results_count?: number;
|
package/dist/models/Usage.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export declare class UsageCharge {
|
|
|
28
28
|
export interface UsageBlockJSON {
|
|
29
29
|
charges?: UsageChargeJSON[];
|
|
30
30
|
total_credits?: number;
|
|
31
|
+
/** Credits left on the account (monthly + purchased) after this request's charges. Absent on plans without a credit limit. */
|
|
31
32
|
credits_remaining_after?: number;
|
|
32
33
|
waived?: {
|
|
33
34
|
credits_saved: number;
|
|
@@ -48,6 +49,10 @@ export interface UsageBlockJSON {
|
|
|
48
49
|
export declare class UsageBlock {
|
|
49
50
|
charges: UsageCharge[];
|
|
50
51
|
total_credits?: number;
|
|
52
|
+
/**
|
|
53
|
+
* Credits left on the account (monthly + purchased) after this request's charges.
|
|
54
|
+
* `undefined` on plans without a credit limit, where the API leaves it out.
|
|
55
|
+
*/
|
|
51
56
|
credits_remaining_after?: number;
|
|
52
57
|
waived?: {
|
|
53
58
|
credits_saved: number;
|
|
@@ -128,13 +133,14 @@ export declare class StorageUsage {
|
|
|
128
133
|
}
|
|
129
134
|
export type PlanInterval = 'month' | 'year';
|
|
130
135
|
export interface UsageDataJSON {
|
|
136
|
+
/** `start` and `end` are null when the account has no subscription period. */
|
|
131
137
|
usage_period: {
|
|
132
|
-
start: string;
|
|
133
|
-
end: string;
|
|
138
|
+
start: string | null;
|
|
139
|
+
end: string | null;
|
|
134
140
|
};
|
|
135
141
|
billing_period: {
|
|
136
|
-
start: string;
|
|
137
|
-
end: string;
|
|
142
|
+
start: string | null;
|
|
143
|
+
end: string | null;
|
|
138
144
|
interval: PlanInterval;
|
|
139
145
|
};
|
|
140
146
|
subscription: {
|
|
@@ -150,12 +156,22 @@ export interface UsageDataJSON {
|
|
|
150
156
|
residential_request?: ActivityCountJSON;
|
|
151
157
|
search_request?: ActivityCountJSON;
|
|
152
158
|
analysis_request?: ActivityCountJSON;
|
|
159
|
+
/** Hours of video whose scenes were analyzed (`unit: 'hours'`). */
|
|
160
|
+
scene_analysis_hour?: ActivityCountJSON;
|
|
153
161
|
transcription_hour?: ActivityCountJSON;
|
|
162
|
+
/** Frames analyzed by `watch` and by `include_scenes` (`unit: 'frames'`). */
|
|
163
|
+
frame_analysis?: ActivityCountJSON;
|
|
164
|
+
/** @deprecated Legacy counters below: the API no longer sends them. */
|
|
154
165
|
video_scene_analyses?: ActivityCountJSON;
|
|
166
|
+
/** @deprecated */
|
|
155
167
|
video_transcripts?: ActivityCountJSON;
|
|
168
|
+
/** @deprecated */
|
|
156
169
|
youtube_transcripts?: ActivityCountJSON;
|
|
170
|
+
/** @deprecated */
|
|
157
171
|
video_searches?: ActivityCountJSON;
|
|
172
|
+
/** @deprecated */
|
|
158
173
|
video_analyses?: ActivityCountJSON;
|
|
174
|
+
/** @deprecated */
|
|
159
175
|
video_uploads?: ActivityCountJSON;
|
|
160
176
|
};
|
|
161
177
|
channels_indexed: CapacityMetricJSON;
|
|
@@ -163,13 +179,15 @@ export interface UsageDataJSON {
|
|
|
163
179
|
generated_at: string;
|
|
164
180
|
}
|
|
165
181
|
export declare class UsageData {
|
|
182
|
+
/** `start` and `end` are `undefined` when the account has no subscription period. */
|
|
166
183
|
usagePeriod: {
|
|
167
|
-
start: Date;
|
|
168
|
-
end: Date;
|
|
184
|
+
start: Date | undefined;
|
|
185
|
+
end: Date | undefined;
|
|
169
186
|
};
|
|
187
|
+
/** `start` and `end` are `undefined` when the account has no subscription period. */
|
|
170
188
|
billingPeriod: {
|
|
171
|
-
start: Date;
|
|
172
|
-
end: Date;
|
|
189
|
+
start: Date | undefined;
|
|
190
|
+
end: Date | undefined;
|
|
173
191
|
interval: PlanInterval;
|
|
174
192
|
};
|
|
175
193
|
subscription: {
|
|
@@ -185,12 +203,22 @@ export declare class UsageData {
|
|
|
185
203
|
residentialRequest?: ActivityCount;
|
|
186
204
|
searchRequest?: ActivityCount;
|
|
187
205
|
analysisRequest?: ActivityCount;
|
|
206
|
+
/** Hours of video whose scenes were analyzed. */
|
|
207
|
+
sceneAnalysisHour?: ActivityCount;
|
|
188
208
|
transcriptionHour?: ActivityCount;
|
|
209
|
+
/** Frames analyzed by `watch` and by `include_scenes`. */
|
|
210
|
+
frameAnalysis?: ActivityCount;
|
|
211
|
+
/** @deprecated Legacy counters below: the API no longer sends them, so they stay undefined. */
|
|
189
212
|
videoSceneAnalyses?: ActivityCount;
|
|
213
|
+
/** @deprecated */
|
|
190
214
|
videoTranscripts?: ActivityCount;
|
|
215
|
+
/** @deprecated */
|
|
191
216
|
youtubeTranscripts?: ActivityCount;
|
|
217
|
+
/** @deprecated */
|
|
192
218
|
videoSearches?: ActivityCount;
|
|
219
|
+
/** @deprecated */
|
|
193
220
|
videoAnalyses?: ActivityCount;
|
|
221
|
+
/** @deprecated */
|
|
194
222
|
videoUploads?: ActivityCount;
|
|
195
223
|
};
|
|
196
224
|
channelsIndexed: CapacityMetric;
|
package/dist/models/Usage.js
CHANGED
|
@@ -118,16 +118,20 @@ class StorageUsage {
|
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
exports.StorageUsage = StorageUsage;
|
|
121
|
+
/** A date of the API, or `undefined` when it sent null (never `new Date(null)`, which is 1970). */
|
|
122
|
+
function optionalDate(value) {
|
|
123
|
+
return value ? new Date(value) : undefined;
|
|
124
|
+
}
|
|
121
125
|
class UsageData {
|
|
122
126
|
constructor(data) {
|
|
123
127
|
this.usagePeriod = {
|
|
124
|
-
start:
|
|
125
|
-
end:
|
|
128
|
+
start: optionalDate(data.usage_period?.start),
|
|
129
|
+
end: optionalDate(data.usage_period?.end),
|
|
126
130
|
};
|
|
127
131
|
this.billingPeriod = {
|
|
128
|
-
start:
|
|
129
|
-
end:
|
|
130
|
-
interval: data.billing_period
|
|
132
|
+
start: optionalDate(data.billing_period?.start),
|
|
133
|
+
end: optionalDate(data.billing_period?.end),
|
|
134
|
+
interval: data.billing_period?.interval,
|
|
131
135
|
};
|
|
132
136
|
this.subscription = {
|
|
133
137
|
planId: data.subscription.plan_id,
|
|
@@ -142,7 +146,9 @@ class UsageData {
|
|
|
142
146
|
residentialRequest: data.usage.residential_request ? ActivityCount.fromJSON(data.usage.residential_request) : undefined,
|
|
143
147
|
searchRequest: data.usage.search_request ? ActivityCount.fromJSON(data.usage.search_request) : undefined,
|
|
144
148
|
analysisRequest: data.usage.analysis_request ? ActivityCount.fromJSON(data.usage.analysis_request) : undefined,
|
|
149
|
+
sceneAnalysisHour: data.usage.scene_analysis_hour ? ActivityCount.fromJSON(data.usage.scene_analysis_hour) : undefined,
|
|
145
150
|
transcriptionHour: data.usage.transcription_hour ? ActivityCount.fromJSON(data.usage.transcription_hour) : undefined,
|
|
151
|
+
frameAnalysis: data.usage.frame_analysis ? ActivityCount.fromJSON(data.usage.frame_analysis) : undefined,
|
|
146
152
|
videoSceneAnalyses: data.usage.video_scene_analyses ? ActivityCount.fromJSON(data.usage.video_scene_analyses) : undefined,
|
|
147
153
|
videoTranscripts: data.usage.video_transcripts ? ActivityCount.fromJSON(data.usage.video_transcripts) : undefined,
|
|
148
154
|
youtubeTranscripts: data.usage.youtube_transcripts ? ActivityCount.fromJSON(data.usage.youtube_transcripts) : undefined,
|
package/package.json
CHANGED
package/src/errors.ts
CHANGED
|
@@ -114,9 +114,11 @@ export class ServerError extends VidNavigatorError {
|
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
/**
|
|
117
|
-
* Raised when storage
|
|
117
|
+
* Raised when the storage of the plan is full: HTTP 402 `storage_quota_exceeded`
|
|
118
|
+
* on `uploadFile` (413 is still mapped here too). A `PaymentRequiredError`, so
|
|
119
|
+
* code that catches that one keeps working.
|
|
118
120
|
*/
|
|
119
|
-
export class StorageQuotaExceededError extends
|
|
121
|
+
export class StorageQuotaExceededError extends PaymentRequiredError {
|
|
120
122
|
constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any) {
|
|
121
123
|
super(message, status_code, error_code, error_message, details);
|
|
122
124
|
this.name = 'StorageQuotaExceededError';
|
package/src/http.ts
CHANGED
|
@@ -43,6 +43,9 @@ export function buildApiError(status: number, data: any, fallbackMessage?: strin
|
|
|
43
43
|
case 401:
|
|
44
44
|
return new AuthenticationError(message, status, errorCode, errorMessage, details);
|
|
45
45
|
case 402:
|
|
46
|
+
if (errorCode === 'storage_quota_exceeded') {
|
|
47
|
+
return new StorageQuotaExceededError(message, status, errorCode, errorMessage, details);
|
|
48
|
+
}
|
|
46
49
|
if (errorCode === 'limit_exceeded') {
|
|
47
50
|
return new InsufficientCreditsError(message, status, errorCode, errorMessage, details);
|
|
48
51
|
}
|
package/src/index.ts
CHANGED
|
@@ -71,7 +71,7 @@ export { Job } from './jobs';
|
|
|
71
71
|
export type { TaskStatus, PollableTask, PollOptions, JobOperation, SubmitOptions, RunOptions, JobInfo } from './jobs';
|
|
72
72
|
|
|
73
73
|
/** SDK version (keep in sync with package.json) */
|
|
74
|
-
export const SDK_VERSION = '3.0.
|
|
74
|
+
export const SDK_VERSION = '3.0.2';
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
77
|
* A LIVE room usually answers in 1-5 s, up to ~30 s when the API has to open a TikTok page, and two
|
package/src/models/TikTok.ts
CHANGED
|
@@ -923,7 +923,8 @@ export interface TikTokLiveSearchStats {
|
|
|
923
923
|
pages_fetched?: number;
|
|
924
924
|
/**
|
|
925
925
|
* Distinct rooms TikTok returned, including any past `max_results`. For information:
|
|
926
|
-
* billing follows `results_count` (1 `residential_request` per 30, minimum 1 per search)
|
|
926
|
+
* billing follows `results_count` (1 `residential_request` per 30, minimum 1 per search)
|
|
927
|
+
* and `pages_fetched` (at least 1 per 5).
|
|
927
928
|
*/
|
|
928
929
|
rooms_fetched?: number;
|
|
929
930
|
results_count?: number;
|
package/src/models/Usage.ts
CHANGED
|
@@ -51,6 +51,7 @@ export class UsageCharge {
|
|
|
51
51
|
export interface UsageBlockJSON {
|
|
52
52
|
charges?: UsageChargeJSON[];
|
|
53
53
|
total_credits?: number;
|
|
54
|
+
/** Credits left on the account (monthly + purchased) after this request's charges. Absent on plans without a credit limit. */
|
|
54
55
|
credits_remaining_after?: number;
|
|
55
56
|
waived?: { credits_saved: number };
|
|
56
57
|
/** Legacy flat token fields. Some /extract/* responses may still echo these. */
|
|
@@ -70,6 +71,10 @@ export interface UsageBlockJSON {
|
|
|
70
71
|
export class UsageBlock {
|
|
71
72
|
charges: UsageCharge[];
|
|
72
73
|
total_credits?: number;
|
|
74
|
+
/**
|
|
75
|
+
* Credits left on the account (monthly + purchased) after this request's charges.
|
|
76
|
+
* `undefined` on plans without a credit limit, where the API leaves it out.
|
|
77
|
+
*/
|
|
73
78
|
credits_remaining_after?: number;
|
|
74
79
|
waived?: { credits_saved: number };
|
|
75
80
|
/** Legacy flat token fields, only present on some /extract/* responses. */
|
|
@@ -231,13 +236,14 @@ export class StorageUsage {
|
|
|
231
236
|
export type PlanInterval = 'month' | 'year';
|
|
232
237
|
|
|
233
238
|
export interface UsageDataJSON {
|
|
239
|
+
/** `start` and `end` are null when the account has no subscription period. */
|
|
234
240
|
usage_period: {
|
|
235
|
-
start: string;
|
|
236
|
-
end: string;
|
|
241
|
+
start: string | null;
|
|
242
|
+
end: string | null;
|
|
237
243
|
};
|
|
238
244
|
billing_period: {
|
|
239
|
-
start: string;
|
|
240
|
-
end: string;
|
|
245
|
+
start: string | null;
|
|
246
|
+
end: string | null;
|
|
241
247
|
interval: PlanInterval;
|
|
242
248
|
};
|
|
243
249
|
subscription: {
|
|
@@ -253,12 +259,22 @@ export interface UsageDataJSON {
|
|
|
253
259
|
residential_request?: ActivityCountJSON;
|
|
254
260
|
search_request?: ActivityCountJSON;
|
|
255
261
|
analysis_request?: ActivityCountJSON;
|
|
262
|
+
/** Hours of video whose scenes were analyzed (`unit: 'hours'`). */
|
|
263
|
+
scene_analysis_hour?: ActivityCountJSON;
|
|
256
264
|
transcription_hour?: ActivityCountJSON;
|
|
265
|
+
/** Frames analyzed by `watch` and by `include_scenes` (`unit: 'frames'`). */
|
|
266
|
+
frame_analysis?: ActivityCountJSON;
|
|
267
|
+
/** @deprecated Legacy counters below: the API no longer sends them. */
|
|
257
268
|
video_scene_analyses?: ActivityCountJSON;
|
|
269
|
+
/** @deprecated */
|
|
258
270
|
video_transcripts?: ActivityCountJSON;
|
|
271
|
+
/** @deprecated */
|
|
259
272
|
youtube_transcripts?: ActivityCountJSON;
|
|
273
|
+
/** @deprecated */
|
|
260
274
|
video_searches?: ActivityCountJSON;
|
|
275
|
+
/** @deprecated */
|
|
261
276
|
video_analyses?: ActivityCountJSON;
|
|
277
|
+
/** @deprecated */
|
|
262
278
|
video_uploads?: ActivityCountJSON;
|
|
263
279
|
};
|
|
264
280
|
channels_indexed: CapacityMetricJSON;
|
|
@@ -266,14 +282,21 @@ export interface UsageDataJSON {
|
|
|
266
282
|
generated_at: string;
|
|
267
283
|
}
|
|
268
284
|
|
|
285
|
+
/** A date of the API, or `undefined` when it sent null (never `new Date(null)`, which is 1970). */
|
|
286
|
+
function optionalDate(value: string | null | undefined): Date | undefined {
|
|
287
|
+
return value ? new Date(value) : undefined;
|
|
288
|
+
}
|
|
289
|
+
|
|
269
290
|
export class UsageData {
|
|
291
|
+
/** `start` and `end` are `undefined` when the account has no subscription period. */
|
|
270
292
|
public usagePeriod: {
|
|
271
|
-
start: Date;
|
|
272
|
-
end: Date;
|
|
293
|
+
start: Date | undefined;
|
|
294
|
+
end: Date | undefined;
|
|
273
295
|
};
|
|
296
|
+
/** `start` and `end` are `undefined` when the account has no subscription period. */
|
|
274
297
|
public billingPeriod: {
|
|
275
|
-
start: Date;
|
|
276
|
-
end: Date;
|
|
298
|
+
start: Date | undefined;
|
|
299
|
+
end: Date | undefined;
|
|
277
300
|
interval: PlanInterval;
|
|
278
301
|
};
|
|
279
302
|
public subscription: {
|
|
@@ -289,12 +312,22 @@ export class UsageData {
|
|
|
289
312
|
residentialRequest?: ActivityCount;
|
|
290
313
|
searchRequest?: ActivityCount;
|
|
291
314
|
analysisRequest?: ActivityCount;
|
|
315
|
+
/** Hours of video whose scenes were analyzed. */
|
|
316
|
+
sceneAnalysisHour?: ActivityCount;
|
|
292
317
|
transcriptionHour?: ActivityCount;
|
|
318
|
+
/** Frames analyzed by `watch` and by `include_scenes`. */
|
|
319
|
+
frameAnalysis?: ActivityCount;
|
|
320
|
+
/** @deprecated Legacy counters below: the API no longer sends them, so they stay undefined. */
|
|
293
321
|
videoSceneAnalyses?: ActivityCount;
|
|
322
|
+
/** @deprecated */
|
|
294
323
|
videoTranscripts?: ActivityCount;
|
|
324
|
+
/** @deprecated */
|
|
295
325
|
youtubeTranscripts?: ActivityCount;
|
|
326
|
+
/** @deprecated */
|
|
296
327
|
videoSearches?: ActivityCount;
|
|
328
|
+
/** @deprecated */
|
|
297
329
|
videoAnalyses?: ActivityCount;
|
|
330
|
+
/** @deprecated */
|
|
298
331
|
videoUploads?: ActivityCount;
|
|
299
332
|
};
|
|
300
333
|
public channelsIndexed: CapacityMetric;
|
|
@@ -303,13 +336,13 @@ export class UsageData {
|
|
|
303
336
|
|
|
304
337
|
constructor(data: UsageDataJSON) {
|
|
305
338
|
this.usagePeriod = {
|
|
306
|
-
start:
|
|
307
|
-
end:
|
|
339
|
+
start: optionalDate(data.usage_period?.start),
|
|
340
|
+
end: optionalDate(data.usage_period?.end),
|
|
308
341
|
};
|
|
309
342
|
this.billingPeriod = {
|
|
310
|
-
start:
|
|
311
|
-
end:
|
|
312
|
-
interval: data.billing_period
|
|
343
|
+
start: optionalDate(data.billing_period?.start),
|
|
344
|
+
end: optionalDate(data.billing_period?.end),
|
|
345
|
+
interval: data.billing_period?.interval,
|
|
313
346
|
};
|
|
314
347
|
this.subscription = {
|
|
315
348
|
planId: data.subscription.plan_id,
|
|
@@ -324,7 +357,9 @@ export class UsageData {
|
|
|
324
357
|
residentialRequest: data.usage.residential_request ? ActivityCount.fromJSON(data.usage.residential_request) : undefined,
|
|
325
358
|
searchRequest: data.usage.search_request ? ActivityCount.fromJSON(data.usage.search_request) : undefined,
|
|
326
359
|
analysisRequest: data.usage.analysis_request ? ActivityCount.fromJSON(data.usage.analysis_request) : undefined,
|
|
360
|
+
sceneAnalysisHour: data.usage.scene_analysis_hour ? ActivityCount.fromJSON(data.usage.scene_analysis_hour) : undefined,
|
|
327
361
|
transcriptionHour: data.usage.transcription_hour ? ActivityCount.fromJSON(data.usage.transcription_hour) : undefined,
|
|
362
|
+
frameAnalysis: data.usage.frame_analysis ? ActivityCount.fromJSON(data.usage.frame_analysis) : undefined,
|
|
328
363
|
videoSceneAnalyses: data.usage.video_scene_analyses ? ActivityCount.fromJSON(data.usage.video_scene_analyses) : undefined,
|
|
329
364
|
videoTranscripts: data.usage.video_transcripts ? ActivityCount.fromJSON(data.usage.video_transcripts) : undefined,
|
|
330
365
|
youtubeTranscripts: data.usage.youtube_transcripts ? ActivityCount.fromJSON(data.usage.youtube_transcripts) : undefined,
|