vidnavigator 1.0.3 → 1.0.4
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 +50 -9
- package/dist/index.d.ts +37 -15
- package/dist/index.js +41 -1
- package/dist/models/TikTok.d.ts +129 -0
- package/dist/models/TikTok.js +92 -1
- package/package.json +1 -1
- package/src/index.ts +113 -14
- package/src/models/TikTok.ts +225 -0
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ The official JavaScript/TypeScript SDK for the [VidNavigator Developer API](http
|
|
|
10
10
|
## Why VidNavigator?
|
|
11
11
|
|
|
12
12
|
- **Multi-platform transcription** — YouTube, Instagram Reels & carousel posts, TikTok, X/Twitter, Vimeo, Facebook, Dailymotion, Loom, and more.
|
|
13
|
-
- **Async TikTok profile scraping** —
|
|
13
|
+
- **Async TikTok profile scraping and keyword search** — collect public TikTok videos in the background, then read results via cursor pagination or a signed `download_url`.
|
|
14
14
|
- **Instagram carousel support** — select a specific video by index, or transcribe every video in a carousel post with one call.
|
|
15
15
|
- **AI-powered analysis** — get summaries, people mentioned, places, key subjects, and direct answers to questions about any video or audio.
|
|
16
16
|
- **Structured data extraction** — define a JSON schema and receive typed, structured fields extracted from any transcript (powered by LLMs).
|
|
@@ -216,7 +216,33 @@ for (const video of videos) {
|
|
|
216
216
|
|
|
217
217
|
For large profiles, process videos sequentially or with a small concurrency limit so you do not exhaust credits or hit rate limits.
|
|
218
218
|
|
|
219
|
-
### 4.
|
|
219
|
+
### 4. TikTok keyword search (async)
|
|
220
|
+
|
|
221
|
+
TikTok keyword search follows the same async pattern as profile scraping: submit a search, then poll by `task_id` until results are ready.
|
|
222
|
+
|
|
223
|
+
```ts
|
|
224
|
+
const submitted = await vn.submitTikTokSearch({
|
|
225
|
+
query: 'ai tools',
|
|
226
|
+
max_results: 100,
|
|
227
|
+
parallel_search_slices: 2,
|
|
228
|
+
after_datetime: '2024-01-01',
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
let task = await vn.getTikTokSearch(submitted.task_id, { limit: 50 });
|
|
232
|
+
|
|
233
|
+
while (task.task_status === 'processing') {
|
|
234
|
+
await sleep(5000);
|
|
235
|
+
task = await vn.getTikTokSearch(submitted.task_id, { limit: 50 });
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
for (const result of task.results) {
|
|
239
|
+
console.log(result.published_at?.toISOString(), result.url, result.stats?.views);
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
Use `parallel_search_slices` from `2` to `4` when you need broader collection than TikTok's natural single-chain cap. Billing scales with the number of slices, so keep it at `1` unless you need the wider result set.
|
|
244
|
+
|
|
245
|
+
### 5. Instagram carousel posts (multiple videos)
|
|
220
246
|
|
|
221
247
|
Instagram carousel posts can contain multiple videos. You can select a specific video by index, or transcribe them all at once:
|
|
222
248
|
|
|
@@ -249,7 +275,7 @@ if ('carousel_info' in all) {
|
|
|
249
275
|
}
|
|
250
276
|
```
|
|
251
277
|
|
|
252
|
-
###
|
|
278
|
+
### 6. Upload and analyze a local file
|
|
253
279
|
|
|
254
280
|
Upload audio or video files for transcription, analysis, and search. Supported formats: mp4, webm, mov, avi, wmv, flv, mkv, m4a, mp3, mpeg, mpga, wav.
|
|
255
281
|
|
|
@@ -283,7 +309,7 @@ console.log(transcript_analysis.query_answer?.answer);
|
|
|
283
309
|
// "Three action items were discussed: 1) Finalize the hiring..."
|
|
284
310
|
```
|
|
285
311
|
|
|
286
|
-
###
|
|
312
|
+
### 7. Extract structured data
|
|
287
313
|
|
|
288
314
|
Define a schema and get back clean, structured data extracted from any video or file transcript. Powered by LLMs with token usage tracking.
|
|
289
315
|
|
|
@@ -326,9 +352,19 @@ const { data } = await vn.extractFileData({
|
|
|
326
352
|
});
|
|
327
353
|
```
|
|
328
354
|
|
|
355
|
+
For larger schemas, pass a JSON or YAML schema file with multipart form-data:
|
|
356
|
+
|
|
357
|
+
```ts
|
|
358
|
+
const { data } = await vn.extractVideoData({
|
|
359
|
+
video_url: 'https://youtube.com/watch?v=dQw4w9WgXcQ',
|
|
360
|
+
schemaFilePath: './schemas/video-extraction.yaml',
|
|
361
|
+
include_usage: true,
|
|
362
|
+
});
|
|
363
|
+
```
|
|
364
|
+
|
|
329
365
|
**Supported schema types:** `String`, `Number`, `Boolean`, `Integer`, `Object`, `Array`, `Enum`
|
|
330
366
|
|
|
331
|
-
###
|
|
367
|
+
### 8. Semantic search
|
|
332
368
|
|
|
333
369
|
Search YouTube videos and uploaded files with AI-powered ranking/reranking.
|
|
334
370
|
|
|
@@ -357,7 +393,7 @@ for (const r of fileResults.results) {
|
|
|
357
393
|
}
|
|
358
394
|
```
|
|
359
395
|
|
|
360
|
-
###
|
|
396
|
+
### 9. Organize files with namespaces
|
|
361
397
|
|
|
362
398
|
```ts
|
|
363
399
|
// Create a namespace
|
|
@@ -377,7 +413,7 @@ const files = await vn.getFiles({ namespace_id: ns.id });
|
|
|
377
413
|
const all = await vn.getNamespaces();
|
|
378
414
|
```
|
|
379
415
|
|
|
380
|
-
###
|
|
416
|
+
### 10. Usage and credits
|
|
381
417
|
|
|
382
418
|
```ts
|
|
383
419
|
const usage = await vn.getUsage();
|
|
@@ -411,8 +447,10 @@ All methods return a `Promise`. Responses are automatically parsed into typed mo
|
|
|
411
447
|
|--------|-------------|
|
|
412
448
|
| `submitTikTokProfileScrape(payload)` | Start an async public TikTok profile scrape. Returns a `task_id` immediately |
|
|
413
449
|
| `getTikTokProfileScrape(task_id, query?)` | Poll task status and retrieve a page of videos. Options: `cursor`, `limit` |
|
|
450
|
+
| `submitTikTokSearch(payload)` | Start an async TikTok keyword search. Returns a `task_id` immediately |
|
|
451
|
+
| `getTikTokSearch(task_id, query?)` | Poll search status and retrieve a page of results. Options: `cursor`, `limit` |
|
|
414
452
|
|
|
415
|
-
Completed tasks include `videos
|
|
453
|
+
Completed profile tasks include `videos`; completed search tasks include `results`. Both include `pagination`, optional `stats`, and an optional short-lived `download_url` for retrieving the whole result as JSON. Datetime filters use `after_datetime` and `before_datetime`, each accepting either `YYYY-MM-DD` or full ISO datetime strings with timezone; TikTok `published_at` values are parsed into JavaScript `Date` objects, and numeric counters such as `views` and `likes` are normalized to integers.
|
|
416
454
|
|
|
417
455
|
### Files
|
|
418
456
|
|
|
@@ -460,7 +498,7 @@ Returns `transcript_analysis` containing:
|
|
|
460
498
|
| `extractVideoData(payload)` | Extract structured data from an online video transcript |
|
|
461
499
|
| `extractFileData(payload)` | Extract structured data from an uploaded file transcript |
|
|
462
500
|
|
|
463
|
-
**Options:** `schema` (required), `what_to_extract` (optional guidance), `include_usage` (token tracking)
|
|
501
|
+
**Options:** `schema` (required for JSON requests), `schemaFilePath` (JSON/YAML schema file via multipart form-data), `what_to_extract` (optional guidance), `include_usage` (token tracking)
|
|
464
502
|
|
|
465
503
|
**Schema field types:** `String`, `Number`, `Boolean`, `Integer`, `Object`, `Array`, `Enum`
|
|
466
504
|
|
|
@@ -538,6 +576,9 @@ All API responses are parsed into typed classes with static `fromJSON()` constru
|
|
|
538
576
|
| `TikTokProfileScrapeSubmission` | Async scrape submission: `task_id`, status, profile URL, expiry |
|
|
539
577
|
| `TikTokProfileTask` | TikTok profile scrape task with status, profile metadata, videos, pagination, `download_url` |
|
|
540
578
|
| `TikTokVideo` | Public TikTok video metadata returned by profile scraping, including `published_at` as a `Date` and integer counters |
|
|
579
|
+
| `TikTokSearchSubmission` | Async TikTok keyword search submission: `task_id`, query, slice count, expiry |
|
|
580
|
+
| `TikTokSearchTask` | TikTok keyword search task with status, results, pagination, `download_url` |
|
|
581
|
+
| `TikTokSearchResult` | Normalized TikTok keyword result, including `published_at` as a `Date` and integer counters |
|
|
541
582
|
| `TweetStatement` | Structured X/Twitter claim analysis, topics, entities, tone, intent, and source text |
|
|
542
583
|
|
|
543
584
|
## Links
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AxiosRequestConfig } from 'axios';
|
|
2
|
-
import { VideoInfo, TranscriptOutput, FileInfo, AnalysisResult, VideoSearchResult, FileSearchResult, UsageData, Namespace, NamespaceRef, ExtractionSchema, ExtractionTokenUsage, CarouselInfo, CarouselVideoResult, TikTokProfileScrapeRequest, TikTokProfileScrapeSubmission, TikTokProfileTask, TweetStatement } from './models';
|
|
2
|
+
import { VideoInfo, TranscriptOutput, FileInfo, AnalysisResult, VideoSearchResult, FileSearchResult, UsageData, Namespace, NamespaceRef, ExtractionSchema, ExtractionTokenUsage, CarouselInfo, CarouselVideoResult, TikTokProfileScrapeRequest, TikTokProfileScrapeSubmission, TikTokProfileTask, TikTokSearchRequest, TikTokSearchSubmission, TikTokSearchTask, TweetStatement } from './models';
|
|
3
3
|
export * from './models';
|
|
4
4
|
export * from './errors';
|
|
5
5
|
/** SDK version (keep in sync with package.json) */
|
|
6
|
-
export declare const SDK_VERSION = "1.0.
|
|
6
|
+
export declare const SDK_VERSION = "1.0.4";
|
|
7
7
|
export interface SDKConfig {
|
|
8
8
|
apiKey: string;
|
|
9
9
|
baseURL?: string;
|
|
@@ -54,6 +54,34 @@ export interface ExtractDataResult {
|
|
|
54
54
|
file_info?: FileInfo;
|
|
55
55
|
usage?: ExtractionTokenUsage;
|
|
56
56
|
}
|
|
57
|
+
export type ExtractVideoDataPayload = {
|
|
58
|
+
video_url: string;
|
|
59
|
+
schema: ExtractionSchema;
|
|
60
|
+
what_to_extract?: string;
|
|
61
|
+
transcribe?: boolean;
|
|
62
|
+
include_usage?: boolean;
|
|
63
|
+
};
|
|
64
|
+
export type ExtractVideoDataMultipartPayload = {
|
|
65
|
+
video_url: string;
|
|
66
|
+
/** Path to a JSON or YAML schema file. The API accepts either a raw schema or a full extraction request object. */
|
|
67
|
+
schemaFilePath: string;
|
|
68
|
+
what_to_extract?: string;
|
|
69
|
+
transcribe?: boolean;
|
|
70
|
+
include_usage?: boolean;
|
|
71
|
+
};
|
|
72
|
+
export type ExtractFileDataPayload = {
|
|
73
|
+
file_id: string;
|
|
74
|
+
schema: ExtractionSchema;
|
|
75
|
+
what_to_extract?: string;
|
|
76
|
+
include_usage?: boolean;
|
|
77
|
+
};
|
|
78
|
+
export type ExtractFileDataMultipartPayload = {
|
|
79
|
+
file_id: string;
|
|
80
|
+
/** Path to a JSON or YAML schema file. The API accepts either a raw schema or a full extraction request object. */
|
|
81
|
+
schemaFilePath: string;
|
|
82
|
+
what_to_extract?: string;
|
|
83
|
+
include_usage?: boolean;
|
|
84
|
+
};
|
|
57
85
|
export declare class VidNavigatorClient {
|
|
58
86
|
private client;
|
|
59
87
|
constructor(config: SDKConfig);
|
|
@@ -72,6 +100,11 @@ export declare class VidNavigatorClient {
|
|
|
72
100
|
cursor?: string;
|
|
73
101
|
limit?: number;
|
|
74
102
|
}): Promise<TikTokProfileTask>;
|
|
103
|
+
submitTikTokSearch(payload: TikTokSearchRequest): Promise<TikTokSearchSubmission>;
|
|
104
|
+
getTikTokSearch(task_id: string, query?: {
|
|
105
|
+
cursor?: string;
|
|
106
|
+
limit?: number;
|
|
107
|
+
}): Promise<TikTokSearchTask>;
|
|
75
108
|
getFiles(query?: {
|
|
76
109
|
limit?: number;
|
|
77
110
|
offset?: number;
|
|
@@ -155,19 +188,8 @@ export declare class VidNavigatorClient {
|
|
|
155
188
|
getTweetStatement(payload: {
|
|
156
189
|
tweet_id: string;
|
|
157
190
|
}): Promise<TweetStatement>;
|
|
158
|
-
extractVideoData(payload:
|
|
159
|
-
|
|
160
|
-
schema: ExtractionSchema;
|
|
161
|
-
what_to_extract?: string;
|
|
162
|
-
transcribe?: boolean;
|
|
163
|
-
include_usage?: boolean;
|
|
164
|
-
}): Promise<ExtractDataResult>;
|
|
165
|
-
extractFileData(payload: {
|
|
166
|
-
file_id: string;
|
|
167
|
-
schema: ExtractionSchema;
|
|
168
|
-
what_to_extract?: string;
|
|
169
|
-
include_usage?: boolean;
|
|
170
|
-
}): Promise<ExtractDataResult>;
|
|
191
|
+
extractVideoData(payload: ExtractVideoDataPayload | ExtractVideoDataMultipartPayload): Promise<ExtractDataResult>;
|
|
192
|
+
extractFileData(payload: ExtractFileDataPayload | ExtractFileDataMultipartPayload): Promise<ExtractDataResult>;
|
|
171
193
|
searchVideos(payload: {
|
|
172
194
|
query: string;
|
|
173
195
|
use_enhanced_search?: boolean;
|
package/dist/index.js
CHANGED
|
@@ -26,7 +26,7 @@ const errors_1 = require("./errors");
|
|
|
26
26
|
__exportStar(require("./models"), exports);
|
|
27
27
|
__exportStar(require("./errors"), exports);
|
|
28
28
|
/** SDK version (keep in sync with package.json) */
|
|
29
|
-
exports.SDK_VERSION = '1.0.
|
|
29
|
+
exports.SDK_VERSION = '1.0.4';
|
|
30
30
|
//endregion
|
|
31
31
|
function parseApiErrorPayload(data) {
|
|
32
32
|
const errorField = data?.error;
|
|
@@ -35,6 +35,11 @@ function parseApiErrorPayload(data) {
|
|
|
35
35
|
(typeof errorField === 'object' ? errorField?.message : undefined);
|
|
36
36
|
return { errorCode, errorMessage, details: data };
|
|
37
37
|
}
|
|
38
|
+
function appendOptionalFormField(form, name, value) {
|
|
39
|
+
if (value !== undefined) {
|
|
40
|
+
form.append(name, String(value));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
38
43
|
class VidNavigatorClient {
|
|
39
44
|
constructor(config) {
|
|
40
45
|
if (!config?.apiKey) {
|
|
@@ -134,6 +139,14 @@ class VidNavigatorClient {
|
|
|
134
139
|
const response = await this.request('GET', `/tiktok/profile/${task_id}`, undefined, query);
|
|
135
140
|
return models_1.TikTokProfileTask.fromJSON(response.data);
|
|
136
141
|
}
|
|
142
|
+
async submitTikTokSearch(payload) {
|
|
143
|
+
const response = await this.request('POST', '/tiktok/search', payload);
|
|
144
|
+
return models_1.TikTokSearchSubmission.fromJSON(response.data);
|
|
145
|
+
}
|
|
146
|
+
async getTikTokSearch(task_id, query) {
|
|
147
|
+
const response = await this.request('GET', `/tiktok/search/${task_id}`, undefined, query);
|
|
148
|
+
return models_1.TikTokSearchTask.fromJSON(response.data);
|
|
149
|
+
}
|
|
137
150
|
//endregion
|
|
138
151
|
//region --- Files ---
|
|
139
152
|
async getFiles(query) {
|
|
@@ -279,6 +292,20 @@ class VidNavigatorClient {
|
|
|
279
292
|
//endregion
|
|
280
293
|
//region --- Extraction ---
|
|
281
294
|
async extractVideoData(payload) {
|
|
295
|
+
if ('schemaFilePath' in payload) {
|
|
296
|
+
const form = new form_data_1.default();
|
|
297
|
+
form.append('video_url', payload.video_url);
|
|
298
|
+
form.append('schema', fs_1.default.createReadStream(payload.schemaFilePath));
|
|
299
|
+
appendOptionalFormField(form, 'what_to_extract', payload.what_to_extract);
|
|
300
|
+
appendOptionalFormField(form, 'transcribe', payload.transcribe);
|
|
301
|
+
appendOptionalFormField(form, 'include_usage', payload.include_usage);
|
|
302
|
+
const body = await this.request('POST', '/extract/video', form, undefined, form.getHeaders());
|
|
303
|
+
return {
|
|
304
|
+
data: body.data,
|
|
305
|
+
video_info: body.video_info ? models_1.VideoInfo.fromJSON(body.video_info) : undefined,
|
|
306
|
+
usage: body.usage ? models_1.ExtractionTokenUsage.fromJSON(body.usage) : undefined,
|
|
307
|
+
};
|
|
308
|
+
}
|
|
282
309
|
const body = await this.request('POST', '/extract/video', payload);
|
|
283
310
|
return {
|
|
284
311
|
data: body.data,
|
|
@@ -287,6 +314,19 @@ class VidNavigatorClient {
|
|
|
287
314
|
};
|
|
288
315
|
}
|
|
289
316
|
async extractFileData(payload) {
|
|
317
|
+
if ('schemaFilePath' in payload) {
|
|
318
|
+
const form = new form_data_1.default();
|
|
319
|
+
form.append('file_id', payload.file_id);
|
|
320
|
+
form.append('schema', fs_1.default.createReadStream(payload.schemaFilePath));
|
|
321
|
+
appendOptionalFormField(form, 'what_to_extract', payload.what_to_extract);
|
|
322
|
+
appendOptionalFormField(form, 'include_usage', payload.include_usage);
|
|
323
|
+
const body = await this.request('POST', '/extract/file', form, undefined, form.getHeaders());
|
|
324
|
+
return {
|
|
325
|
+
data: body.data,
|
|
326
|
+
file_info: body.file_info ? models_1.FileInfo.fromJSON(body.file_info) : undefined,
|
|
327
|
+
usage: body.usage ? models_1.ExtractionTokenUsage.fromJSON(body.usage) : undefined,
|
|
328
|
+
};
|
|
329
|
+
}
|
|
290
330
|
const body = await this.request('POST', '/extract/file', payload);
|
|
291
331
|
return {
|
|
292
332
|
data: body.data,
|
package/dist/models/TikTok.d.ts
CHANGED
|
@@ -8,6 +8,19 @@ export interface TikTokProfileScrapeRequest {
|
|
|
8
8
|
min_likes?: number;
|
|
9
9
|
max_likes?: number;
|
|
10
10
|
}
|
|
11
|
+
export interface TikTokSearchRequest {
|
|
12
|
+
query: string;
|
|
13
|
+
max_results?: number;
|
|
14
|
+
parallel_search_slices?: number;
|
|
15
|
+
/** Format: YYYY-MM-DD or ISO datetime with timezone */
|
|
16
|
+
after_datetime?: string;
|
|
17
|
+
/** Format: YYYY-MM-DD or ISO datetime with timezone */
|
|
18
|
+
before_datetime?: string;
|
|
19
|
+
min_likes?: number;
|
|
20
|
+
max_likes?: number;
|
|
21
|
+
min_views?: number;
|
|
22
|
+
max_views?: number;
|
|
23
|
+
}
|
|
11
24
|
export interface TikTokProfileScrapeSubmissionJSON {
|
|
12
25
|
task_id: string;
|
|
13
26
|
task_status: 'processing';
|
|
@@ -26,6 +39,30 @@ export declare class TikTokProfileScrapeSubmission {
|
|
|
26
39
|
constructor(data: TikTokProfileScrapeSubmissionJSON);
|
|
27
40
|
static fromJSON(json: TikTokProfileScrapeSubmissionJSON): TikTokProfileScrapeSubmission;
|
|
28
41
|
}
|
|
42
|
+
export interface TikTokSearchSubmissionJSON {
|
|
43
|
+
task_id: string;
|
|
44
|
+
task_status: 'processing';
|
|
45
|
+
query: string;
|
|
46
|
+
max_results?: number;
|
|
47
|
+
parallel_search_slices?: number;
|
|
48
|
+
filters?: Record<string, unknown>;
|
|
49
|
+
expires_at?: string;
|
|
50
|
+
check_status_url?: string;
|
|
51
|
+
message?: string;
|
|
52
|
+
}
|
|
53
|
+
export declare class TikTokSearchSubmission {
|
|
54
|
+
task_id: string;
|
|
55
|
+
task_status: 'processing';
|
|
56
|
+
query: string;
|
|
57
|
+
max_results?: number;
|
|
58
|
+
parallel_search_slices?: number;
|
|
59
|
+
filters?: Record<string, unknown>;
|
|
60
|
+
expires_at?: string;
|
|
61
|
+
check_status_url?: string;
|
|
62
|
+
message?: string;
|
|
63
|
+
constructor(data: TikTokSearchSubmissionJSON);
|
|
64
|
+
static fromJSON(json: TikTokSearchSubmissionJSON): TikTokSearchSubmission;
|
|
65
|
+
}
|
|
29
66
|
export interface TikTokVideoJSON {
|
|
30
67
|
id?: string;
|
|
31
68
|
track?: string | null;
|
|
@@ -81,6 +118,66 @@ export interface TikTokProfilePagination {
|
|
|
81
118
|
next_cursor?: string | null;
|
|
82
119
|
prev_cursor?: string | null;
|
|
83
120
|
}
|
|
121
|
+
export interface TikTokSearchAuthor {
|
|
122
|
+
id?: string | null;
|
|
123
|
+
unique_id?: string | null;
|
|
124
|
+
nickname?: string | null;
|
|
125
|
+
sec_uid?: string | null;
|
|
126
|
+
}
|
|
127
|
+
export interface TikTokSearchResultStats {
|
|
128
|
+
views?: number | null;
|
|
129
|
+
likes?: number | null;
|
|
130
|
+
comments?: number | null;
|
|
131
|
+
shares?: number | null;
|
|
132
|
+
collects?: number | null;
|
|
133
|
+
}
|
|
134
|
+
export interface TikTokSearchMusic {
|
|
135
|
+
id?: string | null;
|
|
136
|
+
title?: string | null;
|
|
137
|
+
author_name?: string | null;
|
|
138
|
+
duration?: number | null;
|
|
139
|
+
}
|
|
140
|
+
export interface TikTokSearchResultJSON {
|
|
141
|
+
id?: string | null;
|
|
142
|
+
item_type?: number | null;
|
|
143
|
+
description?: string | null;
|
|
144
|
+
timestamp?: number | null;
|
|
145
|
+
published_at?: string | null;
|
|
146
|
+
author?: TikTokSearchAuthor;
|
|
147
|
+
stats?: TikTokSearchResultStats;
|
|
148
|
+
music?: TikTokSearchMusic;
|
|
149
|
+
duration?: number | null;
|
|
150
|
+
hashtags?: string[];
|
|
151
|
+
url?: string | null;
|
|
152
|
+
}
|
|
153
|
+
export declare class TikTokSearchResult {
|
|
154
|
+
id?: string | null;
|
|
155
|
+
item_type?: number | null;
|
|
156
|
+
description?: string | null;
|
|
157
|
+
timestamp?: number | null;
|
|
158
|
+
published_at?: Date | null;
|
|
159
|
+
author?: TikTokSearchAuthor;
|
|
160
|
+
stats?: TikTokSearchResultStats;
|
|
161
|
+
music?: TikTokSearchMusic;
|
|
162
|
+
duration?: number | null;
|
|
163
|
+
hashtags?: string[];
|
|
164
|
+
url?: string | null;
|
|
165
|
+
constructor(data: TikTokSearchResultJSON);
|
|
166
|
+
static fromJSON(json: TikTokSearchResultJSON): TikTokSearchResult;
|
|
167
|
+
}
|
|
168
|
+
export interface TikTokSearchFilters {
|
|
169
|
+
after_datetime?: string | null;
|
|
170
|
+
before_datetime?: string | null;
|
|
171
|
+
min_likes?: number | null;
|
|
172
|
+
max_likes?: number | null;
|
|
173
|
+
min_views?: number | null;
|
|
174
|
+
max_views?: number | null;
|
|
175
|
+
}
|
|
176
|
+
export interface TikTokSearchStats {
|
|
177
|
+
pages_fetched?: number;
|
|
178
|
+
results_count?: number;
|
|
179
|
+
next_search_cursor?: number | null;
|
|
180
|
+
}
|
|
84
181
|
export interface TikTokProfileTaskJSON {
|
|
85
182
|
task_id: string;
|
|
86
183
|
task_status: 'processing' | 'completed' | 'failed';
|
|
@@ -113,3 +210,35 @@ export declare class TikTokProfileTask {
|
|
|
113
210
|
constructor(data: TikTokProfileTaskJSON);
|
|
114
211
|
static fromJSON(json: TikTokProfileTaskJSON): TikTokProfileTask;
|
|
115
212
|
}
|
|
213
|
+
export interface TikTokSearchTaskJSON {
|
|
214
|
+
task_id: string;
|
|
215
|
+
task_status: 'processing' | 'completed' | 'failed';
|
|
216
|
+
query?: string;
|
|
217
|
+
parallel_search_slices?: number;
|
|
218
|
+
filters?: TikTokSearchFilters;
|
|
219
|
+
stats?: TikTokSearchStats;
|
|
220
|
+
results?: TikTokSearchResultJSON[];
|
|
221
|
+
pagination?: TikTokProfilePagination;
|
|
222
|
+
download_url?: string | null;
|
|
223
|
+
error_message?: string | null;
|
|
224
|
+
created_at?: string | null;
|
|
225
|
+
completed_at?: string | null;
|
|
226
|
+
expires_at?: string | null;
|
|
227
|
+
}
|
|
228
|
+
export declare class TikTokSearchTask {
|
|
229
|
+
task_id: string;
|
|
230
|
+
task_status: 'processing' | 'completed' | 'failed';
|
|
231
|
+
query?: string;
|
|
232
|
+
parallel_search_slices?: number;
|
|
233
|
+
filters?: TikTokSearchFilters;
|
|
234
|
+
stats?: TikTokSearchStats;
|
|
235
|
+
results: TikTokSearchResult[];
|
|
236
|
+
pagination?: TikTokProfilePagination;
|
|
237
|
+
download_url?: string | null;
|
|
238
|
+
error_message?: string | null;
|
|
239
|
+
created_at?: string | null;
|
|
240
|
+
completed_at?: string | null;
|
|
241
|
+
expires_at?: string | null;
|
|
242
|
+
constructor(data: TikTokSearchTaskJSON);
|
|
243
|
+
static fromJSON(json: TikTokSearchTaskJSON): TikTokSearchTask;
|
|
244
|
+
}
|
package/dist/models/TikTok.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TikTokProfileTask = exports.TikTokVideo = exports.TikTokProfileScrapeSubmission = void 0;
|
|
3
|
+
exports.TikTokSearchTask = exports.TikTokProfileTask = exports.TikTokSearchResult = exports.TikTokVideo = exports.TikTokSearchSubmission = exports.TikTokProfileScrapeSubmission = void 0;
|
|
4
4
|
function toInteger(value) {
|
|
5
5
|
if (value === null || value === undefined)
|
|
6
6
|
return value;
|
|
@@ -28,6 +28,18 @@ function normalizeFilters(filters) {
|
|
|
28
28
|
max_likes: toInteger(filters.max_likes),
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
+
function normalizeSearchFilters(filters) {
|
|
32
|
+
if (!filters)
|
|
33
|
+
return undefined;
|
|
34
|
+
return {
|
|
35
|
+
after_datetime: filters.after_datetime,
|
|
36
|
+
before_datetime: filters.before_datetime,
|
|
37
|
+
min_likes: toInteger(filters.min_likes),
|
|
38
|
+
max_likes: toInteger(filters.max_likes),
|
|
39
|
+
min_views: toInteger(filters.min_views),
|
|
40
|
+
max_views: toInteger(filters.max_views),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
31
43
|
function normalizeStats(stats) {
|
|
32
44
|
if (!stats)
|
|
33
45
|
return undefined;
|
|
@@ -37,6 +49,15 @@ function normalizeStats(stats) {
|
|
|
37
49
|
pages_consumed: toOptionalInteger(stats.pages_consumed),
|
|
38
50
|
};
|
|
39
51
|
}
|
|
52
|
+
function normalizeSearchStats(stats) {
|
|
53
|
+
if (!stats)
|
|
54
|
+
return undefined;
|
|
55
|
+
return {
|
|
56
|
+
pages_fetched: toOptionalInteger(stats.pages_fetched),
|
|
57
|
+
results_count: toOptionalInteger(stats.results_count),
|
|
58
|
+
next_search_cursor: toInteger(stats.next_search_cursor),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
40
61
|
function normalizePagination(pagination) {
|
|
41
62
|
if (!pagination)
|
|
42
63
|
return undefined;
|
|
@@ -64,6 +85,23 @@ class TikTokProfileScrapeSubmission {
|
|
|
64
85
|
}
|
|
65
86
|
}
|
|
66
87
|
exports.TikTokProfileScrapeSubmission = TikTokProfileScrapeSubmission;
|
|
88
|
+
class TikTokSearchSubmission {
|
|
89
|
+
constructor(data) {
|
|
90
|
+
this.task_id = data.task_id;
|
|
91
|
+
this.task_status = data.task_status;
|
|
92
|
+
this.query = data.query;
|
|
93
|
+
this.max_results = toOptionalInteger(data.max_results);
|
|
94
|
+
this.parallel_search_slices = toOptionalInteger(data.parallel_search_slices);
|
|
95
|
+
this.filters = data.filters;
|
|
96
|
+
this.expires_at = data.expires_at;
|
|
97
|
+
this.check_status_url = data.check_status_url;
|
|
98
|
+
this.message = data.message;
|
|
99
|
+
}
|
|
100
|
+
static fromJSON(json) {
|
|
101
|
+
return new TikTokSearchSubmission(json);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.TikTokSearchSubmission = TikTokSearchSubmission;
|
|
67
105
|
class TikTokVideo {
|
|
68
106
|
constructor(data) {
|
|
69
107
|
this.id = data.id;
|
|
@@ -86,6 +124,38 @@ class TikTokVideo {
|
|
|
86
124
|
}
|
|
87
125
|
}
|
|
88
126
|
exports.TikTokVideo = TikTokVideo;
|
|
127
|
+
class TikTokSearchResult {
|
|
128
|
+
constructor(data) {
|
|
129
|
+
this.id = data.id;
|
|
130
|
+
this.item_type = toInteger(data.item_type);
|
|
131
|
+
this.description = data.description;
|
|
132
|
+
this.timestamp = toInteger(data.timestamp);
|
|
133
|
+
this.published_at = toNullableDate(data.published_at);
|
|
134
|
+
this.author = data.author;
|
|
135
|
+
this.stats = data.stats
|
|
136
|
+
? {
|
|
137
|
+
views: toInteger(data.stats.views),
|
|
138
|
+
likes: toInteger(data.stats.likes),
|
|
139
|
+
comments: toInteger(data.stats.comments),
|
|
140
|
+
shares: toInteger(data.stats.shares),
|
|
141
|
+
collects: toInteger(data.stats.collects),
|
|
142
|
+
}
|
|
143
|
+
: undefined;
|
|
144
|
+
this.music = data.music
|
|
145
|
+
? {
|
|
146
|
+
...data.music,
|
|
147
|
+
duration: toInteger(data.music.duration),
|
|
148
|
+
}
|
|
149
|
+
: undefined;
|
|
150
|
+
this.duration = toInteger(data.duration);
|
|
151
|
+
this.hashtags = data.hashtags;
|
|
152
|
+
this.url = data.url;
|
|
153
|
+
}
|
|
154
|
+
static fromJSON(json) {
|
|
155
|
+
return new TikTokSearchResult(json);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
exports.TikTokSearchResult = TikTokSearchResult;
|
|
89
159
|
class TikTokProfileTask {
|
|
90
160
|
constructor(data) {
|
|
91
161
|
this.task_id = data.task_id;
|
|
@@ -107,3 +177,24 @@ class TikTokProfileTask {
|
|
|
107
177
|
}
|
|
108
178
|
}
|
|
109
179
|
exports.TikTokProfileTask = TikTokProfileTask;
|
|
180
|
+
class TikTokSearchTask {
|
|
181
|
+
constructor(data) {
|
|
182
|
+
this.task_id = data.task_id;
|
|
183
|
+
this.task_status = data.task_status;
|
|
184
|
+
this.query = data.query;
|
|
185
|
+
this.parallel_search_slices = toOptionalInteger(data.parallel_search_slices);
|
|
186
|
+
this.filters = normalizeSearchFilters(data.filters);
|
|
187
|
+
this.stats = normalizeSearchStats(data.stats);
|
|
188
|
+
this.results = data.results?.map(TikTokSearchResult.fromJSON) ?? [];
|
|
189
|
+
this.pagination = normalizePagination(data.pagination);
|
|
190
|
+
this.download_url = data.download_url;
|
|
191
|
+
this.error_message = data.error_message;
|
|
192
|
+
this.created_at = data.created_at;
|
|
193
|
+
this.completed_at = data.completed_at;
|
|
194
|
+
this.expires_at = data.expires_at;
|
|
195
|
+
}
|
|
196
|
+
static fromJSON(json) {
|
|
197
|
+
return new TikTokSearchTask(json);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
exports.TikTokSearchTask = TikTokSearchTask;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -33,6 +33,11 @@ import {
|
|
|
33
33
|
TikTokProfileScrapeSubmissionJSON,
|
|
34
34
|
TikTokProfileTask,
|
|
35
35
|
TikTokProfileTaskJSON,
|
|
36
|
+
TikTokSearchRequest,
|
|
37
|
+
TikTokSearchSubmission,
|
|
38
|
+
TikTokSearchSubmissionJSON,
|
|
39
|
+
TikTokSearchTask,
|
|
40
|
+
TikTokSearchTaskJSON,
|
|
36
41
|
TweetStatement,
|
|
37
42
|
TweetStatementJSON,
|
|
38
43
|
} from './models';
|
|
@@ -54,7 +59,7 @@ export * from './models';
|
|
|
54
59
|
export * from './errors';
|
|
55
60
|
|
|
56
61
|
/** SDK version (keep in sync with package.json) */
|
|
57
|
-
export const SDK_VERSION = '1.0.
|
|
62
|
+
export const SDK_VERSION = '1.0.4';
|
|
58
63
|
|
|
59
64
|
//region --- Interfaces ---
|
|
60
65
|
export interface SDKConfig {
|
|
@@ -121,6 +126,38 @@ export interface ExtractDataResult {
|
|
|
121
126
|
file_info?: FileInfo;
|
|
122
127
|
usage?: ExtractionTokenUsage;
|
|
123
128
|
}
|
|
129
|
+
|
|
130
|
+
export type ExtractVideoDataPayload = {
|
|
131
|
+
video_url: string;
|
|
132
|
+
schema: ExtractionSchema;
|
|
133
|
+
what_to_extract?: string;
|
|
134
|
+
transcribe?: boolean;
|
|
135
|
+
include_usage?: boolean;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export type ExtractVideoDataMultipartPayload = {
|
|
139
|
+
video_url: string;
|
|
140
|
+
/** Path to a JSON or YAML schema file. The API accepts either a raw schema or a full extraction request object. */
|
|
141
|
+
schemaFilePath: string;
|
|
142
|
+
what_to_extract?: string;
|
|
143
|
+
transcribe?: boolean;
|
|
144
|
+
include_usage?: boolean;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export type ExtractFileDataPayload = {
|
|
148
|
+
file_id: string;
|
|
149
|
+
schema: ExtractionSchema;
|
|
150
|
+
what_to_extract?: string;
|
|
151
|
+
include_usage?: boolean;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
export type ExtractFileDataMultipartPayload = {
|
|
155
|
+
file_id: string;
|
|
156
|
+
/** Path to a JSON or YAML schema file. The API accepts either a raw schema or a full extraction request object. */
|
|
157
|
+
schemaFilePath: string;
|
|
158
|
+
what_to_extract?: string;
|
|
159
|
+
include_usage?: boolean;
|
|
160
|
+
};
|
|
124
161
|
//endregion
|
|
125
162
|
|
|
126
163
|
function parseApiErrorPayload(data: any): {
|
|
@@ -137,6 +174,12 @@ function parseApiErrorPayload(data: any): {
|
|
|
137
174
|
return { errorCode, errorMessage, details: data };
|
|
138
175
|
}
|
|
139
176
|
|
|
177
|
+
function appendOptionalFormField(form: FormData, name: string, value: string | number | boolean | undefined): void {
|
|
178
|
+
if (value !== undefined) {
|
|
179
|
+
form.append(name, String(value));
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
140
183
|
export class VidNavigatorClient {
|
|
141
184
|
private client: AxiosInstance;
|
|
142
185
|
|
|
@@ -303,6 +346,28 @@ export class VidNavigatorClient {
|
|
|
303
346
|
);
|
|
304
347
|
return TikTokProfileTask.fromJSON(response.data);
|
|
305
348
|
}
|
|
349
|
+
|
|
350
|
+
async submitTikTokSearch(payload: TikTokSearchRequest): Promise<TikTokSearchSubmission> {
|
|
351
|
+
const response = await this.request<ApiSuccessResponse<TikTokSearchSubmissionJSON>>(
|
|
352
|
+
'POST',
|
|
353
|
+
'/tiktok/search',
|
|
354
|
+
payload
|
|
355
|
+
);
|
|
356
|
+
return TikTokSearchSubmission.fromJSON(response.data);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
async getTikTokSearch(
|
|
360
|
+
task_id: string,
|
|
361
|
+
query?: { cursor?: string; limit?: number }
|
|
362
|
+
): Promise<TikTokSearchTask> {
|
|
363
|
+
const response = await this.request<ApiSuccessResponse<TikTokSearchTaskJSON>>(
|
|
364
|
+
'GET',
|
|
365
|
+
`/tiktok/search/${task_id}`,
|
|
366
|
+
undefined,
|
|
367
|
+
query
|
|
368
|
+
);
|
|
369
|
+
return TikTokSearchTask.fromJSON(response.data);
|
|
370
|
+
}
|
|
306
371
|
//endregion
|
|
307
372
|
|
|
308
373
|
//region --- Files ---
|
|
@@ -577,13 +642,30 @@ export class VidNavigatorClient {
|
|
|
577
642
|
//endregion
|
|
578
643
|
|
|
579
644
|
//region --- Extraction ---
|
|
580
|
-
async extractVideoData(
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
645
|
+
async extractVideoData(
|
|
646
|
+
payload: ExtractVideoDataPayload | ExtractVideoDataMultipartPayload
|
|
647
|
+
): Promise<ExtractDataResult> {
|
|
648
|
+
if ('schemaFilePath' in payload) {
|
|
649
|
+
const form = new FormData();
|
|
650
|
+
form.append('video_url', payload.video_url);
|
|
651
|
+
form.append('schema', fs.createReadStream(payload.schemaFilePath));
|
|
652
|
+
appendOptionalFormField(form, 'what_to_extract', payload.what_to_extract);
|
|
653
|
+
appendOptionalFormField(form, 'transcribe', payload.transcribe);
|
|
654
|
+
appendOptionalFormField(form, 'include_usage', payload.include_usage);
|
|
655
|
+
|
|
656
|
+
const body = await this.request<{
|
|
657
|
+
status: 'success';
|
|
658
|
+
data: Record<string, unknown>;
|
|
659
|
+
video_info?: VideoInfoJSON;
|
|
660
|
+
usage?: ExtractionTokenUsageJSON;
|
|
661
|
+
}>('POST', '/extract/video', form, undefined, form.getHeaders());
|
|
662
|
+
return {
|
|
663
|
+
data: body.data,
|
|
664
|
+
video_info: body.video_info ? VideoInfo.fromJSON(body.video_info) : undefined,
|
|
665
|
+
usage: body.usage ? ExtractionTokenUsage.fromJSON(body.usage) : undefined,
|
|
666
|
+
};
|
|
667
|
+
}
|
|
668
|
+
|
|
587
669
|
const body = await this.request<{
|
|
588
670
|
status: 'success';
|
|
589
671
|
data: Record<string, unknown>;
|
|
@@ -597,12 +679,29 @@ export class VidNavigatorClient {
|
|
|
597
679
|
};
|
|
598
680
|
}
|
|
599
681
|
|
|
600
|
-
async extractFileData(
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
682
|
+
async extractFileData(
|
|
683
|
+
payload: ExtractFileDataPayload | ExtractFileDataMultipartPayload
|
|
684
|
+
): Promise<ExtractDataResult> {
|
|
685
|
+
if ('schemaFilePath' in payload) {
|
|
686
|
+
const form = new FormData();
|
|
687
|
+
form.append('file_id', payload.file_id);
|
|
688
|
+
form.append('schema', fs.createReadStream(payload.schemaFilePath));
|
|
689
|
+
appendOptionalFormField(form, 'what_to_extract', payload.what_to_extract);
|
|
690
|
+
appendOptionalFormField(form, 'include_usage', payload.include_usage);
|
|
691
|
+
|
|
692
|
+
const body = await this.request<{
|
|
693
|
+
status: 'success';
|
|
694
|
+
data: Record<string, unknown>;
|
|
695
|
+
file_info?: FileInfoJSON;
|
|
696
|
+
usage?: ExtractionTokenUsageJSON;
|
|
697
|
+
}>('POST', '/extract/file', form, undefined, form.getHeaders());
|
|
698
|
+
return {
|
|
699
|
+
data: body.data,
|
|
700
|
+
file_info: body.file_info ? FileInfo.fromJSON(body.file_info) : undefined,
|
|
701
|
+
usage: body.usage ? ExtractionTokenUsage.fromJSON(body.usage) : undefined,
|
|
702
|
+
};
|
|
703
|
+
}
|
|
704
|
+
|
|
606
705
|
const body = await this.request<{
|
|
607
706
|
status: 'success';
|
|
608
707
|
data: Record<string, unknown>;
|
package/src/models/TikTok.ts
CHANGED
|
@@ -9,6 +9,20 @@ export interface TikTokProfileScrapeRequest {
|
|
|
9
9
|
max_likes?: number;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
export interface TikTokSearchRequest {
|
|
13
|
+
query: string;
|
|
14
|
+
max_results?: number;
|
|
15
|
+
parallel_search_slices?: number;
|
|
16
|
+
/** Format: YYYY-MM-DD or ISO datetime with timezone */
|
|
17
|
+
after_datetime?: string;
|
|
18
|
+
/** Format: YYYY-MM-DD or ISO datetime with timezone */
|
|
19
|
+
before_datetime?: string;
|
|
20
|
+
min_likes?: number;
|
|
21
|
+
max_likes?: number;
|
|
22
|
+
min_views?: number;
|
|
23
|
+
max_views?: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
12
26
|
function toInteger(value: number | null | undefined): number | null | undefined {
|
|
13
27
|
if (value === null || value === undefined) return value;
|
|
14
28
|
return Math.trunc(value);
|
|
@@ -36,6 +50,20 @@ function normalizeFilters(filters: TikTokProfileFilters | undefined): TikTokProf
|
|
|
36
50
|
};
|
|
37
51
|
}
|
|
38
52
|
|
|
53
|
+
function normalizeSearchFilters(
|
|
54
|
+
filters: TikTokSearchFilters | undefined
|
|
55
|
+
): TikTokSearchFilters | undefined {
|
|
56
|
+
if (!filters) return undefined;
|
|
57
|
+
return {
|
|
58
|
+
after_datetime: filters.after_datetime,
|
|
59
|
+
before_datetime: filters.before_datetime,
|
|
60
|
+
min_likes: toInteger(filters.min_likes),
|
|
61
|
+
max_likes: toInteger(filters.max_likes),
|
|
62
|
+
min_views: toInteger(filters.min_views),
|
|
63
|
+
max_views: toInteger(filters.max_views),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
39
67
|
function normalizeStats(stats: TikTokProfileStats | undefined): TikTokProfileStats | undefined {
|
|
40
68
|
if (!stats) return undefined;
|
|
41
69
|
return {
|
|
@@ -45,6 +73,15 @@ function normalizeStats(stats: TikTokProfileStats | undefined): TikTokProfileSta
|
|
|
45
73
|
};
|
|
46
74
|
}
|
|
47
75
|
|
|
76
|
+
function normalizeSearchStats(stats: TikTokSearchStats | undefined): TikTokSearchStats | undefined {
|
|
77
|
+
if (!stats) return undefined;
|
|
78
|
+
return {
|
|
79
|
+
pages_fetched: toOptionalInteger(stats.pages_fetched),
|
|
80
|
+
results_count: toOptionalInteger(stats.results_count),
|
|
81
|
+
next_search_cursor: toInteger(stats.next_search_cursor),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
48
85
|
function normalizePagination(
|
|
49
86
|
pagination: TikTokProfilePagination | undefined
|
|
50
87
|
): TikTokProfilePagination | undefined {
|
|
@@ -91,6 +128,46 @@ export class TikTokProfileScrapeSubmission {
|
|
|
91
128
|
}
|
|
92
129
|
}
|
|
93
130
|
|
|
131
|
+
export interface TikTokSearchSubmissionJSON {
|
|
132
|
+
task_id: string;
|
|
133
|
+
task_status: 'processing';
|
|
134
|
+
query: string;
|
|
135
|
+
max_results?: number;
|
|
136
|
+
parallel_search_slices?: number;
|
|
137
|
+
filters?: Record<string, unknown>;
|
|
138
|
+
expires_at?: string;
|
|
139
|
+
check_status_url?: string;
|
|
140
|
+
message?: string;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export class TikTokSearchSubmission {
|
|
144
|
+
task_id: string;
|
|
145
|
+
task_status: 'processing';
|
|
146
|
+
query: string;
|
|
147
|
+
max_results?: number;
|
|
148
|
+
parallel_search_slices?: number;
|
|
149
|
+
filters?: Record<string, unknown>;
|
|
150
|
+
expires_at?: string;
|
|
151
|
+
check_status_url?: string;
|
|
152
|
+
message?: string;
|
|
153
|
+
|
|
154
|
+
constructor(data: TikTokSearchSubmissionJSON) {
|
|
155
|
+
this.task_id = data.task_id;
|
|
156
|
+
this.task_status = data.task_status;
|
|
157
|
+
this.query = data.query;
|
|
158
|
+
this.max_results = toOptionalInteger(data.max_results);
|
|
159
|
+
this.parallel_search_slices = toOptionalInteger(data.parallel_search_slices);
|
|
160
|
+
this.filters = data.filters;
|
|
161
|
+
this.expires_at = data.expires_at;
|
|
162
|
+
this.check_status_url = data.check_status_url;
|
|
163
|
+
this.message = data.message;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
static fromJSON(json: TikTokSearchSubmissionJSON): TikTokSearchSubmission {
|
|
167
|
+
return new TikTokSearchSubmission(json);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
94
171
|
export interface TikTokVideoJSON {
|
|
95
172
|
id?: string;
|
|
96
173
|
track?: string | null;
|
|
@@ -170,6 +247,102 @@ export interface TikTokProfilePagination {
|
|
|
170
247
|
prev_cursor?: string | null;
|
|
171
248
|
}
|
|
172
249
|
|
|
250
|
+
export interface TikTokSearchAuthor {
|
|
251
|
+
id?: string | null;
|
|
252
|
+
unique_id?: string | null;
|
|
253
|
+
nickname?: string | null;
|
|
254
|
+
sec_uid?: string | null;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export interface TikTokSearchResultStats {
|
|
258
|
+
views?: number | null;
|
|
259
|
+
likes?: number | null;
|
|
260
|
+
comments?: number | null;
|
|
261
|
+
shares?: number | null;
|
|
262
|
+
collects?: number | null;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export interface TikTokSearchMusic {
|
|
266
|
+
id?: string | null;
|
|
267
|
+
title?: string | null;
|
|
268
|
+
author_name?: string | null;
|
|
269
|
+
duration?: number | null;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export interface TikTokSearchResultJSON {
|
|
273
|
+
id?: string | null;
|
|
274
|
+
item_type?: number | null;
|
|
275
|
+
description?: string | null;
|
|
276
|
+
timestamp?: number | null;
|
|
277
|
+
published_at?: string | null;
|
|
278
|
+
author?: TikTokSearchAuthor;
|
|
279
|
+
stats?: TikTokSearchResultStats;
|
|
280
|
+
music?: TikTokSearchMusic;
|
|
281
|
+
duration?: number | null;
|
|
282
|
+
hashtags?: string[];
|
|
283
|
+
url?: string | null;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export class TikTokSearchResult {
|
|
287
|
+
id?: string | null;
|
|
288
|
+
item_type?: number | null;
|
|
289
|
+
description?: string | null;
|
|
290
|
+
timestamp?: number | null;
|
|
291
|
+
published_at?: Date | null;
|
|
292
|
+
author?: TikTokSearchAuthor;
|
|
293
|
+
stats?: TikTokSearchResultStats;
|
|
294
|
+
music?: TikTokSearchMusic;
|
|
295
|
+
duration?: number | null;
|
|
296
|
+
hashtags?: string[];
|
|
297
|
+
url?: string | null;
|
|
298
|
+
|
|
299
|
+
constructor(data: TikTokSearchResultJSON) {
|
|
300
|
+
this.id = data.id;
|
|
301
|
+
this.item_type = toInteger(data.item_type);
|
|
302
|
+
this.description = data.description;
|
|
303
|
+
this.timestamp = toInteger(data.timestamp);
|
|
304
|
+
this.published_at = toNullableDate(data.published_at);
|
|
305
|
+
this.author = data.author;
|
|
306
|
+
this.stats = data.stats
|
|
307
|
+
? {
|
|
308
|
+
views: toInteger(data.stats.views),
|
|
309
|
+
likes: toInteger(data.stats.likes),
|
|
310
|
+
comments: toInteger(data.stats.comments),
|
|
311
|
+
shares: toInteger(data.stats.shares),
|
|
312
|
+
collects: toInteger(data.stats.collects),
|
|
313
|
+
}
|
|
314
|
+
: undefined;
|
|
315
|
+
this.music = data.music
|
|
316
|
+
? {
|
|
317
|
+
...data.music,
|
|
318
|
+
duration: toInteger(data.music.duration),
|
|
319
|
+
}
|
|
320
|
+
: undefined;
|
|
321
|
+
this.duration = toInteger(data.duration);
|
|
322
|
+
this.hashtags = data.hashtags;
|
|
323
|
+
this.url = data.url;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
static fromJSON(json: TikTokSearchResultJSON): TikTokSearchResult {
|
|
327
|
+
return new TikTokSearchResult(json);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
export interface TikTokSearchFilters {
|
|
332
|
+
after_datetime?: string | null;
|
|
333
|
+
before_datetime?: string | null;
|
|
334
|
+
min_likes?: number | null;
|
|
335
|
+
max_likes?: number | null;
|
|
336
|
+
min_views?: number | null;
|
|
337
|
+
max_views?: number | null;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export interface TikTokSearchStats {
|
|
341
|
+
pages_fetched?: number;
|
|
342
|
+
results_count?: number;
|
|
343
|
+
next_search_cursor?: number | null;
|
|
344
|
+
}
|
|
345
|
+
|
|
173
346
|
export interface TikTokProfileTaskJSON {
|
|
174
347
|
task_id: string;
|
|
175
348
|
task_status: 'processing' | 'completed' | 'failed';
|
|
@@ -221,3 +394,55 @@ export class TikTokProfileTask {
|
|
|
221
394
|
return new TikTokProfileTask(json);
|
|
222
395
|
}
|
|
223
396
|
}
|
|
397
|
+
|
|
398
|
+
export interface TikTokSearchTaskJSON {
|
|
399
|
+
task_id: string;
|
|
400
|
+
task_status: 'processing' | 'completed' | 'failed';
|
|
401
|
+
query?: string;
|
|
402
|
+
parallel_search_slices?: number;
|
|
403
|
+
filters?: TikTokSearchFilters;
|
|
404
|
+
stats?: TikTokSearchStats;
|
|
405
|
+
results?: TikTokSearchResultJSON[];
|
|
406
|
+
pagination?: TikTokProfilePagination;
|
|
407
|
+
download_url?: string | null;
|
|
408
|
+
error_message?: string | null;
|
|
409
|
+
created_at?: string | null;
|
|
410
|
+
completed_at?: string | null;
|
|
411
|
+
expires_at?: string | null;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
export class TikTokSearchTask {
|
|
415
|
+
task_id: string;
|
|
416
|
+
task_status: 'processing' | 'completed' | 'failed';
|
|
417
|
+
query?: string;
|
|
418
|
+
parallel_search_slices?: number;
|
|
419
|
+
filters?: TikTokSearchFilters;
|
|
420
|
+
stats?: TikTokSearchStats;
|
|
421
|
+
results: TikTokSearchResult[];
|
|
422
|
+
pagination?: TikTokProfilePagination;
|
|
423
|
+
download_url?: string | null;
|
|
424
|
+
error_message?: string | null;
|
|
425
|
+
created_at?: string | null;
|
|
426
|
+
completed_at?: string | null;
|
|
427
|
+
expires_at?: string | null;
|
|
428
|
+
|
|
429
|
+
constructor(data: TikTokSearchTaskJSON) {
|
|
430
|
+
this.task_id = data.task_id;
|
|
431
|
+
this.task_status = data.task_status;
|
|
432
|
+
this.query = data.query;
|
|
433
|
+
this.parallel_search_slices = toOptionalInteger(data.parallel_search_slices);
|
|
434
|
+
this.filters = normalizeSearchFilters(data.filters);
|
|
435
|
+
this.stats = normalizeSearchStats(data.stats);
|
|
436
|
+
this.results = data.results?.map(TikTokSearchResult.fromJSON) ?? [];
|
|
437
|
+
this.pagination = normalizePagination(data.pagination);
|
|
438
|
+
this.download_url = data.download_url;
|
|
439
|
+
this.error_message = data.error_message;
|
|
440
|
+
this.created_at = data.created_at;
|
|
441
|
+
this.completed_at = data.completed_at;
|
|
442
|
+
this.expires_at = data.expires_at;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
static fromJSON(json: TikTokSearchTaskJSON): TikTokSearchTask {
|
|
446
|
+
return new TikTokSearchTask(json);
|
|
447
|
+
}
|
|
448
|
+
}
|