scrapebadger 0.4.0 → 0.8.0
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 +28 -291
- package/dist/index.d.cts +3287 -102
- package/dist/index.d.ts +3287 -102
- package/dist/index.js +1524 -57
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1496 -58
- package/dist/index.mjs.map +1 -1
- package/dist/twitter/index.js +1 -1
- package/dist/twitter/index.js.map +1 -1
- package/dist/twitter/index.mjs +1 -1
- package/dist/twitter/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -2186,7 +2186,7 @@ var StreamClient = class {
|
|
|
2186
2186
|
return;
|
|
2187
2187
|
}
|
|
2188
2188
|
if (!reconnect) {
|
|
2189
|
-
const reasonStr = reason instanceof Buffer ? reason.toString() :
|
|
2189
|
+
const reasonStr = reason instanceof Buffer ? reason.toString() : typeof reason === "string" ? reason : "";
|
|
2190
2190
|
emitter.emit(
|
|
2191
2191
|
"error",
|
|
2192
2192
|
new WebSocketStreamError(`WebSocket closed: ${reasonStr || String(code)}`)
|
|
@@ -2427,94 +2427,1523 @@ var WebClient = class {
|
|
|
2427
2427
|
}
|
|
2428
2428
|
/**
|
|
2429
2429
|
* Scrape a web page.
|
|
2430
|
+
*
|
|
2431
|
+
* @param url - The URL to scrape
|
|
2432
|
+
* @param options - Scrape configuration options
|
|
2433
|
+
* @returns The scrape result including content, metadata, and credit usage
|
|
2430
2434
|
*/
|
|
2431
2435
|
async scrape(url, options = {}) {
|
|
2432
2436
|
const body = { url };
|
|
2433
|
-
if (options.
|
|
2434
|
-
if (options.
|
|
2435
|
-
|
|
2436
|
-
if (options.
|
|
2437
|
-
if (options.
|
|
2438
|
-
if (options.
|
|
2439
|
-
if (options.
|
|
2437
|
+
if (options.format !== void 0) body.format = options.format;
|
|
2438
|
+
if (options.renderJs !== void 0) body.render_js = options.renderJs;
|
|
2439
|
+
if (options.engine !== void 0) body.engine = options.engine;
|
|
2440
|
+
if (options.waitFor !== void 0) body.wait_for = options.waitFor;
|
|
2441
|
+
if (options.waitTimeout !== void 0) body.wait_timeout = options.waitTimeout;
|
|
2442
|
+
if (options.waitAfterLoad !== void 0) body.wait_after_load = options.waitAfterLoad;
|
|
2443
|
+
if (options.jsScenario !== void 0) body.js_scenario = options.jsScenario;
|
|
2444
|
+
if (options.sessionId !== void 0) body.session_id = options.sessionId;
|
|
2445
|
+
if (options.retryCount !== void 0) body.retry_count = options.retryCount;
|
|
2446
|
+
if (options.retryOnBlock !== void 0) body.retry_on_block = options.retryOnBlock;
|
|
2447
|
+
if (options.country !== void 0) body.country = options.country;
|
|
2448
|
+
if (options.customHeaders !== void 0) body.custom_headers = options.customHeaders;
|
|
2449
|
+
if (options.screenshot !== void 0) body.screenshot = options.screenshot;
|
|
2450
|
+
if (options.video !== void 0) body.video = options.video;
|
|
2451
|
+
if (options.antiBot !== void 0) body.anti_bot = options.antiBot;
|
|
2452
|
+
if (options.escalate !== void 0) body.escalate = options.escalate;
|
|
2440
2453
|
if (options.maxCost !== void 0) body.max_cost = options.maxCost;
|
|
2441
|
-
if (options.
|
|
2442
|
-
if (options.
|
|
2443
|
-
if (options.
|
|
2444
|
-
if (options.
|
|
2454
|
+
if (options.aiExtract !== void 0) body.ai_extract = options.aiExtract;
|
|
2455
|
+
if (options.aiPrompt !== void 0) body.ai_prompt = options.aiPrompt;
|
|
2456
|
+
if (options.rawContent !== void 0) body.raw_content = options.rawContent;
|
|
2457
|
+
if (options.skipBotDetection !== void 0) body.skip_bot_detection = options.skipBotDetection;
|
|
2445
2458
|
return this.client.request("/v1/web/scrape", {
|
|
2446
2459
|
method: "POST",
|
|
2447
2460
|
body
|
|
2448
2461
|
});
|
|
2449
2462
|
}
|
|
2450
2463
|
/**
|
|
2451
|
-
*
|
|
2464
|
+
* Extract structured data from a web page using AI.
|
|
2465
|
+
*
|
|
2466
|
+
* Convenience wrapper around {@link scrape} that enables AI extraction
|
|
2467
|
+
* with the given prompt and defaults to markdown format.
|
|
2468
|
+
*
|
|
2469
|
+
* @param url - The URL to extract data from
|
|
2470
|
+
* @param prompt - Natural language prompt describing what to extract (max 2000 chars)
|
|
2471
|
+
* @param options - Additional scrape options (aiExtract and aiPrompt are set automatically)
|
|
2472
|
+
* @returns The scrape result with ai_extraction populated
|
|
2452
2473
|
*/
|
|
2453
|
-
async
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
body.viewport_height = options.viewportHeight;
|
|
2460
|
-
if (options.imageFormat && options.imageFormat !== "png")
|
|
2461
|
-
body.image_format = options.imageFormat;
|
|
2462
|
-
if (options.waitFor) body.wait_for = options.waitFor;
|
|
2463
|
-
if (options.timeout !== void 0) body.timeout = options.timeout;
|
|
2464
|
-
return this.client.request("/v1/web/screenshot", {
|
|
2465
|
-
method: "POST",
|
|
2466
|
-
body
|
|
2474
|
+
async extract(url, prompt, options = {}) {
|
|
2475
|
+
return this.scrape(url, {
|
|
2476
|
+
format: "markdown",
|
|
2477
|
+
...options,
|
|
2478
|
+
aiExtract: true,
|
|
2479
|
+
aiPrompt: prompt
|
|
2467
2480
|
});
|
|
2468
2481
|
}
|
|
2469
2482
|
/**
|
|
2470
|
-
*
|
|
2483
|
+
* Detect anti-bot systems on a URL.
|
|
2484
|
+
*
|
|
2485
|
+
* @param url - The URL to analyze
|
|
2486
|
+
* @param options - Detection options
|
|
2487
|
+
* @returns Detection results including identified anti-bot and captcha systems
|
|
2471
2488
|
*/
|
|
2472
|
-
async
|
|
2489
|
+
async detect(url, options = {}) {
|
|
2473
2490
|
const body = { url };
|
|
2474
|
-
if (options.schema) body.extraction_schema = options.schema;
|
|
2475
|
-
if (options.renderJs) body.render_js = true;
|
|
2476
|
-
if (options.waitFor) body.wait_for = options.waitFor;
|
|
2477
2491
|
if (options.timeout !== void 0) body.timeout = options.timeout;
|
|
2478
|
-
|
|
2492
|
+
if (options.country !== void 0) body.country = options.country;
|
|
2493
|
+
return this.client.request("/v1/web/detect", {
|
|
2479
2494
|
method: "POST",
|
|
2480
2495
|
body
|
|
2481
2496
|
});
|
|
2482
2497
|
}
|
|
2498
|
+
};
|
|
2499
|
+
|
|
2500
|
+
// src/vinted/search.ts
|
|
2501
|
+
var SearchClient = class {
|
|
2502
|
+
client;
|
|
2503
|
+
constructor(client) {
|
|
2504
|
+
this.client = client;
|
|
2505
|
+
}
|
|
2483
2506
|
/**
|
|
2484
|
-
*
|
|
2507
|
+
* Search for Vinted items.
|
|
2508
|
+
*
|
|
2509
|
+
* @param params - Search parameters including query, filters, and pagination.
|
|
2510
|
+
* @returns Search results with items and pagination metadata.
|
|
2511
|
+
* @throws AuthenticationError - If the API key is invalid.
|
|
2512
|
+
* @throws ValidationError - If the search parameters are invalid.
|
|
2513
|
+
*
|
|
2514
|
+
* @example
|
|
2515
|
+
* ```typescript
|
|
2516
|
+
* const results = await client.vinted.search.search({
|
|
2517
|
+
* query: "vintage jacket",
|
|
2518
|
+
* market: "fr",
|
|
2519
|
+
* page: 1,
|
|
2520
|
+
* per_page: 20,
|
|
2521
|
+
* order: "newest_first",
|
|
2522
|
+
* });
|
|
2523
|
+
* console.log(`Found ${results.pagination.total_entries} items`);
|
|
2524
|
+
* ```
|
|
2485
2525
|
*/
|
|
2486
|
-
async
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2526
|
+
async search(params) {
|
|
2527
|
+
return this.client.request("/v1/vinted/search", {
|
|
2528
|
+
params: {
|
|
2529
|
+
query: params.query,
|
|
2530
|
+
market: params.market,
|
|
2531
|
+
page: params.page,
|
|
2532
|
+
per_page: params.per_page,
|
|
2533
|
+
price_from: params.price_from,
|
|
2534
|
+
price_to: params.price_to,
|
|
2535
|
+
brand_ids: params.brand_ids,
|
|
2536
|
+
color_ids: params.color_ids,
|
|
2537
|
+
status_ids: params.status_ids,
|
|
2538
|
+
order: params.order
|
|
2539
|
+
}
|
|
2498
2540
|
});
|
|
2499
2541
|
}
|
|
2542
|
+
};
|
|
2543
|
+
|
|
2544
|
+
// src/vinted/items.ts
|
|
2545
|
+
var ItemsClient = class {
|
|
2546
|
+
client;
|
|
2547
|
+
constructor(client) {
|
|
2548
|
+
this.client = client;
|
|
2549
|
+
}
|
|
2500
2550
|
/**
|
|
2501
|
-
*
|
|
2551
|
+
* Get a single item by ID.
|
|
2552
|
+
*
|
|
2553
|
+
* @param itemId - The Vinted item ID to fetch.
|
|
2554
|
+
* @param options - Optional parameters.
|
|
2555
|
+
* @param options.market - Market code (default: "fr").
|
|
2556
|
+
* @returns The item detail response including full item data.
|
|
2557
|
+
* @throws NotFoundError - If the item doesn't exist.
|
|
2558
|
+
* @throws AuthenticationError - If the API key is invalid.
|
|
2559
|
+
*
|
|
2560
|
+
* @example
|
|
2561
|
+
* ```typescript
|
|
2562
|
+
* const response = await client.vinted.items.get(123456789);
|
|
2563
|
+
* const { item } = response;
|
|
2564
|
+
* console.log(`${item.title}: ${item.description}`);
|
|
2565
|
+
* console.log(`Brand: ${item.brand_title}, Size: ${item.size_title}`);
|
|
2566
|
+
* console.log(`Photos: ${item.photos.length}`);
|
|
2567
|
+
* ```
|
|
2502
2568
|
*/
|
|
2503
|
-
async
|
|
2504
|
-
return this.client.request(
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2569
|
+
async get(itemId, options = {}) {
|
|
2570
|
+
return this.client.request(
|
|
2571
|
+
`/v1/vinted/items/${itemId}`,
|
|
2572
|
+
{ params: { market: options.market } }
|
|
2573
|
+
);
|
|
2574
|
+
}
|
|
2575
|
+
};
|
|
2576
|
+
|
|
2577
|
+
// src/vinted/users.ts
|
|
2578
|
+
var UsersClient2 = class {
|
|
2579
|
+
client;
|
|
2580
|
+
constructor(client) {
|
|
2581
|
+
this.client = client;
|
|
2582
|
+
}
|
|
2583
|
+
/**
|
|
2584
|
+
* Get a user's profile.
|
|
2585
|
+
*
|
|
2586
|
+
* @param userId - The Vinted user ID.
|
|
2587
|
+
* @param options - Optional parameters.
|
|
2588
|
+
* @param options.market - Market code (default: "fr").
|
|
2589
|
+
* @returns The user profile response.
|
|
2590
|
+
* @throws NotFoundError - If the user doesn't exist.
|
|
2591
|
+
* @throws AuthenticationError - If the API key is invalid.
|
|
2592
|
+
*
|
|
2593
|
+
* @example
|
|
2594
|
+
* ```typescript
|
|
2595
|
+
* const response = await client.vinted.users.getProfile(12345);
|
|
2596
|
+
* const { user } = response;
|
|
2597
|
+
* console.log(`${user.login} from ${user.city}, ${user.country_code}`);
|
|
2598
|
+
* console.log(`Reputation: ${user.feedback_reputation}`);
|
|
2599
|
+
* console.log(`Items: ${user.item_count}, Followers: ${user.followers_count}`);
|
|
2600
|
+
* ```
|
|
2601
|
+
*/
|
|
2602
|
+
async getProfile(userId, options = {}) {
|
|
2603
|
+
return this.client.request(
|
|
2604
|
+
`/v1/vinted/users/${userId}`,
|
|
2605
|
+
{ params: { market: options.market } }
|
|
2606
|
+
);
|
|
2607
|
+
}
|
|
2608
|
+
/**
|
|
2609
|
+
* Get items listed by a user.
|
|
2610
|
+
*
|
|
2611
|
+
* @param userId - The Vinted user ID.
|
|
2612
|
+
* @param options - Optional parameters for pagination and market.
|
|
2613
|
+
* @param options.market - Market code (default: "fr").
|
|
2614
|
+
* @param options.page - Page number.
|
|
2615
|
+
* @param options.per_page - Items per page.
|
|
2616
|
+
* @returns The user's items with pagination metadata.
|
|
2617
|
+
* @throws NotFoundError - If the user doesn't exist.
|
|
2618
|
+
* @throws AuthenticationError - If the API key is invalid.
|
|
2619
|
+
*
|
|
2620
|
+
* @example
|
|
2621
|
+
* ```typescript
|
|
2622
|
+
* const response = await client.vinted.users.getItems(12345, {
|
|
2623
|
+
* market: "de",
|
|
2624
|
+
* page: 1,
|
|
2625
|
+
* per_page: 20,
|
|
2626
|
+
* });
|
|
2627
|
+
* console.log(`Page ${response.pagination.current_page} of ${response.pagination.total_pages}`);
|
|
2628
|
+
* for (const item of response.items) {
|
|
2629
|
+
* console.log(`${item.title} — ${item.price.amount} ${item.price.currency_code}`);
|
|
2630
|
+
* }
|
|
2631
|
+
* ```
|
|
2632
|
+
*/
|
|
2633
|
+
async getItems(userId, options = {}) {
|
|
2634
|
+
return this.client.request(
|
|
2635
|
+
`/v1/vinted/users/${userId}/items`,
|
|
2636
|
+
{
|
|
2637
|
+
params: {
|
|
2638
|
+
market: options.market,
|
|
2639
|
+
page: options.page,
|
|
2640
|
+
per_page: options.per_page
|
|
2641
|
+
}
|
|
2642
|
+
}
|
|
2643
|
+
);
|
|
2644
|
+
}
|
|
2645
|
+
};
|
|
2646
|
+
|
|
2647
|
+
// src/vinted/reference.ts
|
|
2648
|
+
var ReferenceClient = class {
|
|
2649
|
+
client;
|
|
2650
|
+
constructor(client) {
|
|
2651
|
+
this.client = client;
|
|
2652
|
+
}
|
|
2653
|
+
/**
|
|
2654
|
+
* Search for brands by keyword.
|
|
2655
|
+
*
|
|
2656
|
+
* @param options - Optional parameters.
|
|
2657
|
+
* @param options.keyword - Brand name to search for.
|
|
2658
|
+
* @param options.market - Market code (default: "fr").
|
|
2659
|
+
* @param options.per_page - Number of results per page.
|
|
2660
|
+
* @returns Brands matching the keyword.
|
|
2661
|
+
*
|
|
2662
|
+
* @example
|
|
2663
|
+
* ```typescript
|
|
2664
|
+
* const response = await client.vinted.reference.brands({
|
|
2665
|
+
* keyword: "adidas",
|
|
2666
|
+
* market: "de",
|
|
2667
|
+
* per_page: 10,
|
|
2668
|
+
* });
|
|
2669
|
+
* for (const brand of response.brands) {
|
|
2670
|
+
* console.log(`${brand.title} (${brand.slug}): ${brand.item_count} items`);
|
|
2671
|
+
* }
|
|
2672
|
+
* ```
|
|
2673
|
+
*/
|
|
2674
|
+
async brands(options = {}) {
|
|
2675
|
+
return this.client.request("/v1/vinted/brands", {
|
|
2676
|
+
params: {
|
|
2677
|
+
keyword: options.keyword,
|
|
2678
|
+
market: options.market,
|
|
2679
|
+
per_page: options.per_page
|
|
2510
2680
|
}
|
|
2511
2681
|
});
|
|
2512
2682
|
}
|
|
2513
2683
|
/**
|
|
2514
|
-
*
|
|
2684
|
+
* Get available colors for a market.
|
|
2685
|
+
*
|
|
2686
|
+
* @param options - Optional parameters.
|
|
2687
|
+
* @param options.market - Market code (default: "fr").
|
|
2688
|
+
* @returns List of available colors.
|
|
2689
|
+
*
|
|
2690
|
+
* @example
|
|
2691
|
+
* ```typescript
|
|
2692
|
+
* const response = await client.vinted.reference.colors({ market: "fr" });
|
|
2693
|
+
* for (const color of response.colors) {
|
|
2694
|
+
* console.log(`${color.title} (#${color.hex})`);
|
|
2695
|
+
* }
|
|
2696
|
+
* ```
|
|
2697
|
+
*/
|
|
2698
|
+
async colors(options = {}) {
|
|
2699
|
+
return this.client.request("/v1/vinted/colors", {
|
|
2700
|
+
params: { market: options.market }
|
|
2701
|
+
});
|
|
2702
|
+
}
|
|
2703
|
+
/**
|
|
2704
|
+
* Get available item condition statuses for a market.
|
|
2705
|
+
*
|
|
2706
|
+
* @param options - Optional parameters.
|
|
2707
|
+
* @param options.market - Market code (default: "fr").
|
|
2708
|
+
* @returns List of item condition statuses.
|
|
2709
|
+
*
|
|
2710
|
+
* @example
|
|
2711
|
+
* ```typescript
|
|
2712
|
+
* const response = await client.vinted.reference.statuses({ market: "fr" });
|
|
2713
|
+
* for (const status of response.statuses) {
|
|
2714
|
+
* console.log(`${status.id}: ${status.title}`);
|
|
2715
|
+
* }
|
|
2716
|
+
* ```
|
|
2717
|
+
*/
|
|
2718
|
+
async statuses(options = {}) {
|
|
2719
|
+
return this.client.request("/v1/vinted/statuses", {
|
|
2720
|
+
params: { market: options.market }
|
|
2721
|
+
});
|
|
2722
|
+
}
|
|
2723
|
+
/**
|
|
2724
|
+
* Get all available Vinted markets.
|
|
2725
|
+
*
|
|
2726
|
+
* @returns List of all supported Vinted markets/countries.
|
|
2727
|
+
*
|
|
2728
|
+
* @example
|
|
2729
|
+
* ```typescript
|
|
2730
|
+
* const response = await client.vinted.reference.markets();
|
|
2731
|
+
* for (const market of response.markets) {
|
|
2732
|
+
* console.log(`${market.name}: ${market.domain} (${market.currency})`);
|
|
2733
|
+
* }
|
|
2734
|
+
* ```
|
|
2735
|
+
*/
|
|
2736
|
+
async markets() {
|
|
2737
|
+
return this.client.request("/v1/vinted/markets");
|
|
2738
|
+
}
|
|
2739
|
+
};
|
|
2740
|
+
|
|
2741
|
+
// src/vinted/client.ts
|
|
2742
|
+
var VintedClient = class {
|
|
2743
|
+
/** Client for item search operations */
|
|
2744
|
+
search;
|
|
2745
|
+
/** Client for individual item operations */
|
|
2746
|
+
items;
|
|
2747
|
+
/** Client for user operations */
|
|
2748
|
+
users;
|
|
2749
|
+
/** Client for reference data (brands, colors, statuses, markets) */
|
|
2750
|
+
reference;
|
|
2751
|
+
/**
|
|
2752
|
+
* Create a new Vinted client.
|
|
2753
|
+
*
|
|
2754
|
+
* @param client - The base HTTP client for making requests.
|
|
2755
|
+
*/
|
|
2756
|
+
constructor(client) {
|
|
2757
|
+
this.search = new SearchClient(client);
|
|
2758
|
+
this.items = new ItemsClient(client);
|
|
2759
|
+
this.users = new UsersClient2(client);
|
|
2760
|
+
this.reference = new ReferenceClient(client);
|
|
2761
|
+
}
|
|
2762
|
+
};
|
|
2763
|
+
|
|
2764
|
+
// src/google/ai-mode.ts
|
|
2765
|
+
var AiModeClient = class {
|
|
2766
|
+
constructor(client) {
|
|
2767
|
+
this.client = client;
|
|
2768
|
+
}
|
|
2769
|
+
async search(params) {
|
|
2770
|
+
return this.client.request("/v1/google/ai-mode/search", {
|
|
2771
|
+
params: { ...params }
|
|
2772
|
+
});
|
|
2773
|
+
}
|
|
2774
|
+
};
|
|
2775
|
+
|
|
2776
|
+
// src/google/autocomplete.ts
|
|
2777
|
+
var AutocompleteClient = class {
|
|
2778
|
+
constructor(client) {
|
|
2779
|
+
this.client = client;
|
|
2780
|
+
}
|
|
2781
|
+
/**
|
|
2782
|
+
* Get Google autocomplete suggestions for a query.
|
|
2783
|
+
*
|
|
2784
|
+
* @example
|
|
2785
|
+
* ```typescript
|
|
2786
|
+
* const res = await client.google.autocomplete.get({ q: "apple" });
|
|
2787
|
+
* for (const s of res.suggestions) {
|
|
2788
|
+
* console.log(s.value, s.entity_name, s.thumbnail);
|
|
2789
|
+
* }
|
|
2790
|
+
* ```
|
|
2791
|
+
*/
|
|
2792
|
+
async get(params) {
|
|
2793
|
+
return this.client.request("/v1/google/autocomplete", {
|
|
2794
|
+
params: { ...params }
|
|
2795
|
+
});
|
|
2796
|
+
}
|
|
2797
|
+
};
|
|
2798
|
+
|
|
2799
|
+
// src/google/finance.ts
|
|
2800
|
+
var FinanceClient = class {
|
|
2801
|
+
constructor(client) {
|
|
2802
|
+
this.client = client;
|
|
2803
|
+
}
|
|
2804
|
+
async quote(params) {
|
|
2805
|
+
return this.client.request("/v1/google/finance/quote", {
|
|
2806
|
+
params: { ...params }
|
|
2807
|
+
});
|
|
2808
|
+
}
|
|
2809
|
+
};
|
|
2810
|
+
|
|
2811
|
+
// src/google/flights.ts
|
|
2812
|
+
var FlightsClient = class {
|
|
2813
|
+
constructor(client) {
|
|
2814
|
+
this.client = client;
|
|
2815
|
+
}
|
|
2816
|
+
/** Search Google Flights for available itineraries. */
|
|
2817
|
+
async search(params) {
|
|
2818
|
+
return this.client.request("/v1/google/flights/search", {
|
|
2819
|
+
params: { ...params }
|
|
2820
|
+
});
|
|
2821
|
+
}
|
|
2822
|
+
};
|
|
2823
|
+
|
|
2824
|
+
// src/google/hotels.ts
|
|
2825
|
+
var HotelsClient = class {
|
|
2826
|
+
constructor(client) {
|
|
2827
|
+
this.client = client;
|
|
2828
|
+
}
|
|
2829
|
+
async search(params) {
|
|
2830
|
+
return this.client.request("/v1/google/hotels/search", {
|
|
2831
|
+
params: { ...params }
|
|
2832
|
+
});
|
|
2833
|
+
}
|
|
2834
|
+
async details(params) {
|
|
2835
|
+
return this.client.request("/v1/google/hotels/details", {
|
|
2836
|
+
params: { ...params }
|
|
2837
|
+
});
|
|
2838
|
+
}
|
|
2839
|
+
};
|
|
2840
|
+
|
|
2841
|
+
// src/google/images.ts
|
|
2842
|
+
var ImagesClient = class {
|
|
2843
|
+
constructor(client) {
|
|
2844
|
+
this.client = client;
|
|
2845
|
+
}
|
|
2846
|
+
async search(params) {
|
|
2847
|
+
return this.client.request("/v1/google/images/search", {
|
|
2848
|
+
params: { ...params }
|
|
2849
|
+
});
|
|
2850
|
+
}
|
|
2851
|
+
};
|
|
2852
|
+
|
|
2853
|
+
// src/google/jobs.ts
|
|
2854
|
+
var JobsClient = class {
|
|
2855
|
+
constructor(client) {
|
|
2856
|
+
this.client = client;
|
|
2857
|
+
}
|
|
2858
|
+
async search(params) {
|
|
2859
|
+
return this.client.request("/v1/google/jobs/search", {
|
|
2860
|
+
params: { ...params }
|
|
2861
|
+
});
|
|
2862
|
+
}
|
|
2863
|
+
};
|
|
2864
|
+
|
|
2865
|
+
// src/google/lens.ts
|
|
2866
|
+
var LensClient = class {
|
|
2867
|
+
constructor(client) {
|
|
2868
|
+
this.client = client;
|
|
2869
|
+
}
|
|
2870
|
+
async search(params) {
|
|
2871
|
+
return this.client.request("/v1/google/lens/search", {
|
|
2872
|
+
params: { ...params }
|
|
2873
|
+
});
|
|
2874
|
+
}
|
|
2875
|
+
};
|
|
2876
|
+
|
|
2877
|
+
// src/google/maps.ts
|
|
2878
|
+
var MapsClient = class {
|
|
2879
|
+
constructor(client) {
|
|
2880
|
+
this.client = client;
|
|
2881
|
+
}
|
|
2882
|
+
/**
|
|
2883
|
+
* Search Maps for places by text query, place_id, or ludocid.
|
|
2884
|
+
*
|
|
2885
|
+
* Returns up to 20 results per page with full details (place_id,
|
|
2886
|
+
* data_id, GPS, rating, reviews, address, phone, website, extensions,
|
|
2887
|
+
* weekly hours, thumbnail) in a single call.
|
|
2888
|
+
*/
|
|
2889
|
+
async search(params) {
|
|
2890
|
+
if (!params.q && !params.place_id && !params.ludocid) {
|
|
2891
|
+
throw new Error("q, place_id, or ludocid is required");
|
|
2892
|
+
}
|
|
2893
|
+
return this.client.request("/v1/google/maps/search", {
|
|
2894
|
+
params: { ...params }
|
|
2895
|
+
});
|
|
2896
|
+
}
|
|
2897
|
+
/**
|
|
2898
|
+
* Get full place detail by `place_id` or `data_id`.
|
|
2899
|
+
*
|
|
2900
|
+
* Returns title, address, phone, website, GPS, rating, reviews_count,
|
|
2901
|
+
* rating_summary (per-star distribution), categories, extensions
|
|
2902
|
+
* (service_options, accessibility, offerings, payments), weekly
|
|
2903
|
+
* operating hours, popular_times graph, provider_id,
|
|
2904
|
+
* permanently_closed, thumbnail, and photo list.
|
|
2905
|
+
*/
|
|
2906
|
+
async place(params) {
|
|
2907
|
+
if (!params.place_id && !params.data_id) {
|
|
2908
|
+
throw new Error("place_id or data_id is required");
|
|
2909
|
+
}
|
|
2910
|
+
return this.client.request("/v1/google/maps/place", {
|
|
2911
|
+
params: { ...params }
|
|
2912
|
+
});
|
|
2913
|
+
}
|
|
2914
|
+
/**
|
|
2915
|
+
* Get reviews for a place (paginated, optional topic filter).
|
|
2916
|
+
*
|
|
2917
|
+
* Pass the `next_page_token` from `response.pagination.next` for
|
|
2918
|
+
* subsequent pages, or use `topic_id` from `response.topics[].id`
|
|
2919
|
+
* to scope to a specific review topic.
|
|
2920
|
+
*/
|
|
2921
|
+
async reviews(params) {
|
|
2922
|
+
return this.client.request("/v1/google/maps/reviews", {
|
|
2923
|
+
params: { ...params }
|
|
2924
|
+
});
|
|
2925
|
+
}
|
|
2926
|
+
/**
|
|
2927
|
+
* Get photos for a place with place-specific categories.
|
|
2928
|
+
*
|
|
2929
|
+
* Returns place-specific categories (Menu, Vibe, Comfort food, dish
|
|
2930
|
+
* names) and photo URLs from all CDN families. Use `category_id` to
|
|
2931
|
+
* scope to a category, or `page_size: 200` to fetch all photos in
|
|
2932
|
+
* one call (Google caps at ~120 photos per response).
|
|
2933
|
+
*/
|
|
2934
|
+
async photos(params) {
|
|
2935
|
+
return this.client.request("/v1/google/maps/photos", {
|
|
2936
|
+
params: { ...params }
|
|
2937
|
+
});
|
|
2938
|
+
}
|
|
2939
|
+
/** Get business posts (promotional updates, announcements) for a place. */
|
|
2940
|
+
async posts(params) {
|
|
2941
|
+
if (!params.data_id && !params.place_id) {
|
|
2942
|
+
throw new Error("data_id or place_id is required");
|
|
2943
|
+
}
|
|
2944
|
+
return this.client.request("/v1/google/maps/posts", {
|
|
2945
|
+
params: { ...params }
|
|
2946
|
+
});
|
|
2947
|
+
}
|
|
2948
|
+
};
|
|
2949
|
+
|
|
2950
|
+
// src/google/news.ts
|
|
2951
|
+
var NewsClient = class {
|
|
2952
|
+
constructor(client) {
|
|
2953
|
+
this.client = client;
|
|
2954
|
+
}
|
|
2955
|
+
/**
|
|
2956
|
+
* Search Google News. One of `q`, `topic_token`, `publication_token`,
|
|
2957
|
+
* or `story_token` is required (or pass no params for the trending
|
|
2958
|
+
* home feed). Returns `menu_links`, `news_results`, `related_topics`.
|
|
2959
|
+
*/
|
|
2960
|
+
async search(params = {}) {
|
|
2961
|
+
if (!params.q && !params.topic_token && !params.publication_token && !params.story_token) {
|
|
2962
|
+
throw new Error("Provide q, topic_token, publication_token, or story_token");
|
|
2963
|
+
}
|
|
2964
|
+
return this.client.request("/v1/google/news/search", {
|
|
2965
|
+
params: { ...params }
|
|
2966
|
+
});
|
|
2967
|
+
}
|
|
2968
|
+
async topics(params) {
|
|
2969
|
+
return this.client.request("/v1/google/news/topics", {
|
|
2970
|
+
params: { ...params }
|
|
2971
|
+
});
|
|
2972
|
+
}
|
|
2973
|
+
async trending(params = {}) {
|
|
2974
|
+
return this.client.request("/v1/google/news/trending", {
|
|
2975
|
+
params: { ...params }
|
|
2976
|
+
});
|
|
2977
|
+
}
|
|
2978
|
+
};
|
|
2979
|
+
|
|
2980
|
+
// src/google/patents.ts
|
|
2981
|
+
var PatentsClient = class {
|
|
2982
|
+
constructor(client) {
|
|
2983
|
+
this.client = client;
|
|
2984
|
+
}
|
|
2985
|
+
async search(params) {
|
|
2986
|
+
return this.client.request("/v1/google/patents/search", {
|
|
2987
|
+
params: { ...params }
|
|
2988
|
+
});
|
|
2989
|
+
}
|
|
2990
|
+
/**
|
|
2991
|
+
* Get rich patent document details by patent number.
|
|
2992
|
+
*
|
|
2993
|
+
* Response includes full abstract + every claim + complete description,
|
|
2994
|
+
* plus structured `cpc_classifications` (code + description), split
|
|
2995
|
+
* `backward_citations` / `forward_citations` (with `primary_examiner`
|
|
2996
|
+
* flag), `non_patent_citations`, `concepts` (research fields),
|
|
2997
|
+
* `legal_events` (prosecution history), `figures` (full-res URLs),
|
|
2998
|
+
* every `inventor`, and the full `assignees_original` history.
|
|
2515
2999
|
*/
|
|
2516
|
-
async
|
|
2517
|
-
return this.
|
|
3000
|
+
async detail(params) {
|
|
3001
|
+
return this.client.request("/v1/google/patents/detail", {
|
|
3002
|
+
params: { ...params }
|
|
3003
|
+
});
|
|
3004
|
+
}
|
|
3005
|
+
};
|
|
3006
|
+
|
|
3007
|
+
// src/google/products.ts
|
|
3008
|
+
var ProductsClient = class {
|
|
3009
|
+
constructor(client) {
|
|
3010
|
+
this.client = client;
|
|
3011
|
+
}
|
|
3012
|
+
async detail(params) {
|
|
3013
|
+
return this.client.request("/v1/google/products/detail", {
|
|
3014
|
+
params: { ...params }
|
|
3015
|
+
});
|
|
3016
|
+
}
|
|
3017
|
+
};
|
|
3018
|
+
|
|
3019
|
+
// src/google/scholar.ts
|
|
3020
|
+
var ScholarClient = class {
|
|
3021
|
+
constructor(client) {
|
|
3022
|
+
this.client = client;
|
|
3023
|
+
}
|
|
3024
|
+
/**
|
|
3025
|
+
* Search Google Scholar. Returns each result with doc `id`, `type`
|
|
3026
|
+
* badge, wrapped `inline_links`, PDF `resources`, and structured
|
|
3027
|
+
* authors. Envelope includes `scholar_results` alias,
|
|
3028
|
+
* `related_searches`, and matched `profiles` cards.
|
|
3029
|
+
*/
|
|
3030
|
+
async search(params) {
|
|
3031
|
+
return this.client.request("/v1/google/scholar/search", {
|
|
3032
|
+
params: { ...params }
|
|
3033
|
+
});
|
|
3034
|
+
}
|
|
3035
|
+
/** Search Google Scholar for author profiles by name. */
|
|
3036
|
+
async profiles(params) {
|
|
3037
|
+
return this.client.request("/v1/google/scholar/profiles", {
|
|
3038
|
+
params: { ...params }
|
|
3039
|
+
});
|
|
3040
|
+
}
|
|
3041
|
+
/**
|
|
3042
|
+
* Full Scholar author profile: structured `interests_detailed`,
|
|
3043
|
+
* publications (with per-article `citation_id` + nested
|
|
3044
|
+
* `cited_by{value, link, citation_id}`), stats, and co-authors.
|
|
3045
|
+
*/
|
|
3046
|
+
async author(params) {
|
|
3047
|
+
return this.client.request("/v1/google/scholar/author", {
|
|
3048
|
+
params: { ...params }
|
|
3049
|
+
});
|
|
3050
|
+
}
|
|
3051
|
+
/** Citations-per-year chart for a Scholar author. */
|
|
3052
|
+
async authorCitation(params) {
|
|
3053
|
+
return this.client.request("/v1/google/scholar/author/citation", {
|
|
3054
|
+
params: { ...params }
|
|
3055
|
+
});
|
|
3056
|
+
}
|
|
3057
|
+
/**
|
|
3058
|
+
* MLA / APA / Chicago / Harvard / Vancouver citation formats plus
|
|
3059
|
+
* BibTeX / RIS / EndNote / RefWorks export links for a paper.
|
|
3060
|
+
*/
|
|
3061
|
+
async cite(params) {
|
|
3062
|
+
return this.client.request("/v1/google/scholar/cite", {
|
|
3063
|
+
params: { ...params }
|
|
3064
|
+
});
|
|
3065
|
+
}
|
|
3066
|
+
};
|
|
3067
|
+
|
|
3068
|
+
// src/google/search.ts
|
|
3069
|
+
var SearchClient2 = class {
|
|
3070
|
+
constructor(client) {
|
|
3071
|
+
this.client = client;
|
|
3072
|
+
}
|
|
3073
|
+
/**
|
|
3074
|
+
* Search Google and get a structured SERP response with organic results,
|
|
3075
|
+
* knowledge graph, People Also Ask, related searches, AI overview, and
|
|
3076
|
+
* pagination.
|
|
3077
|
+
*/
|
|
3078
|
+
async search(params) {
|
|
3079
|
+
return this.client.request("/v1/google/search", { params: { ...params } });
|
|
3080
|
+
}
|
|
3081
|
+
/**
|
|
3082
|
+
* Lightweight Google Search — organic results + related searches only.
|
|
3083
|
+
*
|
|
3084
|
+
* ~40% faster than {@link search}. Skips ads, Knowledge Graph, AI
|
|
3085
|
+
* Overview, local pack, news, inline videos, and shopping blocks.
|
|
3086
|
+
* Credit cost is configured per-endpoint by admins — query
|
|
3087
|
+
* `/public/pricing` for the live rate.
|
|
3088
|
+
*
|
|
3089
|
+
* @example
|
|
3090
|
+
* ```typescript
|
|
3091
|
+
* const lite = await client.google.search.light({ q: "python 3.13" });
|
|
3092
|
+
* ```
|
|
3093
|
+
*/
|
|
3094
|
+
async light(params) {
|
|
3095
|
+
return this.client.request("/v1/google/search", {
|
|
3096
|
+
params: { ...params, mode: "fast" }
|
|
3097
|
+
});
|
|
3098
|
+
}
|
|
3099
|
+
};
|
|
3100
|
+
|
|
3101
|
+
// src/google/shopping.ts
|
|
3102
|
+
var ShoppingClient = class {
|
|
3103
|
+
constructor(client) {
|
|
3104
|
+
this.client = client;
|
|
3105
|
+
}
|
|
3106
|
+
/** Search Google Shopping for products. */
|
|
3107
|
+
async search(params) {
|
|
3108
|
+
return this.client.request("/v1/google/shopping/search", {
|
|
3109
|
+
params: { ...params }
|
|
3110
|
+
});
|
|
3111
|
+
}
|
|
3112
|
+
/** Fetch the Google Shopping product detail page by `product_id`. */
|
|
3113
|
+
async product(params) {
|
|
3114
|
+
return this.client.request("/v1/google/shopping/product", {
|
|
3115
|
+
params: { ...params }
|
|
3116
|
+
});
|
|
3117
|
+
}
|
|
3118
|
+
/**
|
|
3119
|
+
* Resolve the direct merchant URL for a Shopping product tile via
|
|
3120
|
+
* Google's "I'm Feeling Lucky" redirect (scoped to the card's `source`
|
|
3121
|
+
* merchant via the `site:` operator). You only pay for the call when
|
|
3122
|
+
* you actually want the merchant link — no bulk enrichment of every
|
|
3123
|
+
* tile.
|
|
3124
|
+
*/
|
|
3125
|
+
async click(params) {
|
|
3126
|
+
return this.client.request("/v1/google/shopping/product/click", {
|
|
3127
|
+
params: { ...params }
|
|
3128
|
+
});
|
|
3129
|
+
}
|
|
3130
|
+
};
|
|
3131
|
+
|
|
3132
|
+
// src/google/shorts.ts
|
|
3133
|
+
var ShortsClient = class {
|
|
3134
|
+
constructor(client) {
|
|
3135
|
+
this.client = client;
|
|
3136
|
+
}
|
|
3137
|
+
async search(params) {
|
|
3138
|
+
return this.client.request("/v1/google/shorts/search", {
|
|
3139
|
+
params: { ...params }
|
|
3140
|
+
});
|
|
3141
|
+
}
|
|
3142
|
+
};
|
|
3143
|
+
|
|
3144
|
+
// src/google/trends.ts
|
|
3145
|
+
var TrendsClient2 = class {
|
|
3146
|
+
constructor(client) {
|
|
3147
|
+
this.client = client;
|
|
3148
|
+
}
|
|
3149
|
+
async interest(params) {
|
|
3150
|
+
return this.client.request("/v1/google/trends/interest", {
|
|
3151
|
+
params: { ...params }
|
|
3152
|
+
});
|
|
3153
|
+
}
|
|
3154
|
+
async regions(params) {
|
|
3155
|
+
return this.client.request("/v1/google/trends/regions", {
|
|
3156
|
+
params: { ...params }
|
|
3157
|
+
});
|
|
3158
|
+
}
|
|
3159
|
+
async related(params) {
|
|
3160
|
+
return this.client.request("/v1/google/trends/related", {
|
|
3161
|
+
params: { ...params }
|
|
3162
|
+
});
|
|
3163
|
+
}
|
|
3164
|
+
async trending(params = {}) {
|
|
3165
|
+
return this.client.request("/v1/google/trends/trending", {
|
|
3166
|
+
params: { ...params }
|
|
3167
|
+
});
|
|
3168
|
+
}
|
|
3169
|
+
/**
|
|
3170
|
+
* Current trending searches with the full Google Trends UI filter set
|
|
3171
|
+
* — `geo`, `hours`, `category`, `status`, `sort`, `hl`.
|
|
3172
|
+
*/
|
|
3173
|
+
async trendingNow(params = {}) {
|
|
3174
|
+
return this.client.request("/v1/google/trends/trending-now", {
|
|
3175
|
+
params: { ...params }
|
|
3176
|
+
});
|
|
3177
|
+
}
|
|
3178
|
+
/**
|
|
3179
|
+
* Unified Google Trends query — pick the response shape via
|
|
3180
|
+
* `data_type` (TIMESERIES | GEO_MAP | GEO_MAP_0 | RELATED_TOPICS |
|
|
3181
|
+
* RELATED_QUERIES).
|
|
3182
|
+
*/
|
|
3183
|
+
async search(params) {
|
|
3184
|
+
return this.client.request("/v1/google/trends/search", {
|
|
3185
|
+
params: { ...params }
|
|
3186
|
+
});
|
|
3187
|
+
}
|
|
3188
|
+
/**
|
|
3189
|
+
* Return categorized Knowledge Graph topic entities (`mid`, `type`,
|
|
3190
|
+
* direct link into Trends explore) for a query prefix. Distinct from
|
|
3191
|
+
* Google Search autocomplete.
|
|
3192
|
+
*/
|
|
3193
|
+
async autocomplete(params) {
|
|
3194
|
+
return this.client.request("/v1/google/trends/autocomplete", {
|
|
3195
|
+
params: { ...params }
|
|
3196
|
+
});
|
|
3197
|
+
}
|
|
3198
|
+
};
|
|
3199
|
+
|
|
3200
|
+
// src/google/videos.ts
|
|
3201
|
+
var VideosClient = class {
|
|
3202
|
+
constructor(client) {
|
|
3203
|
+
this.client = client;
|
|
3204
|
+
}
|
|
3205
|
+
async search(params) {
|
|
3206
|
+
return this.client.request("/v1/google/videos/search", {
|
|
3207
|
+
params: { ...params }
|
|
3208
|
+
});
|
|
3209
|
+
}
|
|
3210
|
+
};
|
|
3211
|
+
|
|
3212
|
+
// src/google/client.ts
|
|
3213
|
+
var GoogleClient = class {
|
|
3214
|
+
/** Google Web Search (SERP) — with optional deferred AI Overview follow-up. */
|
|
3215
|
+
search;
|
|
3216
|
+
/** Google Maps — places, reviews, photos, posts. */
|
|
3217
|
+
maps;
|
|
3218
|
+
/** Google News — articles, topics, trending. */
|
|
3219
|
+
news;
|
|
3220
|
+
/** Google Hotels — search and property details. */
|
|
3221
|
+
hotels;
|
|
3222
|
+
/** Google Trends — interest, regions, related, trending, topic autocomplete. */
|
|
3223
|
+
trends;
|
|
3224
|
+
/** Google Jobs. */
|
|
3225
|
+
jobs;
|
|
3226
|
+
/** Google Shopping — search, details, click enrichment. */
|
|
3227
|
+
shopping;
|
|
3228
|
+
/** Google Patents — search and document details. */
|
|
3229
|
+
patents;
|
|
3230
|
+
/** Google Scholar — search, profiles, author, author citation, cite formats. */
|
|
3231
|
+
scholar;
|
|
3232
|
+
/** Google Autocomplete — search suggestions. */
|
|
3233
|
+
autocomplete;
|
|
3234
|
+
/** Google Images. */
|
|
3235
|
+
images;
|
|
3236
|
+
/** Google Videos. */
|
|
3237
|
+
videos;
|
|
3238
|
+
/** Google Finance — stock and index quotes. */
|
|
3239
|
+
finance;
|
|
3240
|
+
/** Google AI Mode — generative answer responses. */
|
|
3241
|
+
aiMode;
|
|
3242
|
+
/** Google Lens — visual image search. */
|
|
3243
|
+
lens;
|
|
3244
|
+
/** Google Shorts — short-form vertical video results (udm=39). */
|
|
3245
|
+
shorts;
|
|
3246
|
+
/** Google Flights — one-way, round-trip, and multi-city itineraries. */
|
|
3247
|
+
flights;
|
|
3248
|
+
/** Google Products — immersive product detail. */
|
|
3249
|
+
products;
|
|
3250
|
+
constructor(client) {
|
|
3251
|
+
this.search = new SearchClient2(client);
|
|
3252
|
+
this.maps = new MapsClient(client);
|
|
3253
|
+
this.news = new NewsClient(client);
|
|
3254
|
+
this.hotels = new HotelsClient(client);
|
|
3255
|
+
this.trends = new TrendsClient2(client);
|
|
3256
|
+
this.jobs = new JobsClient(client);
|
|
3257
|
+
this.shopping = new ShoppingClient(client);
|
|
3258
|
+
this.patents = new PatentsClient(client);
|
|
3259
|
+
this.scholar = new ScholarClient(client);
|
|
3260
|
+
this.autocomplete = new AutocompleteClient(client);
|
|
3261
|
+
this.images = new ImagesClient(client);
|
|
3262
|
+
this.videos = new VideosClient(client);
|
|
3263
|
+
this.finance = new FinanceClient(client);
|
|
3264
|
+
this.aiMode = new AiModeClient(client);
|
|
3265
|
+
this.lens = new LensClient(client);
|
|
3266
|
+
this.shorts = new ShortsClient(client);
|
|
3267
|
+
this.flights = new FlightsClient(client);
|
|
3268
|
+
this.products = new ProductsClient(client);
|
|
3269
|
+
}
|
|
3270
|
+
};
|
|
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(
|
|
3587
|
+
`/v1/reddit/subreddits/${subreddit}`
|
|
3588
|
+
);
|
|
3589
|
+
}
|
|
3590
|
+
/**
|
|
3591
|
+
* Get posts from a subreddit.
|
|
3592
|
+
*
|
|
3593
|
+
* @param subreddit - Subreddit name (without r/ prefix).
|
|
3594
|
+
* @param options - Optional parameters.
|
|
3595
|
+
* @param options.sort - Sort order (hot, new, top, rising, controversial).
|
|
3596
|
+
* @param options.time - Time filter for top/controversial (hour, day, week, month, year, all).
|
|
3597
|
+
* @param options.after - Pagination cursor for the next page.
|
|
3598
|
+
* @param options.limit - Number of results to return (max 100).
|
|
3599
|
+
* @returns Subreddit posts with pagination metadata.
|
|
3600
|
+
* @throws NotFoundError - If the subreddit doesn't exist.
|
|
3601
|
+
* @throws AuthenticationError - If the API key is invalid.
|
|
3602
|
+
*
|
|
3603
|
+
* @example
|
|
3604
|
+
* ```typescript
|
|
3605
|
+
* const response = await client.reddit.subreddits.posts("typescript", {
|
|
3606
|
+
* sort: "top",
|
|
3607
|
+
* time: "week",
|
|
3608
|
+
* limit: 25,
|
|
3609
|
+
* });
|
|
3610
|
+
* for (const post of response.posts) {
|
|
3611
|
+
* console.log(`${post.title} — ${post.score} pts`);
|
|
3612
|
+
* }
|
|
3613
|
+
* ```
|
|
3614
|
+
*/
|
|
3615
|
+
async posts(subreddit, options = {}) {
|
|
3616
|
+
return this.client.request(
|
|
3617
|
+
`/v1/reddit/subreddits/${subreddit}/posts`,
|
|
3618
|
+
{
|
|
3619
|
+
params: {
|
|
3620
|
+
sort: options.sort,
|
|
3621
|
+
time: options.time,
|
|
3622
|
+
after: options.after,
|
|
3623
|
+
limit: options.limit
|
|
3624
|
+
}
|
|
3625
|
+
}
|
|
3626
|
+
);
|
|
3627
|
+
}
|
|
3628
|
+
/**
|
|
3629
|
+
* Get the rules for a subreddit.
|
|
3630
|
+
*
|
|
3631
|
+
* @param subreddit - Subreddit name (without r/ prefix).
|
|
3632
|
+
* @returns List of subreddit rules.
|
|
3633
|
+
* @throws NotFoundError - If the subreddit doesn't exist.
|
|
3634
|
+
* @throws AuthenticationError - If the API key is invalid.
|
|
3635
|
+
*
|
|
3636
|
+
* @example
|
|
3637
|
+
* ```typescript
|
|
3638
|
+
* const response = await client.reddit.subreddits.rules("AskReddit");
|
|
3639
|
+
* for (const rule of response.rules) {
|
|
3640
|
+
* console.log(`${rule.priority}. ${rule.short_name}`);
|
|
3641
|
+
* console.log(` ${rule.description}`);
|
|
3642
|
+
* }
|
|
3643
|
+
* ```
|
|
3644
|
+
*/
|
|
3645
|
+
async rules(subreddit) {
|
|
3646
|
+
return this.client.request(
|
|
3647
|
+
`/v1/reddit/subreddits/${subreddit}/rules`
|
|
3648
|
+
);
|
|
3649
|
+
}
|
|
3650
|
+
/**
|
|
3651
|
+
* Get the moderators of a subreddit.
|
|
3652
|
+
*
|
|
3653
|
+
* @param subreddit - Subreddit name (without r/ prefix).
|
|
3654
|
+
* @param options - Optional parameters.
|
|
3655
|
+
* @param options.after - Pagination cursor for the next page.
|
|
3656
|
+
* @param options.limit - Number of results to return.
|
|
3657
|
+
* @returns List of moderators with pagination metadata.
|
|
3658
|
+
* @throws NotFoundError - If the subreddit doesn't exist.
|
|
3659
|
+
* @throws AuthenticationError - If the API key is invalid.
|
|
3660
|
+
*
|
|
3661
|
+
* @example
|
|
3662
|
+
* ```typescript
|
|
3663
|
+
* const response = await client.reddit.subreddits.moderators("programming");
|
|
3664
|
+
* for (const mod of response.moderators) {
|
|
3665
|
+
* console.log(`u/${mod.name}: [${mod.mod_permissions.join(", ")}]`);
|
|
3666
|
+
* }
|
|
3667
|
+
* ```
|
|
3668
|
+
*/
|
|
3669
|
+
async moderators(subreddit, options = {}) {
|
|
3670
|
+
return this.client.request(
|
|
3671
|
+
`/v1/reddit/subreddits/${subreddit}/moderators`,
|
|
3672
|
+
{
|
|
3673
|
+
params: {
|
|
3674
|
+
after: options.after,
|
|
3675
|
+
limit: options.limit
|
|
3676
|
+
}
|
|
3677
|
+
}
|
|
3678
|
+
);
|
|
3679
|
+
}
|
|
3680
|
+
/**
|
|
3681
|
+
* List all wiki pages in a subreddit.
|
|
3682
|
+
*
|
|
3683
|
+
* @param subreddit - Subreddit name (without r/ prefix).
|
|
3684
|
+
* @returns List of wiki page slugs.
|
|
3685
|
+
* @throws NotFoundError - If the subreddit doesn't exist.
|
|
3686
|
+
* @throws AuthenticationError - If the API key is invalid.
|
|
3687
|
+
*
|
|
3688
|
+
* @example
|
|
3689
|
+
* ```typescript
|
|
3690
|
+
* const response = await client.reddit.subreddits.wikiPages("rust");
|
|
3691
|
+
* for (const page of response.pages) {
|
|
3692
|
+
* console.log(`/r/rust/wiki/${page}`);
|
|
3693
|
+
* }
|
|
3694
|
+
* ```
|
|
3695
|
+
*/
|
|
3696
|
+
async wikiPages(subreddit) {
|
|
3697
|
+
return this.client.request(
|
|
3698
|
+
`/v1/reddit/subreddits/${subreddit}/wiki`
|
|
3699
|
+
);
|
|
3700
|
+
}
|
|
3701
|
+
/**
|
|
3702
|
+
* Get the content of a specific wiki page in a subreddit.
|
|
3703
|
+
*
|
|
3704
|
+
* @param subreddit - Subreddit name (without r/ prefix).
|
|
3705
|
+
* @param page - Wiki page slug (e.g. "index", "faq").
|
|
3706
|
+
* @returns Wiki page content and metadata.
|
|
3707
|
+
* @throws NotFoundError - If the subreddit or wiki page doesn't exist.
|
|
3708
|
+
* @throws AuthenticationError - If the API key is invalid.
|
|
3709
|
+
*
|
|
3710
|
+
* @example
|
|
3711
|
+
* ```typescript
|
|
3712
|
+
* const response = await client.reddit.subreddits.wikiPage("learnprogramming", "faq");
|
|
3713
|
+
* console.log(`Last edited by: u/${response.page.revision_by}`);
|
|
3714
|
+
* console.log(response.page.content_md);
|
|
3715
|
+
* ```
|
|
3716
|
+
*/
|
|
3717
|
+
async wikiPage(subreddit, page) {
|
|
3718
|
+
return this.client.request(
|
|
3719
|
+
`/v1/reddit/subreddits/${subreddit}/wiki/${page}`
|
|
3720
|
+
);
|
|
3721
|
+
}
|
|
3722
|
+
/**
|
|
3723
|
+
* Get the most popular subreddits on Reddit.
|
|
3724
|
+
*
|
|
3725
|
+
* @param options - Optional parameters.
|
|
3726
|
+
* @param options.after - Pagination cursor for the next page.
|
|
3727
|
+
* @param options.limit - Number of results to return (max 100).
|
|
3728
|
+
* @returns Popular subreddits with pagination metadata.
|
|
3729
|
+
* @throws AuthenticationError - If the API key is invalid.
|
|
3730
|
+
*
|
|
3731
|
+
* @example
|
|
3732
|
+
* ```typescript
|
|
3733
|
+
* const response = await client.reddit.subreddits.popular({ limit: 20 });
|
|
3734
|
+
* for (const sub of response.subreddits) {
|
|
3735
|
+
* console.log(`r/${sub.display_name}: ${sub.subscribers.toLocaleString()} subscribers`);
|
|
3736
|
+
* }
|
|
3737
|
+
* ```
|
|
3738
|
+
*/
|
|
3739
|
+
async popular(options = {}) {
|
|
3740
|
+
return this.client.request(
|
|
3741
|
+
"/v1/reddit/subreddits/popular",
|
|
3742
|
+
{
|
|
3743
|
+
params: {
|
|
3744
|
+
after: options.after,
|
|
3745
|
+
limit: options.limit
|
|
3746
|
+
}
|
|
3747
|
+
}
|
|
3748
|
+
);
|
|
3749
|
+
}
|
|
3750
|
+
/**
|
|
3751
|
+
* Get newly created subreddits on Reddit.
|
|
3752
|
+
*
|
|
3753
|
+
* @param options - Optional parameters.
|
|
3754
|
+
* @param options.after - Pagination cursor for the next page.
|
|
3755
|
+
* @param options.limit - Number of results to return (max 100).
|
|
3756
|
+
* @returns New subreddits with pagination metadata.
|
|
3757
|
+
* @throws AuthenticationError - If the API key is invalid.
|
|
3758
|
+
*
|
|
3759
|
+
* @example
|
|
3760
|
+
* ```typescript
|
|
3761
|
+
* const response = await client.reddit.subreddits.newSubreddits({ limit: 20 });
|
|
3762
|
+
* for (const sub of response.subreddits) {
|
|
3763
|
+
* console.log(`r/${sub.display_name} (created: ${new Date(sub.created_utc * 1000).toLocaleDateString()})`);
|
|
3764
|
+
* }
|
|
3765
|
+
* ```
|
|
3766
|
+
*/
|
|
3767
|
+
async newSubreddits(options = {}) {
|
|
3768
|
+
return this.client.request(
|
|
3769
|
+
"/v1/reddit/subreddits/new",
|
|
3770
|
+
{
|
|
3771
|
+
params: {
|
|
3772
|
+
after: options.after,
|
|
3773
|
+
limit: options.limit
|
|
3774
|
+
}
|
|
3775
|
+
}
|
|
3776
|
+
);
|
|
3777
|
+
}
|
|
3778
|
+
};
|
|
3779
|
+
|
|
3780
|
+
// src/reddit/users.ts
|
|
3781
|
+
var UsersClient3 = class {
|
|
3782
|
+
client;
|
|
3783
|
+
constructor(client) {
|
|
3784
|
+
this.client = client;
|
|
3785
|
+
}
|
|
3786
|
+
/**
|
|
3787
|
+
* Get a Reddit user's profile.
|
|
3788
|
+
*
|
|
3789
|
+
* @param username - The Reddit username (without u/ prefix).
|
|
3790
|
+
* @returns The user profile response.
|
|
3791
|
+
* @throws NotFoundError - If the user doesn't exist or is suspended.
|
|
3792
|
+
* @throws AuthenticationError - If the API key is invalid.
|
|
3793
|
+
*
|
|
3794
|
+
* @example
|
|
3795
|
+
* ```typescript
|
|
3796
|
+
* const response = await client.reddit.users.get("spez");
|
|
3797
|
+
* const { user } = response;
|
|
3798
|
+
* console.log(`u/${user.name}`);
|
|
3799
|
+
* console.log(`Karma: ${user.total_karma.toLocaleString()} (${user.link_karma} post, ${user.comment_karma} comment)`);
|
|
3800
|
+
* console.log(`Account age: ${new Date(user.created_utc * 1000).toLocaleDateString()}`);
|
|
3801
|
+
* ```
|
|
3802
|
+
*/
|
|
3803
|
+
async get(username) {
|
|
3804
|
+
return this.client.request(
|
|
3805
|
+
`/v1/reddit/users/${username}`
|
|
3806
|
+
);
|
|
3807
|
+
}
|
|
3808
|
+
/**
|
|
3809
|
+
* Get posts submitted by a Reddit user.
|
|
3810
|
+
*
|
|
3811
|
+
* @param username - The Reddit username (without u/ prefix).
|
|
3812
|
+
* @param options - Optional parameters.
|
|
3813
|
+
* @param options.sort - Sort order (hot, new, top, controversial).
|
|
3814
|
+
* @param options.time - Time filter for top/controversial (hour, day, week, month, year, all).
|
|
3815
|
+
* @param options.after - Pagination cursor for the next page.
|
|
3816
|
+
* @param options.limit - Number of results to return (max 100).
|
|
3817
|
+
* @returns The user's posts with pagination metadata.
|
|
3818
|
+
* @throws NotFoundError - If the user doesn't exist.
|
|
3819
|
+
* @throws AuthenticationError - If the API key is invalid.
|
|
3820
|
+
*
|
|
3821
|
+
* @example
|
|
3822
|
+
* ```typescript
|
|
3823
|
+
* const response = await client.reddit.users.posts("spez", {
|
|
3824
|
+
* sort: "top",
|
|
3825
|
+
* time: "all",
|
|
3826
|
+
* limit: 25,
|
|
3827
|
+
* });
|
|
3828
|
+
* for (const post of response.posts) {
|
|
3829
|
+
* console.log(`r/${post.subreddit}: ${post.title} (${post.score} pts)`);
|
|
3830
|
+
* }
|
|
3831
|
+
* ```
|
|
3832
|
+
*/
|
|
3833
|
+
async posts(username, options = {}) {
|
|
3834
|
+
return this.client.request(
|
|
3835
|
+
`/v1/reddit/users/${username}/posts`,
|
|
3836
|
+
{
|
|
3837
|
+
params: {
|
|
3838
|
+
sort: options.sort,
|
|
3839
|
+
time: options.time,
|
|
3840
|
+
after: options.after,
|
|
3841
|
+
limit: options.limit
|
|
3842
|
+
}
|
|
3843
|
+
}
|
|
3844
|
+
);
|
|
3845
|
+
}
|
|
3846
|
+
/**
|
|
3847
|
+
* Get comments made by a Reddit user.
|
|
3848
|
+
*
|
|
3849
|
+
* @param username - The Reddit username (without u/ prefix).
|
|
3850
|
+
* @param options - Optional parameters.
|
|
3851
|
+
* @param options.sort - Sort order (hot, new, top, controversial).
|
|
3852
|
+
* @param options.time - Time filter for top/controversial (hour, day, week, month, year, all).
|
|
3853
|
+
* @param options.after - Pagination cursor for the next page.
|
|
3854
|
+
* @param options.limit - Number of results to return (max 100).
|
|
3855
|
+
* @returns The user's comments with pagination metadata.
|
|
3856
|
+
* @throws NotFoundError - If the user doesn't exist.
|
|
3857
|
+
* @throws AuthenticationError - If the API key is invalid.
|
|
3858
|
+
*
|
|
3859
|
+
* @example
|
|
3860
|
+
* ```typescript
|
|
3861
|
+
* const response = await client.reddit.users.comments("spez", {
|
|
3862
|
+
* sort: "new",
|
|
3863
|
+
* limit: 50,
|
|
3864
|
+
* });
|
|
3865
|
+
* for (const comment of response.comments) {
|
|
3866
|
+
* console.log(`r/${comment.subreddit}: ${comment.body.slice(0, 80)}`);
|
|
3867
|
+
* }
|
|
3868
|
+
* ```
|
|
3869
|
+
*/
|
|
3870
|
+
async comments(username, options = {}) {
|
|
3871
|
+
return this.client.request(
|
|
3872
|
+
`/v1/reddit/users/${username}/comments`,
|
|
3873
|
+
{
|
|
3874
|
+
params: {
|
|
3875
|
+
sort: options.sort,
|
|
3876
|
+
time: options.time,
|
|
3877
|
+
after: options.after,
|
|
3878
|
+
limit: options.limit
|
|
3879
|
+
}
|
|
3880
|
+
}
|
|
3881
|
+
);
|
|
3882
|
+
}
|
|
3883
|
+
/**
|
|
3884
|
+
* Get subreddits moderated by a Reddit user.
|
|
3885
|
+
*
|
|
3886
|
+
* @param username - The Reddit username (without u/ prefix).
|
|
3887
|
+
* @returns Subreddits moderated by the user.
|
|
3888
|
+
* @throws NotFoundError - If the user doesn't exist.
|
|
3889
|
+
* @throws AuthenticationError - If the API key is invalid.
|
|
3890
|
+
*
|
|
3891
|
+
* @example
|
|
3892
|
+
* ```typescript
|
|
3893
|
+
* const response = await client.reddit.users.moderated("spez");
|
|
3894
|
+
* for (const sub of response.subreddits) {
|
|
3895
|
+
* console.log(`r/${sub.display_name}: ${sub.subscribers.toLocaleString()} subscribers`);
|
|
3896
|
+
* }
|
|
3897
|
+
* ```
|
|
3898
|
+
*/
|
|
3899
|
+
async moderated(username) {
|
|
3900
|
+
return this.client.request(
|
|
3901
|
+
`/v1/reddit/users/${username}/moderated`
|
|
3902
|
+
);
|
|
3903
|
+
}
|
|
3904
|
+
/**
|
|
3905
|
+
* Get trophies awarded to a Reddit user.
|
|
3906
|
+
*
|
|
3907
|
+
* @param username - The Reddit username (without u/ prefix).
|
|
3908
|
+
* @returns List of trophies awarded to the user.
|
|
3909
|
+
* @throws NotFoundError - If the user doesn't exist.
|
|
3910
|
+
* @throws AuthenticationError - If the API key is invalid.
|
|
3911
|
+
*
|
|
3912
|
+
* @example
|
|
3913
|
+
* ```typescript
|
|
3914
|
+
* const response = await client.reddit.users.trophies("spez");
|
|
3915
|
+
* for (const trophy of response.trophies) {
|
|
3916
|
+
* console.log(`${trophy.name}${trophy.description ? `: ${trophy.description}` : ""}`);
|
|
3917
|
+
* }
|
|
3918
|
+
* ```
|
|
3919
|
+
*/
|
|
3920
|
+
async trophies(username) {
|
|
3921
|
+
return this.client.request(
|
|
3922
|
+
`/v1/reddit/users/${username}/trophies`
|
|
3923
|
+
);
|
|
3924
|
+
}
|
|
3925
|
+
};
|
|
3926
|
+
|
|
3927
|
+
// src/reddit/client.ts
|
|
3928
|
+
var RedditClient = class {
|
|
3929
|
+
/** Client for search operations (posts, subreddits, users, domain posts) */
|
|
3930
|
+
search;
|
|
3931
|
+
/** Client for post operations (trending, details, comments, duplicates) */
|
|
3932
|
+
posts;
|
|
3933
|
+
/** Client for subreddit operations (details, posts, rules, moderators, wiki) */
|
|
3934
|
+
subreddits;
|
|
3935
|
+
/** Client for user operations (profile, posts, comments, moderated, trophies) */
|
|
3936
|
+
users;
|
|
3937
|
+
/**
|
|
3938
|
+
* Create a new Reddit client.
|
|
3939
|
+
*
|
|
3940
|
+
* @param client - The base HTTP client for making requests.
|
|
3941
|
+
*/
|
|
3942
|
+
constructor(client) {
|
|
3943
|
+
this.search = new SearchClient3(client);
|
|
3944
|
+
this.posts = new PostsClient(client);
|
|
3945
|
+
this.subreddits = new SubredditsClient(client);
|
|
3946
|
+
this.users = new UsersClient3(client);
|
|
2518
3947
|
}
|
|
2519
3948
|
};
|
|
2520
3949
|
|
|
@@ -2525,6 +3954,12 @@ var ScrapeBadger = class {
|
|
|
2525
3954
|
twitter;
|
|
2526
3955
|
/** Web scraping API client */
|
|
2527
3956
|
web;
|
|
3957
|
+
/** Vinted scraper API client */
|
|
3958
|
+
vinted;
|
|
3959
|
+
/** Google Scraper API client — 19 Google product APIs */
|
|
3960
|
+
google;
|
|
3961
|
+
/** Reddit scraper API client */
|
|
3962
|
+
reddit;
|
|
2528
3963
|
/**
|
|
2529
3964
|
* Create a new ScrapeBadger client.
|
|
2530
3965
|
*
|
|
@@ -2561,9 +3996,12 @@ var ScrapeBadger = class {
|
|
|
2561
3996
|
this.baseClient = new BaseClient(resolvedConfig);
|
|
2562
3997
|
this.twitter = new TwitterClient(this.baseClient);
|
|
2563
3998
|
this.web = new WebClient(this.baseClient);
|
|
3999
|
+
this.vinted = new VintedClient(this.baseClient);
|
|
4000
|
+
this.google = new GoogleClient(this.baseClient);
|
|
4001
|
+
this.reddit = new RedditClient(this.baseClient);
|
|
2564
4002
|
}
|
|
2565
4003
|
};
|
|
2566
4004
|
|
|
2567
|
-
export { AccountRestrictedError, AuthenticationError, CommunitiesClient, ConflictError, GeoClient, InsufficientCreditsError, ListsClient, NotFoundError, RateLimitError, ScrapeBadger, ScrapeBadgerError, ServerError, SpacesClient, StreamClient, TimeoutError, TrendsClient, TweetsClient, TwitterClient, UsersClient, ValidationError, WebClient, WebSocketStreamError, collectAll, verifyWebhookSignature };
|
|
4005
|
+
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 };
|
|
2568
4006
|
//# sourceMappingURL=index.mjs.map
|
|
2569
4007
|
//# sourceMappingURL=index.mjs.map
|