scrapebadger 0.7.0 → 0.8.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/README.md +1 -0
- package/dist/index.d.cts +1347 -9
- package/dist/index.d.ts +1347 -9
- package/dist/index.js +641 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +637 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -3269,6 +3269,639 @@ var GoogleClient = class {
|
|
|
3269
3269
|
}
|
|
3270
3270
|
};
|
|
3271
3271
|
|
|
3272
|
+
// src/reddit/search.ts
|
|
3273
|
+
var SearchClient3 = class {
|
|
3274
|
+
client;
|
|
3275
|
+
constructor(client) {
|
|
3276
|
+
this.client = client;
|
|
3277
|
+
}
|
|
3278
|
+
/**
|
|
3279
|
+
* Search Reddit posts.
|
|
3280
|
+
*
|
|
3281
|
+
* @param options - Search parameters.
|
|
3282
|
+
* @param options.query - Search query string.
|
|
3283
|
+
* @param options.subreddit - Restrict search to a specific subreddit.
|
|
3284
|
+
* @param options.sort - Sort order (relevance, hot, top, new, comments).
|
|
3285
|
+
* @param options.time - Time filter (hour, day, week, month, year, all).
|
|
3286
|
+
* @param options.after - Pagination cursor for the next page.
|
|
3287
|
+
* @param options.limit - Number of results to return (max 100).
|
|
3288
|
+
* @returns Search results with posts and pagination metadata.
|
|
3289
|
+
* @throws AuthenticationError - If the API key is invalid.
|
|
3290
|
+
* @throws ValidationError - If the search parameters are invalid.
|
|
3291
|
+
*
|
|
3292
|
+
* @example
|
|
3293
|
+
* ```typescript
|
|
3294
|
+
* const results = await client.reddit.search.posts({
|
|
3295
|
+
* query: "best practices",
|
|
3296
|
+
* subreddit: "programming",
|
|
3297
|
+
* sort: "top",
|
|
3298
|
+
* time: "month",
|
|
3299
|
+
* limit: 25,
|
|
3300
|
+
* });
|
|
3301
|
+
* console.log(`Found ${results.posts.length} posts`);
|
|
3302
|
+
* ```
|
|
3303
|
+
*/
|
|
3304
|
+
async posts(options) {
|
|
3305
|
+
return this.client.request("/v1/reddit/search/posts", {
|
|
3306
|
+
params: {
|
|
3307
|
+
query: options.query,
|
|
3308
|
+
subreddit: options.subreddit,
|
|
3309
|
+
sort: options.sort,
|
|
3310
|
+
time: options.time,
|
|
3311
|
+
after: options.after,
|
|
3312
|
+
limit: options.limit
|
|
3313
|
+
}
|
|
3314
|
+
});
|
|
3315
|
+
}
|
|
3316
|
+
/**
|
|
3317
|
+
* Search Reddit subreddits.
|
|
3318
|
+
*
|
|
3319
|
+
* @param options - Search parameters.
|
|
3320
|
+
* @param options.query - Search query string.
|
|
3321
|
+
* @param options.after - Pagination cursor for the next page.
|
|
3322
|
+
* @param options.limit - Number of results to return (max 100).
|
|
3323
|
+
* @returns Matching subreddits with pagination metadata.
|
|
3324
|
+
* @throws AuthenticationError - If the API key is invalid.
|
|
3325
|
+
* @throws ValidationError - If the search parameters are invalid.
|
|
3326
|
+
*
|
|
3327
|
+
* @example
|
|
3328
|
+
* ```typescript
|
|
3329
|
+
* const results = await client.reddit.search.subreddits({
|
|
3330
|
+
* query: "javascript",
|
|
3331
|
+
* limit: 10,
|
|
3332
|
+
* });
|
|
3333
|
+
* for (const sub of results.subreddits) {
|
|
3334
|
+
* console.log(`r/${sub.display_name}: ${sub.subscribers.toLocaleString()} subscribers`);
|
|
3335
|
+
* }
|
|
3336
|
+
* ```
|
|
3337
|
+
*/
|
|
3338
|
+
async subreddits(options) {
|
|
3339
|
+
return this.client.request(
|
|
3340
|
+
"/v1/reddit/search/subreddits",
|
|
3341
|
+
{
|
|
3342
|
+
params: {
|
|
3343
|
+
query: options.query,
|
|
3344
|
+
after: options.after,
|
|
3345
|
+
limit: options.limit
|
|
3346
|
+
}
|
|
3347
|
+
}
|
|
3348
|
+
);
|
|
3349
|
+
}
|
|
3350
|
+
/**
|
|
3351
|
+
* Search Reddit users.
|
|
3352
|
+
*
|
|
3353
|
+
* @param options - Search parameters.
|
|
3354
|
+
* @param options.query - Search query string.
|
|
3355
|
+
* @param options.after - Pagination cursor for the next page.
|
|
3356
|
+
* @param options.limit - Number of results to return (max 100).
|
|
3357
|
+
* @returns Matching users with pagination metadata.
|
|
3358
|
+
* @throws AuthenticationError - If the API key is invalid.
|
|
3359
|
+
* @throws ValidationError - If the search parameters are invalid.
|
|
3360
|
+
*
|
|
3361
|
+
* @example
|
|
3362
|
+
* ```typescript
|
|
3363
|
+
* const results = await client.reddit.search.users({
|
|
3364
|
+
* query: "john",
|
|
3365
|
+
* limit: 20,
|
|
3366
|
+
* });
|
|
3367
|
+
* for (const user of results.users) {
|
|
3368
|
+
* console.log(`u/${user.name}: ${user.total_karma.toLocaleString()} karma`);
|
|
3369
|
+
* }
|
|
3370
|
+
* ```
|
|
3371
|
+
*/
|
|
3372
|
+
async users(options) {
|
|
3373
|
+
return this.client.request(
|
|
3374
|
+
"/v1/reddit/search/users",
|
|
3375
|
+
{
|
|
3376
|
+
params: {
|
|
3377
|
+
query: options.query,
|
|
3378
|
+
after: options.after,
|
|
3379
|
+
limit: options.limit
|
|
3380
|
+
}
|
|
3381
|
+
}
|
|
3382
|
+
);
|
|
3383
|
+
}
|
|
3384
|
+
/**
|
|
3385
|
+
* Get Reddit posts linking to a specific domain.
|
|
3386
|
+
*
|
|
3387
|
+
* @param options - Request parameters.
|
|
3388
|
+
* @param options.domain - Domain name to search for (e.g. "github.com").
|
|
3389
|
+
* @param options.sort - Sort order (hot, new, top, rising).
|
|
3390
|
+
* @param options.time - Time filter for top sort (hour, day, week, month, year, all).
|
|
3391
|
+
* @param options.after - Pagination cursor for the next page.
|
|
3392
|
+
* @param options.limit - Number of results to return (max 100).
|
|
3393
|
+
* @returns Posts linking to the domain with pagination metadata.
|
|
3394
|
+
* @throws AuthenticationError - If the API key is invalid.
|
|
3395
|
+
* @throws ValidationError - If the parameters are invalid.
|
|
3396
|
+
*
|
|
3397
|
+
* @example
|
|
3398
|
+
* ```typescript
|
|
3399
|
+
* const results = await client.reddit.search.domainPosts({
|
|
3400
|
+
* domain: "github.com",
|
|
3401
|
+
* sort: "top",
|
|
3402
|
+
* time: "week",
|
|
3403
|
+
* limit: 25,
|
|
3404
|
+
* });
|
|
3405
|
+
* for (const post of results.posts) {
|
|
3406
|
+
* console.log(`r/${post.subreddit}: ${post.title}`);
|
|
3407
|
+
* }
|
|
3408
|
+
* ```
|
|
3409
|
+
*/
|
|
3410
|
+
async domainPosts(options) {
|
|
3411
|
+
return this.client.request(
|
|
3412
|
+
"/v1/reddit/search/domain",
|
|
3413
|
+
{
|
|
3414
|
+
params: {
|
|
3415
|
+
domain: options.domain,
|
|
3416
|
+
sort: options.sort,
|
|
3417
|
+
time: options.time,
|
|
3418
|
+
after: options.after,
|
|
3419
|
+
limit: options.limit
|
|
3420
|
+
}
|
|
3421
|
+
}
|
|
3422
|
+
);
|
|
3423
|
+
}
|
|
3424
|
+
};
|
|
3425
|
+
|
|
3426
|
+
// src/reddit/posts.ts
|
|
3427
|
+
var PostsClient = class {
|
|
3428
|
+
client;
|
|
3429
|
+
constructor(client) {
|
|
3430
|
+
this.client = client;
|
|
3431
|
+
}
|
|
3432
|
+
/**
|
|
3433
|
+
* Get trending/hot posts from Reddit or a specific subreddit.
|
|
3434
|
+
*
|
|
3435
|
+
* @param options - Request parameters.
|
|
3436
|
+
* @param options.subreddit - Subreddit name (without r/). If omitted, returns site-wide posts.
|
|
3437
|
+
* @param options.sort - Sort order (hot, new, top, rising, controversial).
|
|
3438
|
+
* @param options.time - Time filter for top/controversial (hour, day, week, month, year, all).
|
|
3439
|
+
* @param options.after - Pagination cursor for the next page.
|
|
3440
|
+
* @param options.limit - Number of results to return (max 100).
|
|
3441
|
+
* @returns Trending posts with pagination metadata.
|
|
3442
|
+
* @throws AuthenticationError - If the API key is invalid.
|
|
3443
|
+
*
|
|
3444
|
+
* @example
|
|
3445
|
+
* ```typescript
|
|
3446
|
+
* const results = await client.reddit.posts.trending({
|
|
3447
|
+
* subreddit: "worldnews",
|
|
3448
|
+
* sort: "hot",
|
|
3449
|
+
* limit: 25,
|
|
3450
|
+
* });
|
|
3451
|
+
* for (const post of results.posts) {
|
|
3452
|
+
* console.log(`${post.title} (${post.num_comments} comments)`);
|
|
3453
|
+
* }
|
|
3454
|
+
* ```
|
|
3455
|
+
*/
|
|
3456
|
+
async trending(options = {}) {
|
|
3457
|
+
return this.client.request("/v1/reddit/posts", {
|
|
3458
|
+
params: {
|
|
3459
|
+
subreddit: options.subreddit,
|
|
3460
|
+
sort: options.sort,
|
|
3461
|
+
time: options.time,
|
|
3462
|
+
after: options.after,
|
|
3463
|
+
limit: options.limit
|
|
3464
|
+
}
|
|
3465
|
+
});
|
|
3466
|
+
}
|
|
3467
|
+
/**
|
|
3468
|
+
* Get full details of a single Reddit post.
|
|
3469
|
+
*
|
|
3470
|
+
* @param postId - The Reddit post ID (e.g. "abc123" or "t3_abc123").
|
|
3471
|
+
* @param options - Optional parameters.
|
|
3472
|
+
* @param options.subreddit - Subreddit name (helps resolve the post URL).
|
|
3473
|
+
* @returns Full post details.
|
|
3474
|
+
* @throws NotFoundError - If the post doesn't exist.
|
|
3475
|
+
* @throws AuthenticationError - If the API key is invalid.
|
|
3476
|
+
*
|
|
3477
|
+
* @example
|
|
3478
|
+
* ```typescript
|
|
3479
|
+
* const response = await client.reddit.posts.get("abc123", { subreddit: "programming" });
|
|
3480
|
+
* const { post } = response;
|
|
3481
|
+
* console.log(`${post.title} by u/${post.author}`);
|
|
3482
|
+
* console.log(`Score: ${post.score}, Comments: ${post.num_comments}`);
|
|
3483
|
+
* ```
|
|
3484
|
+
*/
|
|
3485
|
+
async get(postId, options = {}) {
|
|
3486
|
+
return this.client.request(
|
|
3487
|
+
`/v1/reddit/posts/${postId}`,
|
|
3488
|
+
{ params: { subreddit: options.subreddit } }
|
|
3489
|
+
);
|
|
3490
|
+
}
|
|
3491
|
+
/**
|
|
3492
|
+
* Get comments for a Reddit post.
|
|
3493
|
+
*
|
|
3494
|
+
* @param postId - The Reddit post ID (e.g. "abc123" or "t3_abc123").
|
|
3495
|
+
* @param options - Optional parameters.
|
|
3496
|
+
* @param options.subreddit - Subreddit name (helps resolve the post URL).
|
|
3497
|
+
* @param options.sort - Comment sort order (confidence, top, new, controversial, old, qa).
|
|
3498
|
+
* @param options.depth - Maximum comment tree depth.
|
|
3499
|
+
* @param options.limit - Number of top-level comments to return.
|
|
3500
|
+
* @returns Post details and nested comment tree.
|
|
3501
|
+
* @throws NotFoundError - If the post doesn't exist.
|
|
3502
|
+
* @throws AuthenticationError - If the API key is invalid.
|
|
3503
|
+
*
|
|
3504
|
+
* @example
|
|
3505
|
+
* ```typescript
|
|
3506
|
+
* const response = await client.reddit.posts.comments("abc123", {
|
|
3507
|
+
* subreddit: "programming",
|
|
3508
|
+
* sort: "top",
|
|
3509
|
+
* limit: 50,
|
|
3510
|
+
* });
|
|
3511
|
+
* for (const comment of response.comments) {
|
|
3512
|
+
* console.log(`u/${comment.author}: ${comment.body.slice(0, 100)}`);
|
|
3513
|
+
* }
|
|
3514
|
+
* ```
|
|
3515
|
+
*/
|
|
3516
|
+
async comments(postId, options = {}) {
|
|
3517
|
+
return this.client.request(
|
|
3518
|
+
`/v1/reddit/posts/${postId}/comments`,
|
|
3519
|
+
{
|
|
3520
|
+
params: {
|
|
3521
|
+
subreddit: options.subreddit,
|
|
3522
|
+
sort: options.sort,
|
|
3523
|
+
depth: options.depth,
|
|
3524
|
+
limit: options.limit
|
|
3525
|
+
}
|
|
3526
|
+
}
|
|
3527
|
+
);
|
|
3528
|
+
}
|
|
3529
|
+
/**
|
|
3530
|
+
* Get cross-posts and duplicate submissions of a Reddit post.
|
|
3531
|
+
*
|
|
3532
|
+
* @param postId - The Reddit post ID (e.g. "abc123" or "t3_abc123").
|
|
3533
|
+
* @param options - Optional parameters.
|
|
3534
|
+
* @param options.after - Pagination cursor for the next page.
|
|
3535
|
+
* @param options.limit - Number of results to return (max 100).
|
|
3536
|
+
* @returns The original post and its duplicate submissions.
|
|
3537
|
+
* @throws NotFoundError - If the post doesn't exist.
|
|
3538
|
+
* @throws AuthenticationError - If the API key is invalid.
|
|
3539
|
+
*
|
|
3540
|
+
* @example
|
|
3541
|
+
* ```typescript
|
|
3542
|
+
* const response = await client.reddit.posts.duplicates("abc123");
|
|
3543
|
+
* console.log(`Original: ${response.post.title}`);
|
|
3544
|
+
* console.log(`Cross-posted ${response.duplicates.length} times`);
|
|
3545
|
+
* for (const dupe of response.duplicates) {
|
|
3546
|
+
* console.log(` r/${dupe.subreddit}: ${dupe.score} points`);
|
|
3547
|
+
* }
|
|
3548
|
+
* ```
|
|
3549
|
+
*/
|
|
3550
|
+
async duplicates(postId, options = {}) {
|
|
3551
|
+
return this.client.request(
|
|
3552
|
+
`/v1/reddit/posts/${postId}/duplicates`,
|
|
3553
|
+
{
|
|
3554
|
+
params: {
|
|
3555
|
+
after: options.after,
|
|
3556
|
+
limit: options.limit
|
|
3557
|
+
}
|
|
3558
|
+
}
|
|
3559
|
+
);
|
|
3560
|
+
}
|
|
3561
|
+
};
|
|
3562
|
+
|
|
3563
|
+
// src/reddit/subreddits.ts
|
|
3564
|
+
var SubredditsClient = class {
|
|
3565
|
+
client;
|
|
3566
|
+
constructor(client) {
|
|
3567
|
+
this.client = client;
|
|
3568
|
+
}
|
|
3569
|
+
/**
|
|
3570
|
+
* Get a subreddit's full details and metadata.
|
|
3571
|
+
*
|
|
3572
|
+
* @param subreddit - Subreddit name (without r/ prefix).
|
|
3573
|
+
* @returns Full subreddit details.
|
|
3574
|
+
* @throws NotFoundError - If the subreddit doesn't exist.
|
|
3575
|
+
* @throws AuthenticationError - If the API key is invalid.
|
|
3576
|
+
*
|
|
3577
|
+
* @example
|
|
3578
|
+
* ```typescript
|
|
3579
|
+
* const response = await client.reddit.subreddits.get("javascript");
|
|
3580
|
+
* const { subreddit } = response;
|
|
3581
|
+
* console.log(`${subreddit.title}: ${subreddit.subscribers.toLocaleString()} members`);
|
|
3582
|
+
* console.log(`Description: ${subreddit.public_description}`);
|
|
3583
|
+
* ```
|
|
3584
|
+
*/
|
|
3585
|
+
async get(subreddit) {
|
|
3586
|
+
return this.client.request(`/v1/reddit/subreddits/${subreddit}`);
|
|
3587
|
+
}
|
|
3588
|
+
/**
|
|
3589
|
+
* Get posts from a subreddit.
|
|
3590
|
+
*
|
|
3591
|
+
* @param subreddit - Subreddit name (without r/ prefix).
|
|
3592
|
+
* @param options - Optional parameters.
|
|
3593
|
+
* @param options.sort - Sort order (hot, new, top, rising, controversial).
|
|
3594
|
+
* @param options.time - Time filter for top/controversial (hour, day, week, month, year, all).
|
|
3595
|
+
* @param options.after - Pagination cursor for the next page.
|
|
3596
|
+
* @param options.limit - Number of results to return (max 100).
|
|
3597
|
+
* @returns Subreddit posts with pagination metadata.
|
|
3598
|
+
* @throws NotFoundError - If the subreddit doesn't exist.
|
|
3599
|
+
* @throws AuthenticationError - If the API key is invalid.
|
|
3600
|
+
*
|
|
3601
|
+
* @example
|
|
3602
|
+
* ```typescript
|
|
3603
|
+
* const response = await client.reddit.subreddits.posts("typescript", {
|
|
3604
|
+
* sort: "top",
|
|
3605
|
+
* time: "week",
|
|
3606
|
+
* limit: 25,
|
|
3607
|
+
* });
|
|
3608
|
+
* for (const post of response.posts) {
|
|
3609
|
+
* console.log(`${post.title} — ${post.score} pts`);
|
|
3610
|
+
* }
|
|
3611
|
+
* ```
|
|
3612
|
+
*/
|
|
3613
|
+
async posts(subreddit, options = {}) {
|
|
3614
|
+
return this.client.request(`/v1/reddit/subreddits/${subreddit}/posts`, {
|
|
3615
|
+
params: {
|
|
3616
|
+
sort: options.sort,
|
|
3617
|
+
time: options.time,
|
|
3618
|
+
after: options.after,
|
|
3619
|
+
limit: options.limit
|
|
3620
|
+
}
|
|
3621
|
+
});
|
|
3622
|
+
}
|
|
3623
|
+
/**
|
|
3624
|
+
* Get the rules for a subreddit.
|
|
3625
|
+
*
|
|
3626
|
+
* @param subreddit - Subreddit name (without r/ prefix).
|
|
3627
|
+
* @returns List of subreddit rules.
|
|
3628
|
+
* @throws NotFoundError - If the subreddit doesn't exist.
|
|
3629
|
+
* @throws AuthenticationError - If the API key is invalid.
|
|
3630
|
+
*
|
|
3631
|
+
* @example
|
|
3632
|
+
* ```typescript
|
|
3633
|
+
* const response = await client.reddit.subreddits.rules("AskReddit");
|
|
3634
|
+
* for (const rule of response.rules) {
|
|
3635
|
+
* console.log(`${rule.priority}. ${rule.short_name}`);
|
|
3636
|
+
* console.log(` ${rule.description}`);
|
|
3637
|
+
* }
|
|
3638
|
+
* ```
|
|
3639
|
+
*/
|
|
3640
|
+
async rules(subreddit) {
|
|
3641
|
+
return this.client.request(`/v1/reddit/subreddits/${subreddit}/rules`);
|
|
3642
|
+
}
|
|
3643
|
+
/**
|
|
3644
|
+
* List all wiki pages in a subreddit.
|
|
3645
|
+
*
|
|
3646
|
+
* @param subreddit - Subreddit name (without r/ prefix).
|
|
3647
|
+
* @returns List of wiki page slugs.
|
|
3648
|
+
* @throws NotFoundError - If the subreddit doesn't exist.
|
|
3649
|
+
* @throws AuthenticationError - If the API key is invalid.
|
|
3650
|
+
*
|
|
3651
|
+
* @example
|
|
3652
|
+
* ```typescript
|
|
3653
|
+
* const response = await client.reddit.subreddits.wikiPages("rust");
|
|
3654
|
+
* for (const page of response.pages) {
|
|
3655
|
+
* console.log(`/r/rust/wiki/${page}`);
|
|
3656
|
+
* }
|
|
3657
|
+
* ```
|
|
3658
|
+
*/
|
|
3659
|
+
async wikiPages(subreddit) {
|
|
3660
|
+
return this.client.request(
|
|
3661
|
+
`/v1/reddit/subreddits/${subreddit}/wiki`
|
|
3662
|
+
);
|
|
3663
|
+
}
|
|
3664
|
+
/**
|
|
3665
|
+
* Get the content of a specific wiki page in a subreddit.
|
|
3666
|
+
*
|
|
3667
|
+
* @param subreddit - Subreddit name (without r/ prefix).
|
|
3668
|
+
* @param page - Wiki page slug (e.g. "index", "faq").
|
|
3669
|
+
* @returns Wiki page content and metadata.
|
|
3670
|
+
* @throws NotFoundError - If the subreddit or wiki page doesn't exist.
|
|
3671
|
+
* @throws AuthenticationError - If the API key is invalid.
|
|
3672
|
+
*
|
|
3673
|
+
* @example
|
|
3674
|
+
* ```typescript
|
|
3675
|
+
* const response = await client.reddit.subreddits.wikiPage("learnprogramming", "faq");
|
|
3676
|
+
* console.log(`Last edited by: u/${response.page.revision_by}`);
|
|
3677
|
+
* console.log(response.page.content_md);
|
|
3678
|
+
* ```
|
|
3679
|
+
*/
|
|
3680
|
+
async wikiPage(subreddit, page) {
|
|
3681
|
+
return this.client.request(`/v1/reddit/subreddits/${subreddit}/wiki/${page}`);
|
|
3682
|
+
}
|
|
3683
|
+
/**
|
|
3684
|
+
* Get the most popular subreddits on Reddit.
|
|
3685
|
+
*
|
|
3686
|
+
* @param options - Optional parameters.
|
|
3687
|
+
* @param options.after - Pagination cursor for the next page.
|
|
3688
|
+
* @param options.limit - Number of results to return (max 100).
|
|
3689
|
+
* @returns Popular subreddits with pagination metadata.
|
|
3690
|
+
* @throws AuthenticationError - If the API key is invalid.
|
|
3691
|
+
*
|
|
3692
|
+
* @example
|
|
3693
|
+
* ```typescript
|
|
3694
|
+
* const response = await client.reddit.subreddits.popular({ limit: 20 });
|
|
3695
|
+
* for (const sub of response.subreddits) {
|
|
3696
|
+
* console.log(`r/${sub.display_name}: ${sub.subscribers.toLocaleString()} subscribers`);
|
|
3697
|
+
* }
|
|
3698
|
+
* ```
|
|
3699
|
+
*/
|
|
3700
|
+
async popular(options = {}) {
|
|
3701
|
+
return this.client.request("/v1/reddit/subreddits/popular", {
|
|
3702
|
+
params: {
|
|
3703
|
+
after: options.after,
|
|
3704
|
+
limit: options.limit
|
|
3705
|
+
}
|
|
3706
|
+
});
|
|
3707
|
+
}
|
|
3708
|
+
/**
|
|
3709
|
+
* Get newly created subreddits on Reddit.
|
|
3710
|
+
*
|
|
3711
|
+
* @param options - Optional parameters.
|
|
3712
|
+
* @param options.after - Pagination cursor for the next page.
|
|
3713
|
+
* @param options.limit - Number of results to return (max 100).
|
|
3714
|
+
* @returns New subreddits with pagination metadata.
|
|
3715
|
+
* @throws AuthenticationError - If the API key is invalid.
|
|
3716
|
+
*
|
|
3717
|
+
* @example
|
|
3718
|
+
* ```typescript
|
|
3719
|
+
* const response = await client.reddit.subreddits.newSubreddits({ limit: 20 });
|
|
3720
|
+
* for (const sub of response.subreddits) {
|
|
3721
|
+
* console.log(`r/${sub.display_name} (created: ${new Date(sub.created_utc * 1000).toLocaleDateString()})`);
|
|
3722
|
+
* }
|
|
3723
|
+
* ```
|
|
3724
|
+
*/
|
|
3725
|
+
async newSubreddits(options = {}) {
|
|
3726
|
+
return this.client.request("/v1/reddit/subreddits/new", {
|
|
3727
|
+
params: {
|
|
3728
|
+
after: options.after,
|
|
3729
|
+
limit: options.limit
|
|
3730
|
+
}
|
|
3731
|
+
});
|
|
3732
|
+
}
|
|
3733
|
+
};
|
|
3734
|
+
|
|
3735
|
+
// src/reddit/users.ts
|
|
3736
|
+
var UsersClient3 = class {
|
|
3737
|
+
client;
|
|
3738
|
+
constructor(client) {
|
|
3739
|
+
this.client = client;
|
|
3740
|
+
}
|
|
3741
|
+
/**
|
|
3742
|
+
* Get a Reddit user's profile.
|
|
3743
|
+
*
|
|
3744
|
+
* @param username - The Reddit username (without u/ prefix).
|
|
3745
|
+
* @returns The user profile response.
|
|
3746
|
+
* @throws NotFoundError - If the user doesn't exist or is suspended.
|
|
3747
|
+
* @throws AuthenticationError - If the API key is invalid.
|
|
3748
|
+
*
|
|
3749
|
+
* @example
|
|
3750
|
+
* ```typescript
|
|
3751
|
+
* const response = await client.reddit.users.get("spez");
|
|
3752
|
+
* const { user } = response;
|
|
3753
|
+
* console.log(`u/${user.name}`);
|
|
3754
|
+
* console.log(`Karma: ${user.total_karma.toLocaleString()} (${user.link_karma} post, ${user.comment_karma} comment)`);
|
|
3755
|
+
* console.log(`Account age: ${new Date(user.created_utc * 1000).toLocaleDateString()}`);
|
|
3756
|
+
* ```
|
|
3757
|
+
*/
|
|
3758
|
+
async get(username) {
|
|
3759
|
+
return this.client.request(
|
|
3760
|
+
`/v1/reddit/users/${username}`
|
|
3761
|
+
);
|
|
3762
|
+
}
|
|
3763
|
+
/**
|
|
3764
|
+
* Get posts submitted by a Reddit user.
|
|
3765
|
+
*
|
|
3766
|
+
* @param username - The Reddit username (without u/ prefix).
|
|
3767
|
+
* @param options - Optional parameters.
|
|
3768
|
+
* @param options.sort - Sort order (hot, new, top, controversial).
|
|
3769
|
+
* @param options.time - Time filter for top/controversial (hour, day, week, month, year, all).
|
|
3770
|
+
* @param options.after - Pagination cursor for the next page.
|
|
3771
|
+
* @param options.limit - Number of results to return (max 100).
|
|
3772
|
+
* @returns The user's posts with pagination metadata.
|
|
3773
|
+
* @throws NotFoundError - If the user doesn't exist.
|
|
3774
|
+
* @throws AuthenticationError - If the API key is invalid.
|
|
3775
|
+
*
|
|
3776
|
+
* @example
|
|
3777
|
+
* ```typescript
|
|
3778
|
+
* const response = await client.reddit.users.posts("spez", {
|
|
3779
|
+
* sort: "top",
|
|
3780
|
+
* time: "all",
|
|
3781
|
+
* limit: 25,
|
|
3782
|
+
* });
|
|
3783
|
+
* for (const post of response.posts) {
|
|
3784
|
+
* console.log(`r/${post.subreddit}: ${post.title} (${post.score} pts)`);
|
|
3785
|
+
* }
|
|
3786
|
+
* ```
|
|
3787
|
+
*/
|
|
3788
|
+
async posts(username, options = {}) {
|
|
3789
|
+
return this.client.request(
|
|
3790
|
+
`/v1/reddit/users/${username}/posts`,
|
|
3791
|
+
{
|
|
3792
|
+
params: {
|
|
3793
|
+
sort: options.sort,
|
|
3794
|
+
time: options.time,
|
|
3795
|
+
after: options.after,
|
|
3796
|
+
limit: options.limit
|
|
3797
|
+
}
|
|
3798
|
+
}
|
|
3799
|
+
);
|
|
3800
|
+
}
|
|
3801
|
+
/**
|
|
3802
|
+
* Get comments made by a Reddit user.
|
|
3803
|
+
*
|
|
3804
|
+
* @param username - The Reddit username (without u/ prefix).
|
|
3805
|
+
* @param options - Optional parameters.
|
|
3806
|
+
* @param options.sort - Sort order (hot, new, top, controversial).
|
|
3807
|
+
* @param options.time - Time filter for top/controversial (hour, day, week, month, year, all).
|
|
3808
|
+
* @param options.after - Pagination cursor for the next page.
|
|
3809
|
+
* @param options.limit - Number of results to return (max 100).
|
|
3810
|
+
* @returns The user's comments with pagination metadata.
|
|
3811
|
+
* @throws NotFoundError - If the user doesn't exist.
|
|
3812
|
+
* @throws AuthenticationError - If the API key is invalid.
|
|
3813
|
+
*
|
|
3814
|
+
* @example
|
|
3815
|
+
* ```typescript
|
|
3816
|
+
* const response = await client.reddit.users.comments("spez", {
|
|
3817
|
+
* sort: "new",
|
|
3818
|
+
* limit: 50,
|
|
3819
|
+
* });
|
|
3820
|
+
* for (const comment of response.comments) {
|
|
3821
|
+
* console.log(`r/${comment.subreddit}: ${comment.body.slice(0, 80)}`);
|
|
3822
|
+
* }
|
|
3823
|
+
* ```
|
|
3824
|
+
*/
|
|
3825
|
+
async comments(username, options = {}) {
|
|
3826
|
+
return this.client.request(
|
|
3827
|
+
`/v1/reddit/users/${username}/comments`,
|
|
3828
|
+
{
|
|
3829
|
+
params: {
|
|
3830
|
+
sort: options.sort,
|
|
3831
|
+
time: options.time,
|
|
3832
|
+
after: options.after,
|
|
3833
|
+
limit: options.limit
|
|
3834
|
+
}
|
|
3835
|
+
}
|
|
3836
|
+
);
|
|
3837
|
+
}
|
|
3838
|
+
/**
|
|
3839
|
+
* Get subreddits moderated by a Reddit user.
|
|
3840
|
+
*
|
|
3841
|
+
* @param username - The Reddit username (without u/ prefix).
|
|
3842
|
+
* @returns Subreddits moderated by the user.
|
|
3843
|
+
* @throws NotFoundError - If the user doesn't exist.
|
|
3844
|
+
* @throws AuthenticationError - If the API key is invalid.
|
|
3845
|
+
*
|
|
3846
|
+
* @example
|
|
3847
|
+
* ```typescript
|
|
3848
|
+
* const response = await client.reddit.users.moderated("spez");
|
|
3849
|
+
* for (const sub of response.subreddits) {
|
|
3850
|
+
* console.log(`r/${sub.display_name}: ${sub.subscribers.toLocaleString()} subscribers`);
|
|
3851
|
+
* }
|
|
3852
|
+
* ```
|
|
3853
|
+
*/
|
|
3854
|
+
async moderated(username) {
|
|
3855
|
+
return this.client.request(
|
|
3856
|
+
`/v1/reddit/users/${username}/moderated`
|
|
3857
|
+
);
|
|
3858
|
+
}
|
|
3859
|
+
/**
|
|
3860
|
+
* Get trophies awarded to a Reddit user.
|
|
3861
|
+
*
|
|
3862
|
+
* @param username - The Reddit username (without u/ prefix).
|
|
3863
|
+
* @returns List of trophies awarded to the user.
|
|
3864
|
+
* @throws NotFoundError - If the user doesn't exist.
|
|
3865
|
+
* @throws AuthenticationError - If the API key is invalid.
|
|
3866
|
+
*
|
|
3867
|
+
* @example
|
|
3868
|
+
* ```typescript
|
|
3869
|
+
* const response = await client.reddit.users.trophies("spez");
|
|
3870
|
+
* for (const trophy of response.trophies) {
|
|
3871
|
+
* console.log(`${trophy.name}${trophy.description ? `: ${trophy.description}` : ""}`);
|
|
3872
|
+
* }
|
|
3873
|
+
* ```
|
|
3874
|
+
*/
|
|
3875
|
+
async trophies(username) {
|
|
3876
|
+
return this.client.request(
|
|
3877
|
+
`/v1/reddit/users/${username}/trophies`
|
|
3878
|
+
);
|
|
3879
|
+
}
|
|
3880
|
+
};
|
|
3881
|
+
|
|
3882
|
+
// src/reddit/client.ts
|
|
3883
|
+
var RedditClient = class {
|
|
3884
|
+
/** Client for search operations (posts, subreddits, users, domain posts) */
|
|
3885
|
+
search;
|
|
3886
|
+
/** Client for post operations (trending, details, comments, duplicates) */
|
|
3887
|
+
posts;
|
|
3888
|
+
/** Client for subreddit operations (details, posts, rules, moderators, wiki) */
|
|
3889
|
+
subreddits;
|
|
3890
|
+
/** Client for user operations (profile, posts, comments, moderated, trophies) */
|
|
3891
|
+
users;
|
|
3892
|
+
/**
|
|
3893
|
+
* Create a new Reddit client.
|
|
3894
|
+
*
|
|
3895
|
+
* @param client - The base HTTP client for making requests.
|
|
3896
|
+
*/
|
|
3897
|
+
constructor(client) {
|
|
3898
|
+
this.search = new SearchClient3(client);
|
|
3899
|
+
this.posts = new PostsClient(client);
|
|
3900
|
+
this.subreddits = new SubredditsClient(client);
|
|
3901
|
+
this.users = new UsersClient3(client);
|
|
3902
|
+
}
|
|
3903
|
+
};
|
|
3904
|
+
|
|
3272
3905
|
// src/client.ts
|
|
3273
3906
|
var ScrapeBadger = class {
|
|
3274
3907
|
baseClient;
|
|
@@ -3280,6 +3913,8 @@ var ScrapeBadger = class {
|
|
|
3280
3913
|
vinted;
|
|
3281
3914
|
/** Google Scraper API client — 19 Google product APIs */
|
|
3282
3915
|
google;
|
|
3916
|
+
/** Reddit scraper API client */
|
|
3917
|
+
reddit;
|
|
3283
3918
|
/**
|
|
3284
3919
|
* Create a new ScrapeBadger client.
|
|
3285
3920
|
*
|
|
@@ -3318,9 +3953,10 @@ var ScrapeBadger = class {
|
|
|
3318
3953
|
this.web = new WebClient(this.baseClient);
|
|
3319
3954
|
this.vinted = new VintedClient(this.baseClient);
|
|
3320
3955
|
this.google = new GoogleClient(this.baseClient);
|
|
3956
|
+
this.reddit = new RedditClient(this.baseClient);
|
|
3321
3957
|
}
|
|
3322
3958
|
};
|
|
3323
3959
|
|
|
3324
|
-
export { AccountRestrictedError, AuthenticationError, CommunitiesClient, ConflictError, GeoClient, AiModeClient as GoogleAiModeClient, AutocompleteClient as GoogleAutocompleteClient, GoogleClient, FinanceClient as GoogleFinanceClient, FlightsClient as GoogleFlightsClient, HotelsClient as GoogleHotelsClient, ImagesClient as GoogleImagesClient, JobsClient as GoogleJobsClient, LensClient as GoogleLensClient, MapsClient as GoogleMapsClient, NewsClient as GoogleNewsClient, PatentsClient as GooglePatentsClient, ProductsClient as GoogleProductsClient, ScholarClient as GoogleScholarClient, SearchClient2 as GoogleSearchClient, ShoppingClient as GoogleShoppingClient, ShortsClient as GoogleShortsClient, TrendsClient2 as GoogleTrendsClient, VideosClient as GoogleVideosClient, InsufficientCreditsError, ListsClient, NotFoundError, RateLimitError, ScrapeBadger, ScrapeBadgerError, ServerError, SpacesClient, StreamClient, TimeoutError, TrendsClient, TweetsClient, TwitterClient, UsersClient, ValidationError, VintedClient, ItemsClient as VintedItemsClient, ReferenceClient as VintedReferenceClient, SearchClient as VintedSearchClient, UsersClient2 as VintedUsersClient, WebClient, WebSocketStreamError, collectAll, verifyWebhookSignature };
|
|
3960
|
+
export { AccountRestrictedError, AuthenticationError, CommunitiesClient, ConflictError, GeoClient, AiModeClient as GoogleAiModeClient, AutocompleteClient as GoogleAutocompleteClient, GoogleClient, FinanceClient as GoogleFinanceClient, FlightsClient as GoogleFlightsClient, HotelsClient as GoogleHotelsClient, ImagesClient as GoogleImagesClient, JobsClient as GoogleJobsClient, LensClient as GoogleLensClient, MapsClient as GoogleMapsClient, NewsClient as GoogleNewsClient, PatentsClient as GooglePatentsClient, ProductsClient as GoogleProductsClient, ScholarClient as GoogleScholarClient, SearchClient2 as GoogleSearchClient, ShoppingClient as GoogleShoppingClient, ShortsClient as GoogleShortsClient, TrendsClient2 as GoogleTrendsClient, VideosClient as GoogleVideosClient, InsufficientCreditsError, ListsClient, NotFoundError, RateLimitError, RedditClient, PostsClient as RedditPostsClient, SearchClient3 as RedditSearchClient, SubredditsClient as RedditSubredditsClient, UsersClient3 as RedditUsersClient, ScrapeBadger, ScrapeBadgerError, ServerError, SpacesClient, StreamClient, TimeoutError, TrendsClient, TweetsClient, TwitterClient, UsersClient, ValidationError, VintedClient, ItemsClient as VintedItemsClient, ReferenceClient as VintedReferenceClient, SearchClient as VintedSearchClient, UsersClient2 as VintedUsersClient, WebClient, WebSocketStreamError, collectAll, verifyWebhookSignature };
|
|
3325
3961
|
//# sourceMappingURL=index.mjs.map
|
|
3326
3962
|
//# sourceMappingURL=index.mjs.map
|