scrapebadger 0.1.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.
@@ -0,0 +1,1739 @@
1
+ /**
2
+ * Configuration management for the ScrapeBadger SDK.
3
+ */
4
+ interface ScrapeBadgerConfig {
5
+ /** API key for authentication */
6
+ apiKey: string;
7
+ /** Base URL for the API (default: https://api.scrapebadger.com) */
8
+ baseUrl?: string;
9
+ /** Request timeout in milliseconds (default: 30000) */
10
+ timeout?: number;
11
+ /** Maximum number of retry attempts (default: 3) */
12
+ maxRetries?: number;
13
+ /** Initial retry delay in milliseconds (default: 1000) */
14
+ retryDelay?: number;
15
+ }
16
+ interface ResolvedConfig {
17
+ apiKey: string;
18
+ baseUrl: string;
19
+ timeout: number;
20
+ maxRetries: number;
21
+ retryDelay: number;
22
+ }
23
+
24
+ /**
25
+ * Base HTTP client with retry logic and error handling.
26
+ */
27
+
28
+ interface RequestOptions {
29
+ method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
30
+ params?: Record<string, string | number | boolean | undefined>;
31
+ body?: unknown;
32
+ headers?: Record<string, string>;
33
+ }
34
+ /**
35
+ * Base HTTP client for making API requests.
36
+ */
37
+ declare class BaseClient {
38
+ private readonly config;
39
+ constructor(config: ResolvedConfig);
40
+ /**
41
+ * Make an HTTP request to the API.
42
+ */
43
+ request<T>(path: string, options?: RequestOptions): Promise<T>;
44
+ /**
45
+ * Execute request with exponential backoff retry logic.
46
+ */
47
+ private executeWithRetry;
48
+ /**
49
+ * Fetch with timeout support.
50
+ */
51
+ private fetchWithTimeout;
52
+ /**
53
+ * Handle HTTP response and convert errors.
54
+ */
55
+ private handleResponse;
56
+ /**
57
+ * Sleep for a given duration.
58
+ */
59
+ private sleep;
60
+ }
61
+
62
+ /**
63
+ * Pagination utilities for the ScrapeBadger SDK.
64
+ */
65
+ /**
66
+ * Response wrapper for paginated API responses.
67
+ */
68
+ interface PaginatedResponse<T> {
69
+ /** Array of items in the current page */
70
+ data: T[];
71
+ /** Cursor for the next page, if available */
72
+ nextCursor?: string;
73
+ /** Whether there are more pages available */
74
+ hasMore: boolean;
75
+ }
76
+ /**
77
+ * Options for paginated requests.
78
+ */
79
+ interface PaginationOptions {
80
+ /** Maximum number of items to fetch per request (default: 20) */
81
+ count?: number;
82
+ /** Cursor for pagination */
83
+ cursor?: string;
84
+ }
85
+ /**
86
+ * Options for async iteration.
87
+ */
88
+ interface IteratorOptions extends PaginationOptions {
89
+ /** Maximum total number of items to fetch (default: unlimited) */
90
+ maxItems?: number;
91
+ }
92
+ /**
93
+ * Collect all items from an async generator into an array.
94
+ *
95
+ * @param generator - Async generator to collect from
96
+ * @returns Array of all yielded items
97
+ *
98
+ * @example
99
+ * ```typescript
100
+ * const tweets = await collectAll(client.twitter.tweets.searchAll("query", { maxItems: 100 }));
101
+ * console.log(`Fetched ${tweets.length} tweets`);
102
+ * ```
103
+ */
104
+ declare function collectAll<T>(generator: AsyncGenerator<T, void, undefined>): Promise<T[]>;
105
+
106
+ /**
107
+ * TypeScript types for Twitter API responses.
108
+ *
109
+ * This module contains all the data types used by the Twitter API client.
110
+ * Types mirror the Python SDK's Pydantic models.
111
+ */
112
+ /**
113
+ * Search query type for tweet searches.
114
+ */
115
+ type QueryType = "Top" | "Latest" | "Media";
116
+ /**
117
+ * Category for trending topics.
118
+ */
119
+ type TrendCategory = "trending" | "for_you" | "news" | "sports" | "entertainment";
120
+ /**
121
+ * Tweet type filter for community tweets.
122
+ */
123
+ type CommunityTweetType = "Top" | "Latest" | "Media";
124
+ /**
125
+ * Media attachment on a tweet.
126
+ *
127
+ * Represents images, videos, or animated GIFs attached to tweets.
128
+ */
129
+ interface Media {
130
+ /** Unique identifier for the media */
131
+ media_key?: string;
132
+ /** Media type ('photo', 'video', 'animated_gif') */
133
+ type?: string;
134
+ /** Direct URL to the media */
135
+ url?: string;
136
+ /** URL to a preview/thumbnail image */
137
+ preview_image_url?: string;
138
+ /** Media width in pixels */
139
+ width?: number;
140
+ /** Media height in pixels */
141
+ height?: number;
142
+ /** Duration in milliseconds (for videos) */
143
+ duration_ms?: number;
144
+ /** Number of views (for videos) */
145
+ view_count?: number;
146
+ /** Accessibility description */
147
+ alt_text?: string;
148
+ }
149
+ /**
150
+ * A single option in a poll.
151
+ */
152
+ interface PollOption {
153
+ /** Option position (1-indexed) */
154
+ position: number;
155
+ /** Option text */
156
+ label: string;
157
+ /** Number of votes received */
158
+ votes: number;
159
+ }
160
+ /**
161
+ * A poll attached to a tweet.
162
+ */
163
+ interface Poll {
164
+ /** Unique poll identifier */
165
+ id?: string;
166
+ /** Current status ('open' or 'closed') */
167
+ voting_status?: string;
168
+ /** When the poll ends/ended */
169
+ end_datetime?: string;
170
+ /** Total poll duration */
171
+ duration_minutes?: number;
172
+ /** List of poll options with vote counts */
173
+ options: PollOption[];
174
+ }
175
+ /**
176
+ * A URL entity in tweet text.
177
+ */
178
+ interface Url {
179
+ /** The t.co shortened URL */
180
+ url?: string;
181
+ /** The fully expanded URL */
182
+ expanded_url?: string;
183
+ /** The display version of the URL */
184
+ display_url?: string;
185
+ /** Page title (if available) */
186
+ title?: string;
187
+ /** Page description (if available) */
188
+ description?: string;
189
+ }
190
+ /**
191
+ * A hashtag entity in tweet text.
192
+ */
193
+ interface Hashtag {
194
+ /** The hashtag text (without #) */
195
+ tag: string;
196
+ }
197
+ /**
198
+ * A user mention entity in tweet text.
199
+ */
200
+ interface UserMention {
201
+ /** User ID of mentioned user */
202
+ id?: string;
203
+ /** Username of mentioned user (without @) */
204
+ username?: string;
205
+ /** Display name of mentioned user */
206
+ name?: string;
207
+ }
208
+ /**
209
+ * Location information attached to a tweet.
210
+ */
211
+ interface TweetPlace {
212
+ /** Place ID */
213
+ id?: string;
214
+ /** Full place name */
215
+ full_name?: string;
216
+ /** Short place name */
217
+ name?: string;
218
+ /** Country name */
219
+ country?: string;
220
+ /** ISO country code */
221
+ country_code?: string;
222
+ /** Type of place ('city', 'country', etc.) */
223
+ place_type?: string;
224
+ }
225
+ /**
226
+ * A Twitter tweet with all associated data.
227
+ *
228
+ * This is the primary type for tweet data, containing the tweet content,
229
+ * engagement metrics, author information, and all entities.
230
+ *
231
+ * @example
232
+ * ```typescript
233
+ * const tweet = await client.twitter.tweets.getById("1234567890");
234
+ * console.log(`@${tweet.username}: ${tweet.text}`);
235
+ * console.log(`Likes: ${tweet.favorite_count}, Retweets: ${tweet.retweet_count}`);
236
+ * ```
237
+ */
238
+ interface Tweet {
239
+ /** Unique tweet identifier */
240
+ id: string;
241
+ /** Tweet text content */
242
+ text: string;
243
+ /** Full tweet text (may differ from text for long tweets) */
244
+ full_text?: string;
245
+ /** Tweet creation timestamp (ISO format) */
246
+ created_at?: string;
247
+ /** Language code */
248
+ lang?: string;
249
+ /** Author's user ID */
250
+ user_id?: string;
251
+ /** Author's username */
252
+ username?: string;
253
+ /** Author's display name */
254
+ user_name?: string;
255
+ /** Number of likes */
256
+ favorite_count: number;
257
+ /** Number of retweets */
258
+ retweet_count: number;
259
+ /** Number of replies */
260
+ reply_count: number;
261
+ /** Number of quote tweets */
262
+ quote_count: number;
263
+ /** Number of views */
264
+ view_count?: number;
265
+ /** Number of bookmarks */
266
+ bookmark_count?: number;
267
+ /** Whether the authenticated user liked this */
268
+ favorited: boolean;
269
+ /** Whether the authenticated user retweeted this */
270
+ retweeted: boolean;
271
+ /** Whether the authenticated user bookmarked this */
272
+ bookmarked: boolean;
273
+ /** Whether the tweet is marked as sensitive */
274
+ possibly_sensitive: boolean;
275
+ /** Whether this is a quote tweet */
276
+ is_quote_status: boolean;
277
+ /** Whether this is a retweet */
278
+ is_retweet: boolean;
279
+ /** ID of the conversation thread */
280
+ conversation_id?: string;
281
+ /** ID of the tweet being replied to */
282
+ in_reply_to_status_id?: string;
283
+ /** ID of the user being replied to */
284
+ in_reply_to_user_id?: string;
285
+ /** List of attached media */
286
+ media: Media[];
287
+ /** List of URLs in the tweet */
288
+ urls: Url[];
289
+ /** List of hashtags */
290
+ hashtags: Hashtag[];
291
+ /** List of user mentions */
292
+ user_mentions: UserMention[];
293
+ /** Poll data if present */
294
+ poll?: Poll;
295
+ /** Location data if present */
296
+ place?: TweetPlace;
297
+ /** ID of the quoted tweet */
298
+ quoted_status_id?: string;
299
+ /** ID of the original retweeted tweet */
300
+ retweeted_status_id?: string;
301
+ /** IDs of edit history */
302
+ edit_tweet_ids?: string[];
303
+ /** Edit deadline timestamp */
304
+ editable_until_msecs?: number;
305
+ /** Remaining edit count */
306
+ edits_remaining?: number;
307
+ /** Whether the tweet can be edited */
308
+ is_edit_eligible?: boolean;
309
+ /** Whether the tweet has a link preview card */
310
+ has_card?: boolean;
311
+ /** Card thumbnail URL */
312
+ thumbnail_url?: string;
313
+ /** Card title */
314
+ thumbnail_title?: string;
315
+ /** Whether the tweet has community notes */
316
+ has_community_notes?: boolean;
317
+ /** Client used to post the tweet */
318
+ source?: string;
319
+ }
320
+ /**
321
+ * A Twitter user profile.
322
+ *
323
+ * Contains all publicly available information about a Twitter user,
324
+ * including profile details, metrics, and relationship status.
325
+ *
326
+ * @example
327
+ * ```typescript
328
+ * const user = await client.twitter.users.getByUsername("elonmusk");
329
+ * console.log(`${user.name} (@${user.username})`);
330
+ * console.log(`Followers: ${user.followers_count.toLocaleString()}`);
331
+ * console.log(`Bio: ${user.description}`);
332
+ * ```
333
+ */
334
+ interface User {
335
+ /** Unique user identifier */
336
+ id: string;
337
+ /** User's handle (without @) */
338
+ username: string;
339
+ /** Display name */
340
+ name: string;
341
+ /** User's bio */
342
+ description?: string;
343
+ /** User-provided location */
344
+ location?: string;
345
+ /** User's website URL */
346
+ url?: string;
347
+ /** Profile picture URL */
348
+ profile_image_url?: string;
349
+ /** Banner image URL */
350
+ profile_banner_url?: string;
351
+ /** Number of followers */
352
+ followers_count: number;
353
+ /** Number of accounts followed */
354
+ following_count: number;
355
+ /** Total tweets posted */
356
+ tweet_count: number;
357
+ /** Number of lists the user is on */
358
+ listed_count: number;
359
+ /** Number of tweets liked */
360
+ favourites_count?: number;
361
+ /** Number of media posts */
362
+ media_count?: number;
363
+ /** Whether the user is verified (legacy) */
364
+ verified: boolean;
365
+ /** Type of verification */
366
+ verified_type?: string;
367
+ /** Whether the user has Twitter Blue */
368
+ is_blue_verified?: boolean;
369
+ /** Account creation timestamp */
370
+ created_at?: string;
371
+ /** Default profile */
372
+ default_profile?: boolean;
373
+ /** Default profile image */
374
+ default_profile_image?: boolean;
375
+ /** Whether the account is protected/private */
376
+ protected?: boolean;
377
+ /** Whether content may be sensitive */
378
+ possibly_sensitive?: boolean;
379
+ /** Whether they follow the authenticated user */
380
+ followed_by?: boolean;
381
+ /** Whether the authenticated user follows them */
382
+ following?: boolean;
383
+ /** Whether a follow request was sent */
384
+ follow_request_sent?: boolean;
385
+ /** Whether the authenticated user blocks them */
386
+ blocking?: boolean;
387
+ /** Whether they block the authenticated user */
388
+ blocked_by?: boolean;
389
+ /** Whether the authenticated user mutes them */
390
+ muting?: boolean;
391
+ /** Notifications enabled */
392
+ notifications?: boolean;
393
+ /** Whether DMs are allowed */
394
+ can_dm?: boolean;
395
+ /** Has custom timelines */
396
+ has_custom_timelines?: boolean;
397
+ /** Has extended profile */
398
+ has_extended_profile?: boolean;
399
+ /** Is translator */
400
+ is_translator?: boolean;
401
+ /** Is translation enabled */
402
+ is_translation_enabled?: boolean;
403
+ /** Professional type */
404
+ professional_type?: string;
405
+ /** Advertiser account type */
406
+ advertiser_account_type?: string;
407
+ /** IDs of pinned tweets */
408
+ pinned_tweet_ids?: string[];
409
+ /** Countries where withheld */
410
+ withheld_in_countries?: string[];
411
+ }
412
+ /**
413
+ * Extended "About" information for a user.
414
+ *
415
+ * Contains additional metadata about a user's account, including
416
+ * account location, username change history, and verification details.
417
+ *
418
+ * @example
419
+ * ```typescript
420
+ * const about = await client.twitter.users.getAbout("elonmusk");
421
+ * console.log(`Account based in: ${about.account_based_in}`);
422
+ * console.log(`Username changes: ${about.username_changes}`);
423
+ * ```
424
+ */
425
+ interface UserAbout {
426
+ /** User ID */
427
+ id: string;
428
+ /** REST API user ID */
429
+ rest_id?: string;
430
+ /** Username */
431
+ screen_name?: string;
432
+ /** Display name */
433
+ name?: string;
434
+ /** Region Twitter believes the account is based in */
435
+ account_based_in?: string;
436
+ /** Whether the location is verified */
437
+ location_accurate?: boolean;
438
+ /** Linked affiliate account */
439
+ affiliate_username?: string;
440
+ /** How the source was determined */
441
+ source?: string;
442
+ /** Number of username changes */
443
+ username_changes?: number;
444
+ /** Last change timestamp (ms) */
445
+ username_last_changed_at?: number;
446
+ /** Last change as datetime string */
447
+ username_last_changed_at_datetime?: string;
448
+ /** Whether identity is verified */
449
+ is_identity_verified?: boolean;
450
+ /** Verification timestamp (ms) */
451
+ verified_since_msec?: number;
452
+ /** Verification as datetime string */
453
+ verified_since_datetime?: string;
454
+ }
455
+ /**
456
+ * Response containing a list of user IDs.
457
+ *
458
+ * Used for endpoints that return ID lists without full user data,
459
+ * such as follower_ids and following_ids endpoints.
460
+ *
461
+ * @example
462
+ * ```typescript
463
+ * const ids = await client.twitter.users.getFollowerIds("elonmusk");
464
+ * console.log(`Found ${ids.ids.length.toLocaleString()} follower IDs`);
465
+ * ```
466
+ */
467
+ interface UserIds {
468
+ /** List of user IDs */
469
+ ids: number[];
470
+ /** Cursor for pagination */
471
+ next_cursor?: string;
472
+ }
473
+ /**
474
+ * A Twitter list.
475
+ *
476
+ * Represents a curated list of Twitter users.
477
+ *
478
+ * @example
479
+ * ```typescript
480
+ * const lists = await client.twitter.lists.search("tech leaders");
481
+ * for (const list of lists.data) {
482
+ * console.log(`${list.name}: ${list.member_count} members`);
483
+ * }
484
+ * ```
485
+ */
486
+ interface List {
487
+ /** Unique list identifier */
488
+ id: string;
489
+ /** List name */
490
+ name: string;
491
+ /** List description */
492
+ description?: string;
493
+ /** List creation timestamp */
494
+ created_at?: string;
495
+ /** Number of members */
496
+ member_count?: number;
497
+ /** Number of subscribers */
498
+ subscriber_count?: number;
499
+ /** 'public' or 'private' */
500
+ mode?: string;
501
+ /** Owner's user ID */
502
+ user_id?: string;
503
+ /** Owner's username */
504
+ username?: string;
505
+ }
506
+ /**
507
+ * Banner image for a community.
508
+ */
509
+ interface CommunityBanner {
510
+ /** Banner image URL */
511
+ url?: string;
512
+ /** Image width */
513
+ width?: number;
514
+ /** Image height */
515
+ height?: number;
516
+ }
517
+ /**
518
+ * A rule for a community.
519
+ */
520
+ interface CommunityRule {
521
+ /** Rule identifier */
522
+ id?: string;
523
+ /** Rule name/title */
524
+ name?: string;
525
+ /** Rule description */
526
+ description?: string;
527
+ }
528
+ /**
529
+ * A Twitter community.
530
+ *
531
+ * Represents a community with its members, rules, and settings.
532
+ *
533
+ * @example
534
+ * ```typescript
535
+ * const community = await client.twitter.communities.getDetail("123456");
536
+ * console.log(`${community.name}: ${community.member_count?.toLocaleString()} members`);
537
+ * for (const rule of community.rules || []) {
538
+ * console.log(` - ${rule.name}`);
539
+ * }
540
+ * ```
541
+ */
542
+ interface Community {
543
+ /** Unique community identifier */
544
+ id: string;
545
+ /** Community name */
546
+ name: string;
547
+ /** Community description */
548
+ description?: string;
549
+ /** Number of members */
550
+ member_count?: number;
551
+ /** Whether the authenticated user is a member */
552
+ is_member?: boolean;
553
+ /** User's role ('member', 'moderator', 'admin', 'non_member') */
554
+ role?: string;
555
+ /** Whether the community contains adult content */
556
+ is_nsfw?: boolean;
557
+ /** How users can join ('Open', 'Closed') */
558
+ join_policy?: string;
559
+ /** Who can invite members */
560
+ invites_policy?: string;
561
+ /** Whether the community is pinned */
562
+ is_pinned?: boolean;
563
+ /** Creation timestamp (Unix) */
564
+ created_at?: number;
565
+ /** Creation timestamp (ISO) */
566
+ created_at_datetime?: string;
567
+ /** Community banner image */
568
+ banner?: CommunityBanner;
569
+ /** Profile images of some members */
570
+ members_facepile_results?: string[];
571
+ /** Creator's user ID */
572
+ creator_id?: string;
573
+ /** Creator's username */
574
+ creator_username?: string;
575
+ /** Creator's display name */
576
+ creator_name?: string;
577
+ /** Primary admin's user ID */
578
+ admin_id?: string;
579
+ /** Primary admin's username */
580
+ admin_username?: string;
581
+ /** Primary admin's display name */
582
+ admin_name?: string;
583
+ /** List of community rules */
584
+ rules?: CommunityRule[];
585
+ }
586
+ /**
587
+ * A member of a community.
588
+ *
589
+ * Extends User with community-specific information.
590
+ */
591
+ interface CommunityMember {
592
+ /** The user data */
593
+ user: User;
594
+ /** Member's role in the community */
595
+ role?: string;
596
+ /** When they joined */
597
+ joined_at?: string;
598
+ }
599
+ /**
600
+ * A trending topic.
601
+ *
602
+ * @example
603
+ * ```typescript
604
+ * const trends = await client.twitter.trends.getTrends();
605
+ * for (const trend of trends.data) {
606
+ * console.log(`${trend.name}: ${trend.tweet_count || 'N/A'} tweets`);
607
+ * }
608
+ * ```
609
+ */
610
+ interface Trend {
611
+ /** Trend name/hashtag */
612
+ name: string;
613
+ /** Twitter search URL for the trend */
614
+ url?: string;
615
+ /** Search query to find tweets */
616
+ query?: string;
617
+ /** Number of tweets (if available) */
618
+ tweet_count?: number;
619
+ /** Category context */
620
+ domain_context?: string;
621
+ }
622
+ /**
623
+ * A location for trends.
624
+ *
625
+ * @example
626
+ * ```typescript
627
+ * const locations = await client.twitter.trends.getAvailableLocations();
628
+ * const usLocations = locations.data.filter(loc => loc.country_code === "US");
629
+ * ```
630
+ */
631
+ interface Location {
632
+ /** Where On Earth ID */
633
+ woeid: number;
634
+ /** Location name */
635
+ name: string;
636
+ /** Country name */
637
+ country?: string;
638
+ /** ISO country code */
639
+ country_code?: string;
640
+ /** Type of place */
641
+ place_type?: string;
642
+ }
643
+ /**
644
+ * Trends for a specific location.
645
+ *
646
+ * @example
647
+ * ```typescript
648
+ * const placeTrends = await client.twitter.trends.getPlaceTrends(23424977); // US
649
+ * console.log(`Trends in ${placeTrends.name}:`);
650
+ * for (const trend of placeTrends.trends) {
651
+ * console.log(` - ${trend.name}`);
652
+ * }
653
+ * ```
654
+ */
655
+ interface PlaceTrends {
656
+ /** Where On Earth ID */
657
+ woeid: number;
658
+ /** Location name */
659
+ name?: string;
660
+ /** Country name */
661
+ country?: string;
662
+ /** List of trends for this location */
663
+ trends: Trend[];
664
+ }
665
+ /**
666
+ * A geographic place.
667
+ *
668
+ * @example
669
+ * ```typescript
670
+ * const places = await client.twitter.geo.search({ query: "San Francisco" });
671
+ * for (const place of places.data) {
672
+ * console.log(`${place.full_name} (${place.place_type})`);
673
+ * }
674
+ * ```
675
+ */
676
+ interface Place {
677
+ /** Place ID */
678
+ id: string;
679
+ /** Short place name */
680
+ name: string;
681
+ /** Full place name */
682
+ full_name?: string;
683
+ /** Country name */
684
+ country?: string;
685
+ /** ISO country code */
686
+ country_code?: string;
687
+ /** Type of place ('city', 'country', etc.) */
688
+ place_type?: string;
689
+ /** Twitter place URL */
690
+ url?: string;
691
+ /** Geographic bounding box */
692
+ bounding_box?: Record<string, unknown>;
693
+ /** Additional place attributes */
694
+ attributes?: Record<string, string>;
695
+ }
696
+ /**
697
+ * Generic API response with data and optional cursor.
698
+ */
699
+ interface ApiResponse<T> {
700
+ /** Response data */
701
+ data: T;
702
+ /** Cursor for next page (if paginated) */
703
+ cursor?: string;
704
+ }
705
+ /**
706
+ * Paginated list response.
707
+ */
708
+ interface ListResponse<T> {
709
+ /** Array of items */
710
+ data: T[];
711
+ /** Cursor for next page */
712
+ cursor?: string;
713
+ }
714
+
715
+ /**
716
+ * Twitter Tweets API client.
717
+ *
718
+ * Provides methods for fetching tweets, searching, and getting tweet metadata.
719
+ */
720
+
721
+ /**
722
+ * Client for Twitter tweets endpoints.
723
+ *
724
+ * Provides async methods for fetching individual tweets, searching tweets,
725
+ * and getting tweet engagement data (retweeters, favoriters, replies).
726
+ *
727
+ * @example
728
+ * ```typescript
729
+ * const client = new ScrapeBadger({ apiKey: "key" });
730
+ *
731
+ * // Get single tweet
732
+ * const tweet = await client.twitter.tweets.getById("1234567890");
733
+ *
734
+ * // Search tweets
735
+ * const results = await client.twitter.tweets.search("python programming");
736
+ * for (const tweet of results.data) {
737
+ * console.log(tweet.text);
738
+ * }
739
+ *
740
+ * // Iterate through all results
741
+ * for await (const tweet of client.twitter.tweets.searchAll("python")) {
742
+ * console.log(tweet.text);
743
+ * }
744
+ * ```
745
+ */
746
+ declare class TweetsClient {
747
+ private readonly client;
748
+ constructor(client: BaseClient);
749
+ /**
750
+ * Get a single tweet by ID.
751
+ *
752
+ * @param tweetId - The tweet ID to fetch.
753
+ * @returns The tweet data.
754
+ * @throws NotFoundError - If the tweet doesn't exist.
755
+ * @throws AuthenticationError - If the API key is invalid.
756
+ *
757
+ * @example
758
+ * ```typescript
759
+ * const tweet = await client.twitter.tweets.getById("1234567890");
760
+ * console.log(`@${tweet.username}: ${tweet.text}`);
761
+ * ```
762
+ */
763
+ getById(tweetId: string): Promise<Tweet>;
764
+ /**
765
+ * Get multiple tweets by their IDs.
766
+ *
767
+ * @param tweetIds - List of tweet IDs to fetch.
768
+ * @returns Paginated response containing the tweets.
769
+ *
770
+ * @example
771
+ * ```typescript
772
+ * const tweets = await client.twitter.tweets.getByIds([
773
+ * "1234567890",
774
+ * "0987654321"
775
+ * ]);
776
+ * for (const tweet of tweets.data) {
777
+ * console.log(tweet.text);
778
+ * }
779
+ * ```
780
+ */
781
+ getByIds(tweetIds: string[]): Promise<PaginatedResponse<Tweet>>;
782
+ /**
783
+ * Get replies to a tweet.
784
+ *
785
+ * @param tweetId - The tweet ID to get replies for.
786
+ * @param options - Pagination options.
787
+ * @returns Paginated response containing reply tweets.
788
+ *
789
+ * @example
790
+ * ```typescript
791
+ * const replies = await client.twitter.tweets.getReplies("1234567890");
792
+ * for (const reply of replies.data) {
793
+ * console.log(`@${reply.username}: ${reply.text}`);
794
+ * }
795
+ *
796
+ * // Get next page
797
+ * if (replies.hasMore) {
798
+ * const more = await client.twitter.tweets.getReplies("1234567890", {
799
+ * cursor: replies.nextCursor
800
+ * });
801
+ * }
802
+ * ```
803
+ */
804
+ getReplies(tweetId: string, options?: PaginationOptions): Promise<PaginatedResponse<Tweet>>;
805
+ /**
806
+ * Get users who retweeted a tweet.
807
+ *
808
+ * @param tweetId - The tweet ID to get retweeters for.
809
+ * @param options - Pagination options.
810
+ * @returns Paginated response containing users who retweeted.
811
+ *
812
+ * @example
813
+ * ```typescript
814
+ * const retweeters = await client.twitter.tweets.getRetweeters("1234567890");
815
+ * for (const user of retweeters.data) {
816
+ * console.log(`@${user.username} retweeted`);
817
+ * }
818
+ * ```
819
+ */
820
+ getRetweeters(tweetId: string, options?: PaginationOptions): Promise<PaginatedResponse<User>>;
821
+ /**
822
+ * Get users who liked/favorited a tweet.
823
+ *
824
+ * @param tweetId - The tweet ID to get favoriters for.
825
+ * @param options - Pagination options with optional count.
826
+ * @returns Paginated response containing users who liked.
827
+ *
828
+ * @example
829
+ * ```typescript
830
+ * const likers = await client.twitter.tweets.getFavoriters("1234567890");
831
+ * console.log(`${likers.data.length} users liked this tweet`);
832
+ * ```
833
+ */
834
+ getFavoriters(tweetId: string, options?: PaginationOptions & {
835
+ count?: number;
836
+ }): Promise<PaginatedResponse<User>>;
837
+ /**
838
+ * Get tweets similar to a given tweet.
839
+ *
840
+ * @param tweetId - The tweet ID to find similar tweets for.
841
+ * @returns Paginated response containing similar tweets.
842
+ *
843
+ * @example
844
+ * ```typescript
845
+ * const similar = await client.twitter.tweets.getSimilar("1234567890");
846
+ * for (const tweet of similar.data) {
847
+ * console.log(`Similar: ${tweet.text.slice(0, 100)}...`);
848
+ * }
849
+ * ```
850
+ */
851
+ getSimilar(tweetId: string): Promise<PaginatedResponse<Tweet>>;
852
+ /**
853
+ * Search for tweets.
854
+ *
855
+ * @param query - Search query string. Supports Twitter advanced search operators.
856
+ * @param options - Search options including query type and pagination.
857
+ * @returns Paginated response containing matching tweets.
858
+ *
859
+ * @example
860
+ * ```typescript
861
+ * // Basic search
862
+ * const results = await client.twitter.tweets.search("python programming");
863
+ *
864
+ * // Latest tweets only
865
+ * const latest = await client.twitter.tweets.search("python", {
866
+ * queryType: "Latest"
867
+ * });
868
+ *
869
+ * // Advanced search operators
870
+ * const fromUser = await client.twitter.tweets.search("from:elonmusk lang:en");
871
+ * ```
872
+ */
873
+ search(query: string, options?: PaginationOptions & {
874
+ queryType?: QueryType;
875
+ }): Promise<PaginatedResponse<Tweet>>;
876
+ /**
877
+ * Iterate through all search results with automatic pagination.
878
+ *
879
+ * This is a convenience method that automatically handles pagination,
880
+ * yielding tweets one at a time.
881
+ *
882
+ * @param query - Search query string.
883
+ * @param options - Search and iteration options.
884
+ * @yields Tweet objects matching the search query.
885
+ *
886
+ * @example
887
+ * ```typescript
888
+ * // Get up to 1000 tweets
889
+ * for await (const tweet of client.twitter.tweets.searchAll("python", {
890
+ * maxItems: 1000
891
+ * })) {
892
+ * console.log(tweet.text);
893
+ * }
894
+ *
895
+ * // Collect into an array
896
+ * import { collectAll } from "scrapebadger";
897
+ * const tweets = await collectAll(
898
+ * client.twitter.tweets.searchAll("python", { maxItems: 100 })
899
+ * );
900
+ * ```
901
+ */
902
+ searchAll(query: string, options?: IteratorOptions & {
903
+ queryType?: QueryType;
904
+ }): AsyncGenerator<Tweet, void, undefined>;
905
+ /**
906
+ * Get tweets from a user's timeline.
907
+ *
908
+ * @param username - Twitter username (without @).
909
+ * @param options - Pagination options.
910
+ * @returns Paginated response containing the user's tweets.
911
+ *
912
+ * @example
913
+ * ```typescript
914
+ * const tweets = await client.twitter.tweets.getUserTweets("elonmusk");
915
+ * for (const tweet of tweets.data) {
916
+ * console.log(`${tweet.created_at}: ${tweet.text.slice(0, 100)}...`);
917
+ * }
918
+ * ```
919
+ */
920
+ getUserTweets(username: string, options?: PaginationOptions): Promise<PaginatedResponse<Tweet>>;
921
+ /**
922
+ * Iterate through all tweets from a user with automatic pagination.
923
+ *
924
+ * @param username - Twitter username (without @).
925
+ * @param options - Iteration options.
926
+ * @yields Tweet objects from the user's timeline.
927
+ *
928
+ * @example
929
+ * ```typescript
930
+ * for await (const tweet of client.twitter.tweets.getUserTweetsAll("elonmusk", {
931
+ * maxItems: 500
932
+ * })) {
933
+ * console.log(tweet.text);
934
+ * }
935
+ * ```
936
+ */
937
+ getUserTweetsAll(username: string, options?: IteratorOptions): AsyncGenerator<Tweet, void, undefined>;
938
+ }
939
+
940
+ /**
941
+ * Twitter Users API client.
942
+ *
943
+ * Provides methods for fetching user profiles, followers, following, and related data.
944
+ */
945
+
946
+ /**
947
+ * Client for Twitter users endpoints.
948
+ *
949
+ * Provides async methods for fetching user profiles, followers, following,
950
+ * and other user-related data.
951
+ *
952
+ * @example
953
+ * ```typescript
954
+ * const client = new ScrapeBadger({ apiKey: "key" });
955
+ *
956
+ * // Get user profile
957
+ * const user = await client.twitter.users.getByUsername("elonmusk");
958
+ * console.log(`${user.name}: ${user.followers_count.toLocaleString()} followers`);
959
+ *
960
+ * // Get followers
961
+ * const followers = await client.twitter.users.getFollowers("elonmusk");
962
+ *
963
+ * // Iterate through all followers
964
+ * for await (const follower of client.twitter.users.getFollowersAll("elonmusk")) {
965
+ * console.log(follower.username);
966
+ * }
967
+ * ```
968
+ */
969
+ declare class UsersClient {
970
+ private readonly client;
971
+ constructor(client: BaseClient);
972
+ /**
973
+ * Get a user by their numeric ID.
974
+ *
975
+ * @param userId - The user's numeric ID.
976
+ * @returns The user profile.
977
+ * @throws NotFoundError - If the user doesn't exist.
978
+ *
979
+ * @example
980
+ * ```typescript
981
+ * const user = await client.twitter.users.getById("44196397");
982
+ * console.log(`@${user.username}`);
983
+ * ```
984
+ */
985
+ getById(userId: string): Promise<User>;
986
+ /**
987
+ * Get a user by their username.
988
+ *
989
+ * @param username - The user's username (without @).
990
+ * @returns The user profile.
991
+ * @throws NotFoundError - If the user doesn't exist.
992
+ *
993
+ * @example
994
+ * ```typescript
995
+ * const user = await client.twitter.users.getByUsername("elonmusk");
996
+ * console.log(`${user.name} has ${user.followers_count.toLocaleString()} followers`);
997
+ * ```
998
+ */
999
+ getByUsername(username: string): Promise<User>;
1000
+ /**
1001
+ * Get extended "About" information for a user.
1002
+ *
1003
+ * Returns additional metadata including account location,
1004
+ * username change history, and verification details.
1005
+ *
1006
+ * @param username - The user's username (without @).
1007
+ * @returns Extended user information.
1008
+ *
1009
+ * @example
1010
+ * ```typescript
1011
+ * const about = await client.twitter.users.getAbout("elonmusk");
1012
+ * console.log(`Account based in: ${about.account_based_in}`);
1013
+ * console.log(`Username changes: ${about.username_changes}`);
1014
+ * ```
1015
+ */
1016
+ getAbout(username: string): Promise<UserAbout>;
1017
+ /**
1018
+ * Get a user's followers.
1019
+ *
1020
+ * @param username - The user's username (without @).
1021
+ * @param options - Pagination options.
1022
+ * @returns Paginated response containing follower users.
1023
+ *
1024
+ * @example
1025
+ * ```typescript
1026
+ * const followers = await client.twitter.users.getFollowers("elonmusk");
1027
+ * for (const user of followers.data) {
1028
+ * console.log(`@${user.username}`);
1029
+ * }
1030
+ *
1031
+ * // Get next page
1032
+ * if (followers.hasMore) {
1033
+ * const more = await client.twitter.users.getFollowers("elonmusk", {
1034
+ * cursor: followers.nextCursor
1035
+ * });
1036
+ * }
1037
+ * ```
1038
+ */
1039
+ getFollowers(username: string, options?: PaginationOptions): Promise<PaginatedResponse<User>>;
1040
+ /**
1041
+ * Iterate through all followers with automatic pagination.
1042
+ *
1043
+ * @param username - The user's username (without @).
1044
+ * @param options - Iteration options.
1045
+ * @yields User objects for each follower.
1046
+ *
1047
+ * @example
1048
+ * ```typescript
1049
+ * for await (const follower of client.twitter.users.getFollowersAll("elonmusk", {
1050
+ * maxItems: 1000
1051
+ * })) {
1052
+ * console.log(follower.username);
1053
+ * }
1054
+ * ```
1055
+ */
1056
+ getFollowersAll(username: string, options?: IteratorOptions): AsyncGenerator<User, void, undefined>;
1057
+ /**
1058
+ * Get users that a user is following.
1059
+ *
1060
+ * @param username - The user's username (without @).
1061
+ * @param options - Pagination options.
1062
+ * @returns Paginated response containing followed users.
1063
+ *
1064
+ * @example
1065
+ * ```typescript
1066
+ * const following = await client.twitter.users.getFollowing("elonmusk");
1067
+ * for (const user of following.data) {
1068
+ * console.log(`Follows @${user.username}`);
1069
+ * }
1070
+ * ```
1071
+ */
1072
+ getFollowing(username: string, options?: PaginationOptions): Promise<PaginatedResponse<User>>;
1073
+ /**
1074
+ * Iterate through all following with automatic pagination.
1075
+ *
1076
+ * @param username - The user's username (without @).
1077
+ * @param options - Iteration options.
1078
+ * @yields User objects for each followed account.
1079
+ */
1080
+ getFollowingAll(username: string, options?: IteratorOptions): AsyncGenerator<User, void, undefined>;
1081
+ /**
1082
+ * Get a user's most recent followers.
1083
+ *
1084
+ * @param username - The user's username (without @).
1085
+ * @param options - Pagination options with optional count.
1086
+ * @returns Paginated response containing recent followers.
1087
+ */
1088
+ getLatestFollowers(username: string, options?: PaginationOptions & {
1089
+ count?: number;
1090
+ }): Promise<PaginatedResponse<User>>;
1091
+ /**
1092
+ * Get accounts a user most recently followed.
1093
+ *
1094
+ * @param username - The user's username (without @).
1095
+ * @param options - Pagination options with optional count.
1096
+ * @returns Paginated response containing recently followed users.
1097
+ */
1098
+ getLatestFollowing(username: string, options?: PaginationOptions & {
1099
+ count?: number;
1100
+ }): Promise<PaginatedResponse<User>>;
1101
+ /**
1102
+ * Get follower IDs for a user.
1103
+ *
1104
+ * More efficient than getFollowers when you only need IDs.
1105
+ *
1106
+ * @param username - The user's username (without @).
1107
+ * @param options - Pagination options with optional count.
1108
+ * @returns UserIds containing list of follower IDs.
1109
+ *
1110
+ * @example
1111
+ * ```typescript
1112
+ * const ids = await client.twitter.users.getFollowerIds("elonmusk");
1113
+ * console.log(`Found ${ids.ids.length.toLocaleString()} follower IDs`);
1114
+ * ```
1115
+ */
1116
+ getFollowerIds(username: string, options?: PaginationOptions & {
1117
+ count?: number;
1118
+ }): Promise<UserIds>;
1119
+ /**
1120
+ * Get following IDs for a user.
1121
+ *
1122
+ * More efficient than getFollowing when you only need IDs.
1123
+ *
1124
+ * @param username - The user's username (without @).
1125
+ * @param options - Pagination options with optional count.
1126
+ * @returns UserIds containing list of following IDs.
1127
+ */
1128
+ getFollowingIds(username: string, options?: PaginationOptions & {
1129
+ count?: number;
1130
+ }): Promise<UserIds>;
1131
+ /**
1132
+ * Get verified followers for a user.
1133
+ *
1134
+ * @param userId - The user's numeric ID.
1135
+ * @param options - Pagination options with optional count.
1136
+ * @returns Paginated response containing verified followers.
1137
+ */
1138
+ getVerifiedFollowers(userId: string, options?: PaginationOptions & {
1139
+ count?: number;
1140
+ }): Promise<PaginatedResponse<User>>;
1141
+ /**
1142
+ * Get followers that the authenticated user also follows.
1143
+ *
1144
+ * @param userId - The user's numeric ID.
1145
+ * @param options - Pagination options with optional count.
1146
+ * @returns Paginated response containing mutual connections.
1147
+ */
1148
+ getFollowersYouKnow(userId: string, options?: PaginationOptions & {
1149
+ count?: number;
1150
+ }): Promise<PaginatedResponse<User>>;
1151
+ /**
1152
+ * Get premium accounts that a user subscribes to.
1153
+ *
1154
+ * @param userId - The user's numeric ID.
1155
+ * @param options - Pagination options with optional count.
1156
+ * @returns Paginated response containing subscribed accounts.
1157
+ */
1158
+ getSubscriptions(userId: string, options?: PaginationOptions & {
1159
+ count?: number;
1160
+ }): Promise<PaginatedResponse<User>>;
1161
+ /**
1162
+ * Get a user's highlighted tweets.
1163
+ *
1164
+ * @param userId - The user's numeric ID.
1165
+ * @param options - Pagination options with optional count.
1166
+ * @returns Paginated response containing highlighted tweets.
1167
+ */
1168
+ getHighlights(userId: string, options?: PaginationOptions & {
1169
+ count?: number;
1170
+ }): Promise<PaginatedResponse<Tweet>>;
1171
+ /**
1172
+ * Search for users.
1173
+ *
1174
+ * @param query - Search query string.
1175
+ * @param options - Pagination options.
1176
+ * @returns Paginated response containing matching users.
1177
+ *
1178
+ * @example
1179
+ * ```typescript
1180
+ * const results = await client.twitter.users.search("python developer");
1181
+ * for (const user of results.data) {
1182
+ * console.log(`@${user.username}: ${user.description}`);
1183
+ * }
1184
+ * ```
1185
+ */
1186
+ search(query: string, options?: PaginationOptions): Promise<PaginatedResponse<User>>;
1187
+ /**
1188
+ * Iterate through all search results with automatic pagination.
1189
+ *
1190
+ * @param query - Search query string.
1191
+ * @param options - Iteration options.
1192
+ * @yields User objects matching the search query.
1193
+ */
1194
+ searchAll(query: string, options?: IteratorOptions): AsyncGenerator<User, void, undefined>;
1195
+ }
1196
+
1197
+ /**
1198
+ * Twitter Lists API client.
1199
+ *
1200
+ * Provides methods for fetching Twitter lists, list members, and list tweets.
1201
+ */
1202
+
1203
+ /**
1204
+ * Client for Twitter lists endpoints.
1205
+ *
1206
+ * Provides async methods for fetching list details, members, subscribers,
1207
+ * and tweets from lists.
1208
+ *
1209
+ * @example
1210
+ * ```typescript
1211
+ * const client = new ScrapeBadger({ apiKey: "key" });
1212
+ *
1213
+ * // Search for lists
1214
+ * const lists = await client.twitter.lists.search("tech leaders");
1215
+ *
1216
+ * // Get list details
1217
+ * const list = await client.twitter.lists.getDetail("123456");
1218
+ * console.log(`${list.name}: ${list.member_count} members`);
1219
+ *
1220
+ * // Get list tweets
1221
+ * const tweets = await client.twitter.lists.getTweets("123456");
1222
+ * ```
1223
+ */
1224
+ declare class ListsClient {
1225
+ private readonly client;
1226
+ constructor(client: BaseClient);
1227
+ /**
1228
+ * Get details for a specific list.
1229
+ *
1230
+ * @param listId - The list ID.
1231
+ * @returns The list details.
1232
+ * @throws NotFoundError - If the list doesn't exist.
1233
+ *
1234
+ * @example
1235
+ * ```typescript
1236
+ * const list = await client.twitter.lists.getDetail("123456");
1237
+ * console.log(`${list.name} by @${list.username}`);
1238
+ * console.log(`${list.member_count} members, ${list.subscriber_count} subscribers`);
1239
+ * ```
1240
+ */
1241
+ getDetail(listId: string): Promise<List>;
1242
+ /**
1243
+ * Get tweets from a list's timeline.
1244
+ *
1245
+ * @param listId - The list ID.
1246
+ * @param options - Pagination options.
1247
+ * @returns Paginated response containing tweets from list members.
1248
+ *
1249
+ * @example
1250
+ * ```typescript
1251
+ * const tweets = await client.twitter.lists.getTweets("123456");
1252
+ * for (const tweet of tweets.data) {
1253
+ * console.log(`@${tweet.username}: ${tweet.text.slice(0, 100)}...`);
1254
+ * }
1255
+ * ```
1256
+ */
1257
+ getTweets(listId: string, options?: PaginationOptions): Promise<PaginatedResponse<Tweet>>;
1258
+ /**
1259
+ * Iterate through all list tweets with automatic pagination.
1260
+ *
1261
+ * @param listId - The list ID.
1262
+ * @param options - Iteration options.
1263
+ * @yields Tweet objects from the list timeline.
1264
+ */
1265
+ getTweetsAll(listId: string, options?: IteratorOptions): AsyncGenerator<Tweet, void, undefined>;
1266
+ /**
1267
+ * Get members of a list.
1268
+ *
1269
+ * @param listId - The list ID.
1270
+ * @param options - Pagination options.
1271
+ * @returns Paginated response containing list members.
1272
+ *
1273
+ * @example
1274
+ * ```typescript
1275
+ * const members = await client.twitter.lists.getMembers("123456");
1276
+ * for (const user of members.data) {
1277
+ * console.log(`@${user.username}`);
1278
+ * }
1279
+ * ```
1280
+ */
1281
+ getMembers(listId: string, options?: PaginationOptions): Promise<PaginatedResponse<User>>;
1282
+ /**
1283
+ * Iterate through all list members with automatic pagination.
1284
+ *
1285
+ * @param listId - The list ID.
1286
+ * @param options - Iteration options.
1287
+ * @yields User objects for each list member.
1288
+ */
1289
+ getMembersAll(listId: string, options?: IteratorOptions): AsyncGenerator<User, void, undefined>;
1290
+ /**
1291
+ * Get subscribers of a list.
1292
+ *
1293
+ * @param listId - The list ID.
1294
+ * @param options - Pagination options with optional count.
1295
+ * @returns Paginated response containing list subscribers.
1296
+ */
1297
+ getSubscribers(listId: string, options?: PaginationOptions & {
1298
+ count?: number;
1299
+ }): Promise<PaginatedResponse<User>>;
1300
+ /**
1301
+ * Search for lists.
1302
+ *
1303
+ * @param query - Search query string.
1304
+ * @param options - Pagination options with optional count.
1305
+ * @returns Paginated response containing matching lists.
1306
+ *
1307
+ * @example
1308
+ * ```typescript
1309
+ * const results = await client.twitter.lists.search("tech leaders");
1310
+ * for (const list of results.data) {
1311
+ * console.log(`${list.name}: ${list.member_count} members`);
1312
+ * }
1313
+ * ```
1314
+ */
1315
+ search(query: string, options?: PaginationOptions & {
1316
+ count?: number;
1317
+ }): Promise<PaginatedResponse<List>>;
1318
+ /**
1319
+ * Get lists owned by the authenticated user.
1320
+ *
1321
+ * @param options - Pagination options with optional count.
1322
+ * @returns Paginated response containing the user's lists.
1323
+ */
1324
+ getMyLists(options?: PaginationOptions & {
1325
+ count?: number;
1326
+ }): Promise<PaginatedResponse<List>>;
1327
+ }
1328
+
1329
+ /**
1330
+ * Twitter Communities API client.
1331
+ *
1332
+ * Provides methods for fetching Twitter communities, members, and tweets.
1333
+ */
1334
+
1335
+ /**
1336
+ * Client for Twitter communities endpoints.
1337
+ *
1338
+ * Provides async methods for fetching community details, members,
1339
+ * moderators, and tweets.
1340
+ *
1341
+ * @example
1342
+ * ```typescript
1343
+ * const client = new ScrapeBadger({ apiKey: "key" });
1344
+ *
1345
+ * // Search communities
1346
+ * const communities = await client.twitter.communities.search("python");
1347
+ *
1348
+ * // Get community details
1349
+ * const community = await client.twitter.communities.getDetail("123456");
1350
+ * console.log(`${community.name}: ${community.member_count} members`);
1351
+ *
1352
+ * // Get community tweets
1353
+ * const tweets = await client.twitter.communities.getTweets("123456");
1354
+ * ```
1355
+ */
1356
+ declare class CommunitiesClient {
1357
+ private readonly client;
1358
+ constructor(client: BaseClient);
1359
+ /**
1360
+ * Get details for a specific community.
1361
+ *
1362
+ * @param communityId - The community ID.
1363
+ * @returns The community details including rules and admin info.
1364
+ * @throws NotFoundError - If the community doesn't exist.
1365
+ *
1366
+ * @example
1367
+ * ```typescript
1368
+ * const community = await client.twitter.communities.getDetail("123456");
1369
+ * console.log(`${community.name}`);
1370
+ * console.log(`Members: ${community.member_count?.toLocaleString()}`);
1371
+ * console.log(`Join policy: ${community.join_policy}`);
1372
+ *
1373
+ * if (community.rules) {
1374
+ * console.log("Rules:");
1375
+ * for (const rule of community.rules) {
1376
+ * console.log(` - ${rule.name}`);
1377
+ * }
1378
+ * }
1379
+ * ```
1380
+ */
1381
+ getDetail(communityId: string): Promise<Community>;
1382
+ /**
1383
+ * Get tweets from a community.
1384
+ *
1385
+ * @param communityId - The community ID.
1386
+ * @param options - Options including tweet type, count, and pagination.
1387
+ * @returns Paginated response containing community tweets.
1388
+ *
1389
+ * @example
1390
+ * ```typescript
1391
+ * // Get top tweets
1392
+ * const tweets = await client.twitter.communities.getTweets("123456");
1393
+ *
1394
+ * // Get latest tweets
1395
+ * const latest = await client.twitter.communities.getTweets("123456", {
1396
+ * tweetType: "Latest"
1397
+ * });
1398
+ * ```
1399
+ */
1400
+ getTweets(communityId: string, options?: PaginationOptions & {
1401
+ tweetType?: CommunityTweetType;
1402
+ count?: number;
1403
+ }): Promise<PaginatedResponse<Tweet>>;
1404
+ /**
1405
+ * Iterate through all community tweets with automatic pagination.
1406
+ *
1407
+ * @param communityId - The community ID.
1408
+ * @param options - Options including tweet type and iteration limits.
1409
+ * @yields Tweet objects from the community.
1410
+ */
1411
+ getTweetsAll(communityId: string, options?: IteratorOptions & {
1412
+ tweetType?: CommunityTweetType;
1413
+ }): AsyncGenerator<Tweet, void, undefined>;
1414
+ /**
1415
+ * Get members of a community.
1416
+ *
1417
+ * @param communityId - The community ID.
1418
+ * @param options - Pagination options with optional count.
1419
+ * @returns Paginated response containing community members.
1420
+ *
1421
+ * @example
1422
+ * ```typescript
1423
+ * const members = await client.twitter.communities.getMembers("123456");
1424
+ * for (const member of members.data) {
1425
+ * console.log(`@${member.user.username} (${member.role})`);
1426
+ * }
1427
+ * ```
1428
+ */
1429
+ getMembers(communityId: string, options?: PaginationOptions & {
1430
+ count?: number;
1431
+ }): Promise<PaginatedResponse<CommunityMember>>;
1432
+ /**
1433
+ * Get moderators of a community.
1434
+ *
1435
+ * @param communityId - The community ID.
1436
+ * @param options - Pagination options with optional count.
1437
+ * @returns Paginated response containing community moderators.
1438
+ */
1439
+ getModerators(communityId: string, options?: PaginationOptions & {
1440
+ count?: number;
1441
+ }): Promise<PaginatedResponse<CommunityMember>>;
1442
+ /**
1443
+ * Search for communities.
1444
+ *
1445
+ * @param query - Search query string.
1446
+ * @param options - Pagination options.
1447
+ * @returns Paginated response containing matching communities.
1448
+ *
1449
+ * @example
1450
+ * ```typescript
1451
+ * const results = await client.twitter.communities.search("python developers");
1452
+ * for (const community of results.data) {
1453
+ * console.log(`${community.name}: ${community.member_count} members`);
1454
+ * }
1455
+ * ```
1456
+ */
1457
+ search(query: string, options?: PaginationOptions): Promise<PaginatedResponse<Community>>;
1458
+ /**
1459
+ * Search for tweets within a community.
1460
+ *
1461
+ * @param communityId - The community ID.
1462
+ * @param query - Search query string.
1463
+ * @param options - Pagination options with optional count.
1464
+ * @returns Paginated response containing matching tweets.
1465
+ */
1466
+ searchTweets(communityId: string, query: string, options?: PaginationOptions & {
1467
+ count?: number;
1468
+ }): Promise<PaginatedResponse<Tweet>>;
1469
+ /**
1470
+ * Get the community timeline (tweets from communities you're in).
1471
+ *
1472
+ * @param options - Pagination options with optional count.
1473
+ * @returns Paginated response containing community timeline tweets.
1474
+ */
1475
+ getTimeline(options?: PaginationOptions & {
1476
+ count?: number;
1477
+ }): Promise<PaginatedResponse<Tweet>>;
1478
+ }
1479
+
1480
+ /**
1481
+ * Twitter Trends API client.
1482
+ *
1483
+ * Provides methods for fetching trending topics and trend locations.
1484
+ */
1485
+
1486
+ /**
1487
+ * Client for Twitter trends endpoints.
1488
+ *
1489
+ * Provides async methods for fetching trending topics, place-specific trends,
1490
+ * and available trend locations.
1491
+ *
1492
+ * @example
1493
+ * ```typescript
1494
+ * const client = new ScrapeBadger({ apiKey: "key" });
1495
+ *
1496
+ * // Get global trends
1497
+ * const trends = await client.twitter.trends.getTrends();
1498
+ * for (const trend of trends.data) {
1499
+ * console.log(`${trend.name}: ${trend.tweet_count || 'N/A'} tweets`);
1500
+ * }
1501
+ *
1502
+ * // Get trends for a specific location
1503
+ * const usTrends = await client.twitter.trends.getPlaceTrends(23424977);
1504
+ *
1505
+ * // Get available locations
1506
+ * const locations = await client.twitter.trends.getAvailableLocations();
1507
+ * ```
1508
+ */
1509
+ declare class TrendsClient {
1510
+ private readonly client;
1511
+ constructor(client: BaseClient);
1512
+ /**
1513
+ * Get trending topics.
1514
+ *
1515
+ * @param options - Options for filtering trends.
1516
+ * @returns Paginated response containing trending topics.
1517
+ *
1518
+ * @example
1519
+ * ```typescript
1520
+ * // Get general trending topics
1521
+ * const trends = await client.twitter.trends.getTrends();
1522
+ *
1523
+ * // Get news trends
1524
+ * const newsTrends = await client.twitter.trends.getTrends({
1525
+ * category: "news"
1526
+ * });
1527
+ *
1528
+ * for (const trend of trends.data) {
1529
+ * const count = trend.tweet_count?.toLocaleString() || "N/A";
1530
+ * console.log(`${trend.name}: ${count} tweets`);
1531
+ * }
1532
+ * ```
1533
+ */
1534
+ getTrends(options?: {
1535
+ category?: TrendCategory;
1536
+ count?: number;
1537
+ }): Promise<PaginatedResponse<Trend>>;
1538
+ /**
1539
+ * Get trends for a specific location.
1540
+ *
1541
+ * @param woeid - Where On Earth ID for the location.
1542
+ * Common WOEIDs:
1543
+ * - 1: Worldwide
1544
+ * - 23424977: United States
1545
+ * - 23424975: United Kingdom
1546
+ * - 23424856: Japan
1547
+ * - 23424829: Germany
1548
+ * @returns PlaceTrends containing location info and trends.
1549
+ * @throws NotFoundError - If the WOEID is invalid.
1550
+ *
1551
+ * @example
1552
+ * ```typescript
1553
+ * // Get US trends
1554
+ * const usTrends = await client.twitter.trends.getPlaceTrends(23424977);
1555
+ * console.log(`Trends in ${usTrends.name}:`);
1556
+ * for (const trend of usTrends.trends) {
1557
+ * console.log(` - ${trend.name}`);
1558
+ * }
1559
+ *
1560
+ * // Get worldwide trends
1561
+ * const globalTrends = await client.twitter.trends.getPlaceTrends(1);
1562
+ * ```
1563
+ */
1564
+ getPlaceTrends(woeid: number): Promise<PlaceTrends>;
1565
+ /**
1566
+ * Get all locations where trends are available.
1567
+ *
1568
+ * @returns Paginated response containing available trend locations.
1569
+ *
1570
+ * @example
1571
+ * ```typescript
1572
+ * const locations = await client.twitter.trends.getAvailableLocations();
1573
+ *
1574
+ * // Filter by country
1575
+ * const usLocations = locations.data.filter(
1576
+ * loc => loc.country_code === "US"
1577
+ * );
1578
+ * console.log(`Found ${usLocations.length} US locations`);
1579
+ *
1580
+ * // Get countries only
1581
+ * const countries = locations.data.filter(
1582
+ * loc => loc.place_type === "Country"
1583
+ * );
1584
+ * ```
1585
+ */
1586
+ getAvailableLocations(): Promise<PaginatedResponse<Location>>;
1587
+ }
1588
+
1589
+ /**
1590
+ * Twitter Geo API client.
1591
+ *
1592
+ * Provides methods for fetching geographic place information.
1593
+ */
1594
+
1595
+ /**
1596
+ * Options for searching places.
1597
+ */
1598
+ interface GeoSearchOptions {
1599
+ /** Latitude coordinate */
1600
+ lat?: number;
1601
+ /** Longitude coordinate */
1602
+ long?: number;
1603
+ /** Free-form text search query (e.g., "San Francisco") */
1604
+ query?: string;
1605
+ /** IP address for location lookup */
1606
+ ip?: string;
1607
+ /** Result granularity ("neighborhood", "city", "admin", "country") */
1608
+ granularity?: string;
1609
+ /** Maximum number of results (1-100) */
1610
+ maxResults?: number;
1611
+ }
1612
+ /**
1613
+ * Client for Twitter geo/places endpoints.
1614
+ *
1615
+ * Provides async methods for fetching place details and searching
1616
+ * for geographic locations.
1617
+ *
1618
+ * @example
1619
+ * ```typescript
1620
+ * const client = new ScrapeBadger({ apiKey: "key" });
1621
+ *
1622
+ * // Search for places
1623
+ * const places = await client.twitter.geo.search({ query: "San Francisco" });
1624
+ *
1625
+ * // Search by coordinates
1626
+ * const nearby = await client.twitter.geo.search({ lat: 37.7749, long: -122.4194 });
1627
+ *
1628
+ * // Get place details
1629
+ * const place = await client.twitter.geo.getDetail("5a110d312052166f");
1630
+ * ```
1631
+ */
1632
+ declare class GeoClient {
1633
+ private readonly client;
1634
+ constructor(client: BaseClient);
1635
+ /**
1636
+ * Get details for a specific place.
1637
+ *
1638
+ * @param placeId - The Twitter place ID.
1639
+ * @returns The place details.
1640
+ * @throws NotFoundError - If the place doesn't exist.
1641
+ *
1642
+ * @example
1643
+ * ```typescript
1644
+ * const place = await client.twitter.geo.getDetail("5a110d312052166f");
1645
+ * console.log(`${place.full_name}`);
1646
+ * console.log(`Type: ${place.place_type}`);
1647
+ * console.log(`Country: ${place.country}`);
1648
+ * ```
1649
+ */
1650
+ getDetail(placeId: string): Promise<Place>;
1651
+ /**
1652
+ * Search for geographic places.
1653
+ *
1654
+ * At least one of lat/long, query, or ip must be provided.
1655
+ *
1656
+ * @param options - Search options.
1657
+ * @returns Paginated response containing matching places.
1658
+ * @throws ValidationError - If no search parameters are provided.
1659
+ *
1660
+ * @example
1661
+ * ```typescript
1662
+ * // Search by name
1663
+ * const places = await client.twitter.geo.search({ query: "San Francisco" });
1664
+ * for (const place of places.data) {
1665
+ * console.log(`${place.full_name} (${place.place_type})`);
1666
+ * }
1667
+ *
1668
+ * // Search by coordinates
1669
+ * const nearby = await client.twitter.geo.search({
1670
+ * lat: 37.7749,
1671
+ * long: -122.4194,
1672
+ * granularity: "city"
1673
+ * });
1674
+ *
1675
+ * // Search by IP
1676
+ * const ipPlaces = await client.twitter.geo.search({ ip: "8.8.8.8" });
1677
+ * ```
1678
+ */
1679
+ search(options?: GeoSearchOptions): Promise<PaginatedResponse<Place>>;
1680
+ }
1681
+
1682
+ /**
1683
+ * Twitter API client.
1684
+ *
1685
+ * Provides access to all Twitter API endpoints through specialized sub-clients.
1686
+ */
1687
+
1688
+ /**
1689
+ * Twitter API client with access to all Twitter endpoints.
1690
+ *
1691
+ * Provides sub-clients for different resource types:
1692
+ * - `tweets` - Tweet operations (get, search, replies, retweeters, etc.)
1693
+ * - `users` - User operations (profiles, followers, following, search, etc.)
1694
+ * - `lists` - List operations (details, members, tweets, search, etc.)
1695
+ * - `communities` - Community operations (details, members, tweets, search, etc.)
1696
+ * - `trends` - Trending topics and locations
1697
+ * - `geo` - Geographic place information
1698
+ *
1699
+ * @example
1700
+ * ```typescript
1701
+ * const client = new ScrapeBadger({ apiKey: "key" });
1702
+ *
1703
+ * // Access tweets
1704
+ * const tweet = await client.twitter.tweets.getById("1234567890");
1705
+ *
1706
+ * // Access users
1707
+ * const user = await client.twitter.users.getByUsername("elonmusk");
1708
+ *
1709
+ * // Access trends
1710
+ * const trends = await client.twitter.trends.getTrends();
1711
+ *
1712
+ * // Search with automatic pagination
1713
+ * for await (const tweet of client.twitter.tweets.searchAll("python")) {
1714
+ * console.log(tweet.text);
1715
+ * }
1716
+ * ```
1717
+ */
1718
+ declare class TwitterClient {
1719
+ /** Client for tweet operations */
1720
+ readonly tweets: TweetsClient;
1721
+ /** Client for user operations */
1722
+ readonly users: UsersClient;
1723
+ /** Client for list operations */
1724
+ readonly lists: ListsClient;
1725
+ /** Client for community operations */
1726
+ readonly communities: CommunitiesClient;
1727
+ /** Client for trends operations */
1728
+ readonly trends: TrendsClient;
1729
+ /** Client for geo/places operations */
1730
+ readonly geo: GeoClient;
1731
+ /**
1732
+ * Create a new Twitter client.
1733
+ *
1734
+ * @param client - The base HTTP client for making requests.
1735
+ */
1736
+ constructor(client: BaseClient);
1737
+ }
1738
+
1739
+ export { type ApiResponse as A, CommunitiesClient as C, GeoClient as G, type Hashtag as H, type IteratorOptions as I, ListsClient as L, type Media as M, type PaginatedResponse as P, type QueryType as Q, type ResolvedConfig as R, type ScrapeBadgerConfig as S, TwitterClient as T, UsersClient as U, type PaginationOptions as a, TweetsClient as b, collectAll as c, TrendsClient as d, type GeoSearchOptions as e, type TrendCategory as f, type CommunityTweetType as g, type PollOption as h, type Poll as i, type Url as j, type UserMention as k, type TweetPlace as l, type Tweet as m, type User as n, type UserAbout as o, type UserIds as p, type List as q, type CommunityBanner as r, type CommunityRule as s, type Community as t, type CommunityMember as u, type Trend as v, type Location as w, type PlaceTrends as x, type Place as y, type ListResponse as z };