ensembledata 0.0.3 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/client.js CHANGED
@@ -17,28 +17,32 @@ class CustomerEndpoints {
17
17
 
18
18
  /**
19
19
  * @param {{ date: string }} params
20
- * @param {Record<string, any>} extraParams
20
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
21
21
  * @returns {Promise<EDResponse>}
22
22
  */
23
- getUsage({ date }, extraParams = {}) {
23
+ getUsage({ date }, options = {}) {
24
24
  const params = filterUndefinedValues({
25
- ...extraParams,
25
+ ...options.extraParams,
26
26
  date,
27
27
  });
28
- return this.#requester.get("/customer/get-used-units", params);
28
+ return this.#requester.get("/customer/get-used-units", params, {
29
+ timeout: options.timeout,
30
+ });
29
31
  }
30
32
 
31
33
  /**
32
34
  * @param {{ days: number }} params
33
- * @param {Record<string, any>} extraParams
35
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
34
36
  * @returns {Promise<EDResponse>}
35
37
  */
36
- getUsageHistory({ days }, extraParams = {}) {
38
+ getUsageHistory({ days }, options = {}) {
37
39
  const params = filterUndefinedValues({
38
- ...extraParams,
40
+ ...options.extraParams,
39
41
  days,
40
42
  });
41
- return this.#requester.get("/customer/get-history", params);
43
+ return this.#requester.get("/customer/get-history", params, {
44
+ timeout: options.timeout,
45
+ });
42
46
  }
43
47
  }
44
48
 
@@ -56,16 +60,18 @@ class TiktokEndpoints {
56
60
 
57
61
  /**
58
62
  * @param {{ hashtag: string; cursor?: number }} params
59
- * @param {Record<string, any>} extraParams
63
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
60
64
  * @returns {Promise<EDResponse>}
61
65
  */
62
- hashtagSearch({ hashtag, cursor = undefined }, extraParams = {}) {
66
+ hashtagSearch({ hashtag, cursor = undefined }, options = {}) {
63
67
  const params = filterUndefinedValues({
64
- ...extraParams,
68
+ ...options.extraParams,
65
69
  name: hashtag,
66
70
  cursor,
67
71
  });
68
- return this.#requester.get("/tt/hashtag/posts", params);
72
+ return this.#requester.get("/tt/hashtag/posts", params, {
73
+ timeout: options.timeout,
74
+ });
69
75
  }
70
76
 
71
77
  /**
@@ -75,21 +81,23 @@ class TiktokEndpoints {
75
81
  * remapOutput?: boolean;
76
82
  * maxCursor?: number;
77
83
  * }} params
78
- * @param {Record<string, any>} extraParams
84
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
79
85
  * @returns {Promise<EDResponse>}
80
86
  */
81
87
  fullHashtagSearch(
82
88
  { hashtag, days, remapOutput = undefined, maxCursor = undefined },
83
- extraParams = {},
89
+ options = {},
84
90
  ) {
85
91
  const params = filterUndefinedValues({
86
- ...extraParams,
92
+ ...options.extraParams,
87
93
  name: hashtag,
88
94
  days,
89
95
  remap_output: remapOutput,
90
96
  max_cursor: maxCursor,
91
97
  });
92
- return this.#requester.get("/tt/hashtag/recent-posts", params);
98
+ return this.#requester.get("/tt/hashtag/recent-posts", params, {
99
+ timeout: options.timeout,
100
+ });
93
101
  }
94
102
 
95
103
  /**
@@ -97,12 +105,12 @@ class TiktokEndpoints {
97
105
  * keyword: string;
98
106
  * cursor?: number;
99
107
  * period: "0" | "1" | "7" | "30" | "90" | "180";
100
- * sorting: "0" | "1";
108
+ * sorting?: "0" | "1";
101
109
  * country?: string;
102
110
  * matchExactly?: boolean;
103
111
  * getAuthorStats?: boolean;
104
112
  * }} params
105
- * @param {Record<string, any>} extraParams
113
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
106
114
  * @returns {Promise<EDResponse>}
107
115
  */
108
116
  keywordSearch(
@@ -110,15 +118,15 @@ class TiktokEndpoints {
110
118
  keyword,
111
119
  cursor = undefined,
112
120
  period,
113
- sorting,
121
+ sorting = undefined,
114
122
  country = undefined,
115
123
  matchExactly = undefined,
116
124
  getAuthorStats = undefined,
117
125
  },
118
- extraParams = {},
126
+ options = {},
119
127
  ) {
120
128
  const params = filterUndefinedValues({
121
- ...extraParams,
129
+ ...options.extraParams,
122
130
  name: keyword,
123
131
  cursor,
124
132
  period,
@@ -127,7 +135,9 @@ class TiktokEndpoints {
127
135
  match_exactly: matchExactly,
128
136
  get_author_stats: getAuthorStats,
129
137
  });
130
- return this.#requester.get("/tt/keyword/search", params);
138
+ return this.#requester.get("/tt/keyword/search", params, {
139
+ timeout: options.timeout,
140
+ });
131
141
  }
132
142
 
133
143
  /**
@@ -138,7 +148,7 @@ class TiktokEndpoints {
138
148
  * country?: string;
139
149
  * matchExactly?: boolean;
140
150
  * }} params
141
- * @param {Record<string, any>} extraParams
151
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
142
152
  * @returns {Promise<EDResponse>}
143
153
  */
144
154
  fullKeywordSearch(
@@ -149,17 +159,19 @@ class TiktokEndpoints {
149
159
  country = undefined,
150
160
  matchExactly = undefined,
151
161
  },
152
- extraParams = {},
162
+ options = {},
153
163
  ) {
154
164
  const params = filterUndefinedValues({
155
- ...extraParams,
165
+ ...options.extraParams,
156
166
  name: keyword,
157
167
  period,
158
168
  sorting,
159
169
  country,
160
170
  match_exactly: matchExactly,
161
171
  });
162
- return this.#requester.get("/tt/keyword/full-search", params);
172
+ return this.#requester.get("/tt/keyword/full-search", params, {
173
+ timeout: options.timeout,
174
+ });
163
175
  }
164
176
 
165
177
  /**
@@ -170,7 +182,7 @@ class TiktokEndpoints {
170
182
  * oldestCreatetime?: number;
171
183
  * alternativeMethod?: boolean;
172
184
  * }} params
173
- * @param {Record<string, any>} extraParams
185
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
174
186
  * @returns {Promise<EDResponse>}
175
187
  */
176
188
  userPostsFromUsername(
@@ -181,17 +193,20 @@ class TiktokEndpoints {
181
193
  oldestCreatetime = undefined,
182
194
  alternativeMethod = undefined,
183
195
  },
184
- extraParams = {},
196
+ options = {},
185
197
  ) {
186
198
  const params = filterUndefinedValues({
187
- ...extraParams,
199
+ ...options.extraParams,
188
200
  username,
189
201
  depth,
190
202
  start_cursor: cursor,
191
203
  oldest_createtime: oldestCreatetime,
192
204
  alternative_method: alternativeMethod,
193
205
  });
194
- return this.#requester.get("/tt/user/posts", params);
206
+ return this.#requester.get("/tt/user/posts", params, {
207
+ timeout: options.timeout,
208
+ returnTopLevelData: true,
209
+ });
195
210
  }
196
211
 
197
212
  /**
@@ -202,7 +217,7 @@ class TiktokEndpoints {
202
217
  * oldestCreatetime?: number;
203
218
  * alternativeMethod?: boolean;
204
219
  * }} params
205
- * @param {Record<string, any>} extraParams
220
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
206
221
  * @returns {Promise<EDResponse>}
207
222
  */
208
223
  userPostsFromSecuid(
@@ -213,185 +228,215 @@ class TiktokEndpoints {
213
228
  oldestCreatetime = undefined,
214
229
  alternativeMethod = undefined,
215
230
  },
216
- extraParams = {},
231
+ options = {},
217
232
  ) {
218
233
  const params = filterUndefinedValues({
219
- ...extraParams,
234
+ ...options.extraParams,
220
235
  secUid,
221
236
  depth,
222
237
  start_cursor: cursor,
223
238
  oldest_createtime: oldestCreatetime,
224
239
  alternative_method: alternativeMethod,
225
240
  });
226
- return this.#requester.get("/tt/user/posts-from-secuid", params);
241
+ return this.#requester.get("/tt/user/posts-from-secuid", params, {
242
+ timeout: options.timeout,
243
+ returnTopLevelData: true,
244
+ });
227
245
  }
228
246
 
229
247
  /**
230
248
  * @param {{ username: string }} params
231
- * @param {Record<string, any>} extraParams
249
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
232
250
  * @returns {Promise<EDResponse>}
233
251
  */
234
- userInfoFromUsername({ username }, extraParams = {}) {
252
+ userInfoFromUsername({ username }, options = {}) {
235
253
  const params = filterUndefinedValues({
236
- ...extraParams,
254
+ ...options.extraParams,
237
255
  username,
238
256
  });
239
- return this.#requester.get("/tt/user/info", params);
257
+ return this.#requester.get("/tt/user/info", params, {
258
+ timeout: options.timeout,
259
+ });
240
260
  }
241
261
 
242
262
  /**
243
263
  * @param {{ secUid: string; alternativeMethod?: boolean }} params
244
- * @param {Record<string, any>} extraParams
264
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
245
265
  * @returns {Promise<EDResponse>}
246
266
  */
247
267
  userInfoFromSecuid(
248
268
  { secUid, alternativeMethod = undefined },
249
- extraParams = {},
269
+ options = {},
250
270
  ) {
251
271
  const params = filterUndefinedValues({
252
- ...extraParams,
272
+ ...options.extraParams,
253
273
  secUid,
254
274
  alternative_method: alternativeMethod,
255
275
  });
256
- return this.#requester.get("/tt/user/info-from-secuid", params);
276
+ return this.#requester.get("/tt/user/info-from-secuid", params, {
277
+ timeout: options.timeout,
278
+ });
257
279
  }
258
280
 
259
281
  /**
260
282
  * @param {{ keyword: string; cursor?: number }} params
261
- * @param {Record<string, any>} extraParams
283
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
262
284
  * @returns {Promise<EDResponse>}
263
285
  */
264
- userSearch({ keyword, cursor = undefined }, extraParams = {}) {
286
+ userSearch({ keyword, cursor = undefined }, options = {}) {
265
287
  const params = filterUndefinedValues({
266
- ...extraParams,
288
+ ...options.extraParams,
267
289
  keyword,
268
290
  cursor,
269
291
  });
270
- return this.#requester.get("/tt/user/search", params);
292
+ return this.#requester.get("/tt/user/search", params, {
293
+ timeout: options.timeout,
294
+ });
271
295
  }
272
296
 
273
297
  /**
274
298
  * @param {{ url: string }} params
275
- * @param {Record<string, any>} extraParams
299
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
276
300
  * @returns {Promise<EDResponse>}
277
301
  */
278
- postInfo({ url }, extraParams = {}) {
302
+ postInfo({ url }, options = {}) {
279
303
  const params = filterUndefinedValues({
280
- ...extraParams,
304
+ ...options.extraParams,
281
305
  url,
282
306
  });
283
- return this.#requester.get("/tt/post/info", params);
307
+ return this.#requester.get("/tt/post/info", params, {
308
+ timeout: options.timeout,
309
+ });
284
310
  }
285
311
 
286
312
  /**
287
313
  * @param {{ awemeIds: string[] }} params
288
- * @param {Record<string, any>} extraParams
314
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
289
315
  * @returns {Promise<EDResponse>}
290
316
  */
291
- multiPostInfo({ awemeIds }, extraParams = {}) {
317
+ multiPostInfo({ awemeIds }, options = {}) {
292
318
  const params = filterUndefinedValues({
293
- ...extraParams,
319
+ ...options.extraParams,
294
320
  ids: awemeIds.join(";"),
295
321
  });
296
- return this.#requester.get("/tt/post/multi-info", params);
322
+ return this.#requester.get("/tt/post/multi-info", params, {
323
+ timeout: options.timeout,
324
+ });
297
325
  }
298
326
 
299
327
  /**
300
328
  * @param {{ awemeId: string; cursor?: number }} params
301
- * @param {Record<string, any>} extraParams
329
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
302
330
  * @returns {Promise<EDResponse>}
303
331
  */
304
- postComments({ awemeId, cursor = undefined }, extraParams = {}) {
332
+ postComments({ awemeId, cursor = undefined }, options = {}) {
305
333
  const params = filterUndefinedValues({
306
- ...extraParams,
334
+ ...options.extraParams,
307
335
  aweme_id: awemeId,
308
336
  cursor,
309
337
  });
310
- return this.#requester.get("/tt/post/comments", params);
338
+ return this.#requester.get("/tt/post/comments", params, {
339
+ timeout: options.timeout,
340
+ });
311
341
  }
312
342
 
313
343
  /**
314
344
  * @param {{ awemeId: string; commentId: string; cursor?: number }} params
315
- * @param {Record<string, any>} extraParams
345
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
316
346
  * @returns {Promise<EDResponse>}
317
347
  */
318
348
  postCommentReplies(
319
349
  { awemeId, commentId, cursor = undefined },
320
- extraParams = {},
350
+ options = {},
321
351
  ) {
322
352
  const params = filterUndefinedValues({
323
- ...extraParams,
353
+ ...options.extraParams,
324
354
  aweme_id: awemeId,
325
355
  comment_id: commentId,
326
356
  cursor,
327
357
  });
328
- return this.#requester.get("/tt/post/comments-replies", params);
358
+ return this.#requester.get("/tt/post/comments-replies", params, {
359
+ timeout: options.timeout,
360
+ });
329
361
  }
330
362
 
331
363
  /**
332
364
  * @param {{
333
365
  * keyword: string;
334
366
  * cursor?: number;
335
- * sorting: "0" | "1" | "2" | "3" | "4";
336
- * filterBy: "0" | "1" | "2";
367
+ * sorting?: "0" | "1" | "2" | "3" | "4";
368
+ * filterBy?: "0" | "1" | "2";
337
369
  * }} params
338
- * @param {Record<string, any>} extraParams
370
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
339
371
  * @returns {Promise<EDResponse>}
340
372
  */
341
373
  musicSearch(
342
- { keyword, cursor = undefined, sorting, filterBy },
343
- extraParams = {},
374
+ {
375
+ keyword,
376
+ cursor = undefined,
377
+ sorting = undefined,
378
+ filterBy = undefined,
379
+ },
380
+ options = {},
344
381
  ) {
345
382
  const params = filterUndefinedValues({
346
- ...extraParams,
383
+ ...options.extraParams,
347
384
  name: keyword,
348
385
  cursor,
349
386
  sorting,
350
387
  filter_by: filterBy,
351
388
  });
352
- return this.#requester.get("/tt/music/info", params);
389
+ return this.#requester.get("/tt/music/info", params, {
390
+ timeout: options.timeout,
391
+ });
353
392
  }
354
393
 
355
394
  /**
356
395
  * @param {{ musicId: string; cursor?: number }} params
357
- * @param {Record<string, any>} extraParams
396
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
358
397
  * @returns {Promise<EDResponse>}
359
398
  */
360
- musicPosts({ musicId, cursor = undefined }, extraParams = {}) {
399
+ musicPosts({ musicId, cursor = undefined }, options = {}) {
361
400
  const params = filterUndefinedValues({
362
- ...extraParams,
401
+ ...options.extraParams,
363
402
  music_id: musicId,
364
403
  cursor,
365
404
  });
366
- return this.#requester.get("/tt/music/posts", params);
405
+ return this.#requester.get("/tt/music/posts", params, {
406
+ timeout: options.timeout,
407
+ });
367
408
  }
368
409
 
369
410
  /**
370
411
  * @param {{ musicId: string }} params
371
- * @param {Record<string, any>} extraParams
412
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
372
413
  * @returns {Promise<EDResponse>}
373
414
  */
374
- musicDetails({ musicId }, extraParams = {}) {
415
+ musicDetails({ musicId }, options = {}) {
375
416
  const params = filterUndefinedValues({
376
- ...extraParams,
417
+ ...options.extraParams,
377
418
  id: musicId,
378
419
  });
379
- return this.#requester.get("/tt/music/details", params);
420
+ return this.#requester.get("/tt/music/details", params, {
421
+ timeout: options.timeout,
422
+ });
380
423
  }
381
424
 
382
425
  /**
383
426
  * @param {{ id: string; secUid: string; cursor?: number }} params
384
- * @param {Record<string, any>} extraParams
427
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
385
428
  * @returns {Promise<EDResponse>}
386
429
  */
387
- userFollowers({ id, secUid, cursor = undefined }, extraParams = {}) {
430
+ userFollowers({ id, secUid, cursor = undefined }, options = {}) {
388
431
  const params = filterUndefinedValues({
389
- ...extraParams,
432
+ ...options.extraParams,
390
433
  id,
391
434
  secUid,
392
435
  cursor,
393
436
  });
394
- return this.#requester.get("/tt/user/followers", params);
437
+ return this.#requester.get("/tt/user/followers", params, {
438
+ timeout: options.timeout,
439
+ });
395
440
  }
396
441
 
397
442
  /**
@@ -401,35 +446,39 @@ class TiktokEndpoints {
401
446
  * cursor?: number;
402
447
  * pageToken?: string;
403
448
  * }} params
404
- * @param {Record<string, any>} extraParams
449
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
405
450
  * @returns {Promise<EDResponse>}
406
451
  */
407
452
  userFollowings(
408
453
  { id, secUid, cursor = undefined, pageToken = undefined },
409
- extraParams = {},
454
+ options = {},
410
455
  ) {
411
456
  const params = filterUndefinedValues({
412
- ...extraParams,
457
+ ...options.extraParams,
413
458
  id,
414
459
  secUid,
415
460
  cursor,
416
461
  page_token: pageToken,
417
462
  });
418
- return this.#requester.get("/tt/user/followings", params);
463
+ return this.#requester.get("/tt/user/followings", params, {
464
+ timeout: options.timeout,
465
+ });
419
466
  }
420
467
 
421
468
  /**
422
469
  * @param {{ secUid: string; cursor?: number }} params
423
- * @param {Record<string, any>} extraParams
470
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
424
471
  * @returns {Promise<EDResponse>}
425
472
  */
426
- userLikedPosts({ secUid, cursor = undefined }, extraParams = {}) {
473
+ userLikedPosts({ secUid, cursor = undefined }, options = {}) {
427
474
  const params = filterUndefinedValues({
428
- ...extraParams,
475
+ ...options.extraParams,
429
476
  secUid,
430
477
  cursor,
431
478
  });
432
- return this.#requester.get("/tt/user/liked-posts", params);
479
+ return this.#requester.get("/tt/user/liked-posts", params, {
480
+ timeout: options.timeout,
481
+ });
433
482
  }
434
483
  }
435
484
 
@@ -454,7 +503,7 @@ class YoutubeEndpoints {
454
503
  * sorting?: "relevance" | "time" | "views" | "rating";
455
504
  * getAdditionalInfo?: boolean;
456
505
  * }} params
457
- * @param {Record<string, any>} extraParams
506
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
458
507
  * @returns {Promise<EDResponse>}
459
508
  */
460
509
  keywordSearch(
@@ -466,10 +515,10 @@ class YoutubeEndpoints {
466
515
  sorting = undefined,
467
516
  getAdditionalInfo = undefined,
468
517
  },
469
- extraParams = {},
518
+ options = {},
470
519
  ) {
471
520
  const params = filterUndefinedValues({
472
- ...extraParams,
521
+ ...options.extraParams,
473
522
  keyword,
474
523
  depth,
475
524
  start_cursor: cursor,
@@ -477,83 +526,91 @@ class YoutubeEndpoints {
477
526
  sorting,
478
527
  get_additional_info: getAdditionalInfo,
479
528
  });
480
- return this.#requester.get("/youtube/search", params);
529
+ return this.#requester.get("/youtube/search", params, {
530
+ timeout: options.timeout,
531
+ });
481
532
  }
482
533
 
483
534
  /**
484
535
  * @param {{ keyword: string }} params
485
- * @param {Record<string, any>} extraParams
536
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
486
537
  * @returns {Promise<EDResponse>}
487
538
  */
488
- featuredCategoriesSearch({ keyword }, extraParams = {}) {
539
+ featuredCategoriesSearch({ keyword }, options = {}) {
489
540
  const params = filterUndefinedValues({
490
- ...extraParams,
541
+ ...options.extraParams,
491
542
  name: keyword,
492
543
  });
493
544
  return this.#requester.get(
494
545
  "/youtube/search/featured-categories",
495
546
  params,
547
+ { timeout: options.timeout },
496
548
  );
497
549
  }
498
550
 
499
551
  /**
500
552
  * @param {{ hashtag: string; depth: number; onlyShorts?: boolean }} params
501
- * @param {Record<string, any>} extraParams
553
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
502
554
  * @returns {Promise<EDResponse>}
503
555
  */
504
- hashtagSearch(
505
- { hashtag, depth, onlyShorts = undefined },
506
- extraParams = {},
507
- ) {
556
+ hashtagSearch({ hashtag, depth, onlyShorts = undefined }, options = {}) {
508
557
  const params = filterUndefinedValues({
509
- ...extraParams,
558
+ ...options.extraParams,
510
559
  name: hashtag,
511
560
  depth,
512
561
  only_shorts: onlyShorts,
513
562
  });
514
- return this.#requester.get("/youtube/hashtag/search", params);
563
+ return this.#requester.get("/youtube/hashtag/search", params, {
564
+ timeout: options.timeout,
565
+ });
515
566
  }
516
567
 
517
568
  /**
518
569
  * @param {{ channelId: string; fromUrl?: boolean }} params
519
- * @param {Record<string, any>} extraParams
570
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
520
571
  * @returns {Promise<EDResponse>}
521
572
  */
522
- channelDetailedInfo({ channelId, fromUrl = undefined }, extraParams = {}) {
573
+ channelDetailedInfo({ channelId, fromUrl = undefined }, options = {}) {
523
574
  const params = filterUndefinedValues({
524
- ...extraParams,
575
+ ...options.extraParams,
525
576
  browseId: channelId,
526
577
  from_url: fromUrl,
527
578
  });
528
- return this.#requester.get("/youtube/channel/detailed-info", params);
579
+ return this.#requester.get("/youtube/channel/detailed-info", params, {
580
+ timeout: options.timeout,
581
+ });
529
582
  }
530
583
 
531
584
  /**
532
585
  * @param {{ channelId: string; depth: number }} params
533
- * @param {Record<string, any>} extraParams
586
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
534
587
  * @returns {Promise<EDResponse>}
535
588
  */
536
- channelVideos({ channelId, depth }, extraParams = {}) {
589
+ channelVideos({ channelId, depth }, options = {}) {
537
590
  const params = filterUndefinedValues({
538
- ...extraParams,
591
+ ...options.extraParams,
539
592
  browseId: channelId,
540
593
  depth,
541
594
  });
542
- return this.#requester.get("/youtube/channel/videos", params);
595
+ return this.#requester.get("/youtube/channel/videos", params, {
596
+ timeout: options.timeout,
597
+ });
543
598
  }
544
599
 
545
600
  /**
546
601
  * @param {{ channelId: string; depth: number }} params
547
- * @param {Record<string, any>} extraParams
602
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
548
603
  * @returns {Promise<EDResponse>}
549
604
  */
550
- channelShorts({ channelId, depth }, extraParams = {}) {
605
+ channelShorts({ channelId, depth }, options = {}) {
551
606
  const params = filterUndefinedValues({
552
- ...extraParams,
607
+ ...options.extraParams,
553
608
  browseId: channelId,
554
609
  depth,
555
610
  });
556
- return this.#requester.get("/youtube/channel/shorts", params);
611
+ return this.#requester.get("/youtube/channel/shorts", params, {
612
+ timeout: options.timeout,
613
+ });
557
614
  }
558
615
 
559
616
  /**
@@ -562,87 +619,99 @@ class YoutubeEndpoints {
562
619
  * alternativeMethod?: boolean;
563
620
  * getSubscribersCount?: boolean;
564
621
  * }} params
565
- * @param {Record<string, any>} extraParams
622
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
566
623
  * @returns {Promise<EDResponse>}
567
624
  */
568
625
  videoDetails(
569
626
  { id, alternativeMethod = undefined, getSubscribersCount = undefined },
570
- extraParams = {},
627
+ options = {},
571
628
  ) {
572
629
  const params = filterUndefinedValues({
573
- ...extraParams,
630
+ ...options.extraParams,
574
631
  id,
575
632
  alternative_method: alternativeMethod,
576
633
  get_subscribers_count: getSubscribersCount,
577
634
  });
578
- return this.#requester.get("/youtube/channel/get-short-stats", params);
635
+ return this.#requester.get("/youtube/channel/get-short-stats", params, {
636
+ timeout: options.timeout,
637
+ });
579
638
  }
580
639
 
581
640
  /**
582
641
  * @param {{ channelId: string }} params
583
- * @param {Record<string, any>} extraParams
642
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
584
643
  * @returns {Promise<EDResponse>}
585
644
  */
586
- channelSubscribers({ channelId }, extraParams = {}) {
645
+ channelSubscribers({ channelId }, options = {}) {
587
646
  const params = filterUndefinedValues({
588
- ...extraParams,
647
+ ...options.extraParams,
589
648
  browseId: channelId,
590
649
  });
591
- return this.#requester.get("/youtube/channel/followers", params);
650
+ return this.#requester.get("/youtube/channel/followers", params, {
651
+ timeout: options.timeout,
652
+ });
592
653
  }
593
654
 
594
655
  /**
595
656
  * @param {{ username: string }} params
596
- * @param {Record<string, any>} extraParams
657
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
597
658
  * @returns {Promise<EDResponse>}
598
659
  */
599
- channelUsernameToId({ username }, extraParams = {}) {
660
+ channelUsernameToId({ username }, options = {}) {
600
661
  const params = filterUndefinedValues({
601
- ...extraParams,
662
+ ...options.extraParams,
602
663
  name: username,
603
664
  });
604
- return this.#requester.get("/youtube/channel/name-to-id", params);
665
+ return this.#requester.get("/youtube/channel/name-to-id", params, {
666
+ timeout: options.timeout,
667
+ });
605
668
  }
606
669
 
607
670
  /**
608
671
  * @param {{ channelId: string }} params
609
- * @param {Record<string, any>} extraParams
672
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
610
673
  * @returns {Promise<EDResponse>}
611
674
  */
612
- channelIdToUsername({ channelId }, extraParams = {}) {
675
+ channelIdToUsername({ channelId }, options = {}) {
613
676
  const params = filterUndefinedValues({
614
- ...extraParams,
677
+ ...options.extraParams,
615
678
  browseId: channelId,
616
679
  });
617
- return this.#requester.get("/youtube/channel/id-to-name", params);
680
+ return this.#requester.get("/youtube/channel/id-to-name", params, {
681
+ timeout: options.timeout,
682
+ });
618
683
  }
619
684
 
620
685
  /**
621
686
  * @param {{ musicId: string; depth?: number }} params
622
- * @param {Record<string, any>} extraParams
687
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
623
688
  * @returns {Promise<EDResponse>}
624
689
  */
625
- musicIdToShorts({ musicId, depth = undefined }, extraParams = {}) {
690
+ musicIdToShorts({ musicId, depth = undefined }, options = {}) {
626
691
  const params = filterUndefinedValues({
627
- ...extraParams,
692
+ ...options.extraParams,
628
693
  id: musicId,
629
694
  depth,
630
695
  });
631
- return this.#requester.get("/youtube/music/id-to-shorts", params);
696
+ return this.#requester.get("/youtube/music/id-to-shorts", params, {
697
+ timeout: options.timeout,
698
+ });
632
699
  }
633
700
 
634
701
  /**
635
702
  * @param {{ id: string; cursor?: string }} params
636
- * @param {Record<string, any>} extraParams
703
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
637
704
  * @returns {Promise<EDResponse>}
638
705
  */
639
- videoComments({ id, cursor = undefined }, extraParams = {}) {
706
+ videoComments({ id, cursor = undefined }, options = {}) {
640
707
  const params = filterUndefinedValues({
641
- ...extraParams,
708
+ ...options.extraParams,
642
709
  id,
643
710
  cursor,
644
711
  });
645
- return this.#requester.get("/youtube/video/comments", params);
712
+ return this.#requester.get("/youtube/video/comments", params, {
713
+ timeout: options.timeout,
714
+ });
646
715
  }
647
716
  }
648
717
 
@@ -667,7 +736,7 @@ class InstagramEndpoints {
667
736
  * cursor?: string;
668
737
  * alternativeMethod?: boolean;
669
738
  * }} params
670
- * @param {Record<string, any>} extraParams
739
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
671
740
  * @returns {Promise<EDResponse>}
672
741
  */
673
742
  userPosts(
@@ -679,10 +748,10 @@ class InstagramEndpoints {
679
748
  cursor = undefined,
680
749
  alternativeMethod = undefined,
681
750
  },
682
- extraParams = {},
751
+ options = {},
683
752
  ) {
684
753
  const params = filterUndefinedValues({
685
- ...extraParams,
754
+ ...options.extraParams,
686
755
  user_id: userId,
687
756
  depth,
688
757
  oldest_timestamp: oldestTimestamp,
@@ -690,59 +759,69 @@ class InstagramEndpoints {
690
759
  start_cursor: cursor,
691
760
  alternative_method: alternativeMethod,
692
761
  });
693
- return this.#requester.get("/instagram/user/posts", params);
762
+ return this.#requester.get("/instagram/user/posts", params, {
763
+ timeout: options.timeout,
764
+ });
694
765
  }
695
766
 
696
767
  /**
697
768
  * @param {{ userId: number }} params
698
- * @param {Record<string, any>} extraParams
769
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
699
770
  * @returns {Promise<EDResponse>}
700
771
  */
701
- userBasicStats({ userId }, extraParams = {}) {
772
+ userBasicStats({ userId }, options = {}) {
702
773
  const params = filterUndefinedValues({
703
- ...extraParams,
774
+ ...options.extraParams,
704
775
  user_id: userId,
705
776
  });
706
- return this.#requester.get("/instagram/user/basic-info", params);
777
+ return this.#requester.get("/instagram/user/basic-info", params, {
778
+ timeout: options.timeout,
779
+ });
707
780
  }
708
781
 
709
782
  /**
710
783
  * @param {{ username: string }} params
711
- * @param {Record<string, any>} extraParams
784
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
712
785
  * @returns {Promise<EDResponse>}
713
786
  */
714
- userInfo({ username }, extraParams = {}) {
787
+ userInfo({ username }, options = {}) {
715
788
  const params = filterUndefinedValues({
716
- ...extraParams,
789
+ ...options.extraParams,
717
790
  username,
718
791
  });
719
- return this.#requester.get("/instagram/user/info", params);
792
+ return this.#requester.get("/instagram/user/info", params, {
793
+ timeout: options.timeout,
794
+ });
720
795
  }
721
796
 
722
797
  /**
723
798
  * @param {{ username: string }} params
724
- * @param {Record<string, any>} extraParams
799
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
725
800
  * @returns {Promise<EDResponse>}
726
801
  */
727
- userDetailedInfo({ username }, extraParams = {}) {
802
+ userDetailedInfo({ username }, options = {}) {
728
803
  const params = filterUndefinedValues({
729
- ...extraParams,
804
+ ...options.extraParams,
730
805
  username,
731
806
  });
732
- return this.#requester.get("/instagram/user/detailed-info", params);
807
+ return this.#requester.get("/instagram/user/detailed-info", params, {
808
+ timeout: options.timeout,
809
+ });
733
810
  }
734
811
 
735
812
  /**
736
813
  * @param {{ userId: number }} params
737
- * @param {Record<string, any>} extraParams
814
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
738
815
  * @returns {Promise<EDResponse>}
739
816
  */
740
- userFollowers({ userId }, extraParams = {}) {
817
+ userFollowers({ userId }, options = {}) {
741
818
  const params = filterUndefinedValues({
742
- ...extraParams,
819
+ ...options.extraParams,
743
820
  user_id: userId,
744
821
  });
745
- return this.#requester.get("/instagram/user/followers", params);
822
+ return this.#requester.get("/instagram/user/followers", params, {
823
+ timeout: options.timeout,
824
+ });
746
825
  }
747
826
 
748
827
  /**
@@ -754,7 +833,7 @@ class InstagramEndpoints {
754
833
  * cursor?: string;
755
834
  * chunkSize?: number;
756
835
  * }} params
757
- * @param {Record<string, any>} extraParams
836
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
758
837
  * @returns {Promise<EDResponse>}
759
838
  */
760
839
  userReels(
@@ -766,10 +845,10 @@ class InstagramEndpoints {
766
845
  cursor = undefined,
767
846
  chunkSize = undefined,
768
847
  },
769
- extraParams = {},
848
+ options = {},
770
849
  ) {
771
850
  const params = filterUndefinedValues({
772
- ...extraParams,
851
+ ...options.extraParams,
773
852
  user_id: userId,
774
853
  depth,
775
854
  include_feed_video: includeFeedVideo,
@@ -777,39 +856,45 @@ class InstagramEndpoints {
777
856
  start_cursor: cursor,
778
857
  chunk_size: chunkSize,
779
858
  });
780
- return this.#requester.get("/instagram/user/reels", params);
859
+ return this.#requester.get("/instagram/user/reels", params, {
860
+ timeout: options.timeout,
861
+ });
781
862
  }
782
863
 
783
864
  /**
784
865
  * @param {{ userId: number; cursor?: string; chunkSize?: number }} params
785
- * @param {Record<string, any>} extraParams
866
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
786
867
  * @returns {Promise<EDResponse>}
787
868
  */
788
869
  userTaggedPosts(
789
870
  { userId, cursor = undefined, chunkSize = undefined },
790
- extraParams = {},
871
+ options = {},
791
872
  ) {
792
873
  const params = filterUndefinedValues({
793
- ...extraParams,
874
+ ...options.extraParams,
794
875
  user_id: userId,
795
876
  cursor,
796
877
  chunk_size: chunkSize,
797
878
  });
798
- return this.#requester.get("/instagram/user/tagged-posts", params);
879
+ return this.#requester.get("/instagram/user/tagged-posts", params, {
880
+ timeout: options.timeout,
881
+ });
799
882
  }
800
883
 
801
884
  /**
802
885
  * @param {{ code: string; numComments?: number }} params
803
- * @param {Record<string, any>} extraParams
886
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
804
887
  * @returns {Promise<EDResponse>}
805
888
  */
806
- postInfoAndComments({ code, numComments = undefined }, extraParams = {}) {
889
+ postInfoAndComments({ code, numComments = undefined }, options = {}) {
807
890
  const params = filterUndefinedValues({
808
- ...extraParams,
891
+ ...options.extraParams,
809
892
  code,
810
893
  n_comments_to_fetch: numComments,
811
894
  });
812
- return this.#requester.get("/instagram/post/details", params);
895
+ return this.#requester.get("/instagram/post/details", params, {
896
+ timeout: options.timeout,
897
+ });
813
898
  }
814
899
 
815
900
  /**
@@ -820,7 +905,7 @@ class InstagramEndpoints {
820
905
  * getAuthorInfo?: boolean;
821
906
  * alternativeMethod?: boolean;
822
907
  * }} params
823
- * @param {Record<string, any>} extraParams
908
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
824
909
  * @returns {Promise<EDResponse>}
825
910
  */
826
911
  hashtagPosts(
@@ -831,44 +916,50 @@ class InstagramEndpoints {
831
916
  getAuthorInfo = undefined,
832
917
  alternativeMethod = undefined,
833
918
  },
834
- extraParams = {},
919
+ options = {},
835
920
  ) {
836
921
  const params = filterUndefinedValues({
837
- ...extraParams,
922
+ ...options.extraParams,
838
923
  name: hashtag,
839
924
  cursor,
840
925
  chunk_size: chunkSize,
841
926
  get_author_info: getAuthorInfo,
842
927
  alternative_method: alternativeMethod,
843
928
  });
844
- return this.#requester.get("/instagram/hashtag/posts", params);
929
+ return this.#requester.get("/instagram/hashtag/posts", params, {
930
+ timeout: options.timeout,
931
+ });
845
932
  }
846
933
 
847
934
  /**
848
935
  * @param {{ musicId: string; cursor?: string }} params
849
- * @param {Record<string, any>} extraParams
936
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
850
937
  * @returns {Promise<EDResponse>}
851
938
  */
852
- musicPosts({ musicId, cursor = undefined }, extraParams = {}) {
939
+ musicPosts({ musicId, cursor = undefined }, options = {}) {
853
940
  const params = filterUndefinedValues({
854
- ...extraParams,
941
+ ...options.extraParams,
855
942
  id: musicId,
856
943
  cursor,
857
944
  });
858
- return this.#requester.get("/instagram/music/posts", params);
945
+ return this.#requester.get("/instagram/music/posts", params, {
946
+ timeout: options.timeout,
947
+ });
859
948
  }
860
949
 
861
950
  /**
862
951
  * @param {{ text: string }} params
863
- * @param {Record<string, any>} extraParams
952
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
864
953
  * @returns {Promise<EDResponse>}
865
954
  */
866
- search({ text }, extraParams = {}) {
955
+ search({ text }, options = {}) {
867
956
  const params = filterUndefinedValues({
868
- ...extraParams,
957
+ ...options.extraParams,
869
958
  text,
870
959
  });
871
- return this.#requester.get("/instagram/search", params);
960
+ return this.#requester.get("/instagram/search", params, {
961
+ timeout: options.timeout,
962
+ });
872
963
  }
873
964
  }
874
965
 
@@ -890,30 +981,34 @@ class TwitchEndpoints {
890
981
  * depth: number;
891
982
  * type: "videos" | "channels" | "games";
892
983
  * }} params
893
- * @param {Record<string, any>} extraParams
984
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
894
985
  * @returns {Promise<EDResponse>}
895
986
  */
896
- keywordSearch({ keyword, depth, type }, extraParams = {}) {
987
+ keywordSearch({ keyword, depth, type }, options = {}) {
897
988
  const params = filterUndefinedValues({
898
- ...extraParams,
989
+ ...options.extraParams,
899
990
  keyword,
900
991
  depth,
901
992
  type,
902
993
  });
903
- return this.#requester.get("/twitch/search", params);
994
+ return this.#requester.get("/twitch/search", params, {
995
+ timeout: options.timeout,
996
+ });
904
997
  }
905
998
 
906
999
  /**
907
1000
  * @param {{ username: string }} params
908
- * @param {Record<string, any>} extraParams
1001
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
909
1002
  * @returns {Promise<EDResponse>}
910
1003
  */
911
- userFollowers({ username }, extraParams = {}) {
1004
+ userFollowers({ username }, options = {}) {
912
1005
  const params = filterUndefinedValues({
913
- ...extraParams,
1006
+ ...options.extraParams,
914
1007
  username,
915
1008
  });
916
- return this.#requester.get("/twitch/user/followers", params);
1009
+ return this.#requester.get("/twitch/user/followers", params, {
1010
+ timeout: options.timeout,
1011
+ });
917
1012
  }
918
1013
  }
919
1014
 
@@ -936,35 +1031,36 @@ class RedditEndpoints {
936
1031
  * period: "hour" | "day" | "week" | "month" | "year" | "all";
937
1032
  * cursor?: string;
938
1033
  * }} params
939
- * @param {Record<string, any>} extraParams
1034
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
940
1035
  * @returns {Promise<EDResponse>}
941
1036
  */
942
- subredditPosts(
943
- { name, sort, period, cursor = undefined },
944
- extraParams = {},
945
- ) {
1037
+ subredditPosts({ name, sort, period, cursor = undefined }, options = {}) {
946
1038
  const params = filterUndefinedValues({
947
- ...extraParams,
1039
+ ...options.extraParams,
948
1040
  name,
949
1041
  sort,
950
1042
  period,
951
1043
  cursor,
952
1044
  });
953
- return this.#requester.get("/reddit/subreddit/posts", params);
1045
+ return this.#requester.get("/reddit/subreddit/posts", params, {
1046
+ timeout: options.timeout,
1047
+ });
954
1048
  }
955
1049
 
956
1050
  /**
957
1051
  * @param {{ id: string; cursor?: string }} params
958
- * @param {Record<string, any>} extraParams
1052
+ * @param {{ extraParams?: Record<string, any>; timeout?: number }} options
959
1053
  * @returns {Promise<EDResponse>}
960
1054
  */
961
- postComments({ id, cursor = undefined }, extraParams = {}) {
1055
+ postComments({ id, cursor = undefined }, options = {}) {
962
1056
  const params = filterUndefinedValues({
963
- ...extraParams,
1057
+ ...options.extraParams,
964
1058
  id,
965
1059
  cursor,
966
1060
  });
967
- return this.#requester.get("/reddit/post/comments", params);
1061
+ return this.#requester.get("/reddit/post/comments", params, {
1062
+ timeout: options.timeout,
1063
+ });
968
1064
  }
969
1065
  }
970
1066
 
@@ -975,9 +1071,15 @@ export class EDClient {
975
1071
  */
976
1072
  #requester;
977
1073
 
978
- /** @param {{ token: string }} options */
979
- constructor({ token }) {
980
- const requester = new Requester({ token });
1074
+ /**
1075
+ * @param {{
1076
+ * token: string;
1077
+ * timeout?: number;
1078
+ * maxNetworkRetries?: number;
1079
+ * }} options
1080
+ */
1081
+ constructor({ token, timeout = 600, maxNetworkRetries = 3 }) {
1082
+ const requester = new Requester({ token, timeout, maxNetworkRetries });
981
1083
  this.#requester = requester;
982
1084
 
983
1085
  /** @readonly */
@@ -1002,9 +1104,10 @@ export class EDClient {
1002
1104
  /**
1003
1105
  * @param {string} path
1004
1106
  * @param {Record<string, string>} params
1107
+ * @param {{ timeout?: number }} options
1005
1108
  * @returns {Promise<EDResponse>}
1006
1109
  */
1007
- async request(path, params) {
1008
- return this.#requester.get(path, params);
1110
+ async request(path, params, options = {}) {
1111
+ return this.#requester.get(path, params, { timeout: options.timeout });
1009
1112
  }
1010
1113
  }