ensembledata 0.0.3

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