scrapebadger 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/internal/exceptions.ts","../src/internal/client.ts","../src/internal/config.ts","../src/internal/pagination.ts","../src/twitter/tweets.ts","../src/twitter/users.ts","../src/twitter/lists.ts","../src/twitter/communities.ts","../src/twitter/trends.ts","../src/twitter/geo.ts","../src/twitter/stream.ts","../src/twitter/client.ts","../src/web/client.ts","../src/client.ts"],"names":[],"mappings":";;;;;AAOO,IAAM,iBAAA,GAAN,MAAM,kBAAA,SAA0B,KAAA,CAAM;AAAA,EAC3C,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,mBAAA;AACZ,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,kBAAA,CAAkB,SAAS,CAAA;AAAA,EACzD;AACF;AAKO,IAAM,mBAAA,GAAN,MAAM,oBAAA,SAA4B,iBAAA,CAAkB;AAAA,EACzD,WAAA,CAAY,UAAU,4CAAA,EAA8C;AAClE,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,qBAAA;AACZ,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,oBAAA,CAAoB,SAAS,CAAA;AAAA,EAC3D;AACF;AAKO,IAAM,cAAA,GAAN,MAAM,eAAA,SAAuB,iBAAA,CAAkB;AAAA;AAAA,EAE3C,UAAA;AAAA;AAAA,EAEA,KAAA;AAAA;AAAA,EAEA,SAAA;AAAA,EAET,WAAA,CACE,OAAA,GAAU,sBAAA,EACV,OAAA,EACA;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,gBAAA;AACZ,IAAA,IAAA,CAAK,aAAa,OAAA,EAAS,UAAA;AAC3B,IAAA,IAAA,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AAA;AAAA;AAAA;AAAA,EAKA,MAAM,YAAA,CACJ,GAAA,EACA,SAAA,EACA,OAAA,GAAyB,EAAC,EACH;AACvB,IAAA,OAAO,KAAK,MAAA,CAAO,GAAA,EAAK,EAAE,GAAG,OAAA,EAAS,WAAW,CAAA;AAAA,EACnD;AACF;;;ACjHO,IAAM,eAAN,MAAmB;AAAA,EACP,UAAA;AAAA;AAAA,EAGR,OAAA;AAAA;AAAA,EAGA,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA2BT,WAAA,CAAY,MAAA,GAAsC,EAAC,EAAG;AAEpD,IAAA,MAAM,MAAA,GAAS,MAAA,CAAO,MAAA,IAAU,gBAAA,EAAiB;AAEjD,IAAA,IAAI,CAAC,MAAA,EAAQ;AACX,MAAA,MAAM,IAAI,KAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AAEA,IAAA,MAAM,iBAAiB,aAAA,CAAc,EAAE,GAAG,MAAA,EAAQ,QAAQ,CAAA;AAC1D,IAAA,IAAA,CAAK,UAAA,GAAa,IAAI,UAAA,CAAW,cAAc,CAAA;AAG/C,IAAA,IAAA,CAAK,OAAA,GAAU,IAAI,aAAA,CAAc,IAAA,CAAK,UAAU,CAAA;AAChD,IAAA,IAAA,CAAK,GAAA,GAAM,IAAI,SAAA,CAAU,IAAA,CAAK,UAAU,CAAA;AAAA,EAC1C;AACF","file":"index.mjs","sourcesContent":["/**\n * Custom exceptions for the ScrapeBadger SDK.\n */\n\n/**\n * Base error class for all ScrapeBadger errors.\n */\nexport class ScrapeBadgerError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ScrapeBadgerError\";\n Object.setPrototypeOf(this, ScrapeBadgerError.prototype);\n }\n}\n\n/**\n * Raised when authentication fails (invalid or missing API key).\n */\nexport class AuthenticationError extends ScrapeBadgerError {\n constructor(message = \"Authentication failed. Check your API key.\") {\n super(message);\n this.name = \"AuthenticationError\";\n Object.setPrototypeOf(this, AuthenticationError.prototype);\n }\n}\n\n/**\n * Raised when rate limit is exceeded.\n */\nexport class RateLimitError extends ScrapeBadgerError {\n /** Unix timestamp when the rate limit resets */\n readonly retryAfter: number | undefined;\n /** Maximum requests per minute for this tier */\n readonly limit: number | undefined;\n /** Remaining requests in the current window */\n readonly remaining: number | undefined;\n\n constructor(\n message = \"Rate limit exceeded.\",\n options?: { retryAfter?: number; limit?: number; remaining?: number }\n ) {\n super(message);\n this.name = \"RateLimitError\";\n this.retryAfter = options?.retryAfter;\n this.limit = options?.limit;\n this.remaining = options?.remaining;\n Object.setPrototypeOf(this, RateLimitError.prototype);\n }\n}\n\n/**\n * Raised when the requested resource is not found.\n */\nexport class NotFoundError extends ScrapeBadgerError {\n /** The resource type that was not found */\n readonly resourceType: string | undefined;\n /** The resource ID that was not found */\n readonly resourceId: string | undefined;\n\n constructor(message = \"Resource not found.\", resourceType?: string, resourceId?: string) {\n super(message);\n this.name = \"NotFoundError\";\n this.resourceType = resourceType;\n this.resourceId = resourceId;\n Object.setPrototypeOf(this, NotFoundError.prototype);\n }\n}\n\n/**\n * Raised when the request is invalid.\n */\nexport class ValidationError extends ScrapeBadgerError {\n /** Validation errors by field */\n readonly errors: Record<string, string[]> | undefined;\n\n constructor(message = \"Validation error.\", errors?: Record<string, string[]>) {\n super(message);\n this.name = \"ValidationError\";\n this.errors = errors;\n Object.setPrototypeOf(this, ValidationError.prototype);\n }\n}\n\n/**\n * Raised when an internal server error occurs.\n */\nexport class ServerError extends ScrapeBadgerError {\n /** HTTP status code */\n readonly statusCode: number;\n\n constructor(message = \"Internal server error.\", statusCode = 500) {\n super(message);\n this.name = \"ServerError\";\n this.statusCode = statusCode;\n Object.setPrototypeOf(this, ServerError.prototype);\n }\n}\n\n/**\n * Raised when the request times out.\n */\nexport class TimeoutError extends ScrapeBadgerError {\n /** Timeout duration in milliseconds */\n readonly timeout: number;\n\n constructor(message = \"Request timed out.\", timeout: number) {\n super(message);\n this.name = \"TimeoutError\";\n this.timeout = timeout;\n Object.setPrototypeOf(this, TimeoutError.prototype);\n }\n}\n\n/**\n * Raised when the account has insufficient credits.\n */\nexport class InsufficientCreditsError extends ScrapeBadgerError {\n /** Current credit balance */\n readonly creditsBalance: number | undefined;\n\n constructor(message = \"Insufficient credits.\", creditsBalance?: number) {\n super(message);\n this.name = \"InsufficientCreditsError\";\n this.creditsBalance = creditsBalance;\n Object.setPrototypeOf(this, InsufficientCreditsError.prototype);\n }\n}\n\n/**\n * Raised when the account is restricted.\n */\nexport class AccountRestrictedError extends ScrapeBadgerError {\n /** Reason for the restriction */\n readonly reason: string | undefined;\n\n constructor(message = \"Account restricted.\", reason?: string) {\n super(message);\n this.name = \"AccountRestrictedError\";\n this.reason = reason;\n Object.setPrototypeOf(this, AccountRestrictedError.prototype);\n }\n}\n\n/**\n * Raised when a resource conflict occurs (e.g. duplicate monitor name).\n *\n * Maps to HTTP 409 Conflict.\n *\n * @example\n * ```typescript\n * import { ConflictError } from \"scrapebadger\";\n *\n * try {\n * await client.twitter.stream.createMonitor({\n * name: \"Existing Monitor\",\n * usernames: [\"elonmusk\"],\n * pollIntervalSeconds: 10,\n * });\n * } catch (err) {\n * if (err instanceof ConflictError) {\n * console.error(\"Monitor name already exists:\", err.message);\n * }\n * }\n * ```\n */\nexport class ConflictError extends ScrapeBadgerError {\n constructor(message = \"Resource conflict.\") {\n super(message);\n this.name = \"ConflictError\";\n Object.setPrototypeOf(this, ConflictError.prototype);\n }\n}\n\n/**\n * Raised when the WebSocket stream connection fails or is terminated.\n *\n * Common codes:\n * - 4001 -- Invalid or missing API key (auth failure)\n * - 4003 -- Connection limit exceeded (max 5 per API key)\n * - 1001 -- Server closed due to pong timeout\n * - 0 -- Unknown/parse error\n *\n * @example\n * ```typescript\n * import { WebSocketStreamError } from \"scrapebadger\";\n *\n * try {\n * for await (const event of client.twitter.stream.connectIter()) {\n * // ...\n * }\n * } catch (err) {\n * if (err instanceof WebSocketStreamError && err.code === 4001) {\n * console.error(\"API key rejected -- check your key\");\n * }\n * }\n * ```\n */\nexport class WebSocketStreamError extends ScrapeBadgerError {\n /** WebSocket close code or server error code */\n readonly code: number | undefined;\n\n constructor(message = \"WebSocket stream error\", code?: number) {\n super(message);\n this.name = \"WebSocketStreamError\";\n this.code = code;\n Object.setPrototypeOf(this, WebSocketStreamError.prototype);\n }\n}\n","/**\n * Base HTTP client with retry logic and error handling.\n */\n\nimport type { ResolvedConfig } from \"./config.js\";\nimport {\n AuthenticationError,\n RateLimitError,\n NotFoundError,\n ValidationError,\n ServerError,\n TimeoutError,\n InsufficientCreditsError,\n AccountRestrictedError,\n ConflictError,\n ScrapeBadgerError,\n} from \"./exceptions.js\";\n\nexport interface RequestOptions {\n method?: \"GET\" | \"POST\" | \"PUT\" | \"DELETE\" | \"PATCH\";\n params?: Record<string, string | number | boolean | undefined>;\n body?: unknown;\n headers?: Record<string, string>;\n}\n\ninterface ErrorResponse {\n detail?: string;\n message?: string;\n errors?: Record<string, string[]>;\n limit?: number;\n remaining?: number;\n reset_at?: number;\n reason?: string;\n credits_balance?: number;\n}\n\n/**\n * Base HTTP client for making API requests.\n */\nexport class BaseClient {\n readonly config: ResolvedConfig;\n\n constructor(config: ResolvedConfig) {\n this.config = config;\n }\n\n /**\n * Make an HTTP request to the API.\n */\n async request<T>(path: string, options: RequestOptions = {}): Promise<T> {\n const { method = \"GET\", params, body, headers = {} } = options;\n\n // Build URL with query parameters\n const url = new URL(path, this.config.baseUrl);\n if (params) {\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined) {\n url.searchParams.set(key, String(value));\n }\n }\n }\n\n // Build headers\n const requestHeaders: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n \"X-API-Key\": this.config.apiKey,\n \"User-Agent\": \"scrapebadger-node/0.1.0\",\n ...headers,\n };\n\n // Build request options\n const fetchOptions: RequestInit = {\n method,\n headers: requestHeaders,\n };\n\n if (body && method !== \"GET\") {\n fetchOptions.body = JSON.stringify(body);\n }\n\n // Execute with retry logic\n return this.executeWithRetry<T>(url.toString(), fetchOptions);\n }\n\n /**\n * Execute request with exponential backoff retry logic.\n */\n private async executeWithRetry<T>(url: string, options: RequestInit): Promise<T> {\n let lastError: Error | undefined;\n\n for (let attempt = 0; attempt <= this.config.maxRetries; attempt++) {\n try {\n const response = await this.fetchWithTimeout(url, options);\n return await this.handleResponse<T>(response);\n } catch (error) {\n lastError = error as Error;\n\n // Don't retry on client errors (4xx) except rate limits\n if (error instanceof ScrapeBadgerError && !(error instanceof RateLimitError)) {\n throw error;\n }\n\n // Don't retry after exhausting attempts\n if (attempt === this.config.maxRetries) {\n break;\n }\n\n // Calculate delay with exponential backoff\n const delay = this.config.retryDelay * Math.pow(2, attempt);\n\n // For rate limits, use retry-after if available\n if (error instanceof RateLimitError && error.retryAfter) {\n const retryDelay = (error.retryAfter - Date.now() / 1000) * 1000;\n if (retryDelay > 0 && retryDelay < 60000) {\n await this.sleep(retryDelay);\n continue;\n }\n }\n\n await this.sleep(delay);\n }\n }\n\n throw lastError ?? new ScrapeBadgerError(\"Request failed after retries\");\n }\n\n /**\n * Fetch with timeout support.\n */\n private async fetchWithTimeout(url: string, options: RequestInit): Promise<Response> {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);\n\n try {\n const response = await fetch(url, {\n ...options,\n signal: controller.signal,\n });\n return response;\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") {\n throw new TimeoutError(\n `Request timed out after ${this.config.timeout}ms`,\n this.config.timeout\n );\n }\n throw error;\n } finally {\n clearTimeout(timeoutId);\n }\n }\n\n /**\n * Handle HTTP response and convert errors.\n */\n private async handleResponse<T>(response: Response): Promise<T> {\n // Parse response body\n let data: T | ErrorResponse;\n const contentType = response.headers.get(\"content-type\");\n\n if (contentType?.includes(\"application/json\")) {\n data = (await response.json()) as T | ErrorResponse;\n } else {\n const text = await response.text();\n data = { detail: text } as ErrorResponse;\n }\n\n // Handle success\n if (response.ok) {\n return data as T;\n }\n\n // Handle errors\n const errorData = data as ErrorResponse;\n const message = errorData.detail ?? errorData.message ?? \"Request failed\";\n\n switch (response.status) {\n case 401:\n throw new AuthenticationError(message);\n\n case 402:\n throw new InsufficientCreditsError(message, errorData.credits_balance);\n\n case 403:\n if (message.toLowerCase().includes(\"restricted\")) {\n throw new AccountRestrictedError(message, errorData.reason);\n }\n throw new AuthenticationError(message);\n\n case 404:\n throw new NotFoundError(message);\n\n case 409:\n throw new ConflictError(message);\n\n case 422:\n throw new ValidationError(message, errorData.errors);\n\n case 429:\n throw new RateLimitError(message, {\n retryAfter: errorData.reset_at,\n limit: errorData.limit,\n remaining: errorData.remaining,\n });\n\n default:\n if (response.status >= 500) {\n throw new ServerError(message, response.status);\n }\n throw new ScrapeBadgerError(message);\n }\n }\n\n /**\n * Sleep for a given duration.\n */\n private sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n}\n","/**\n * Configuration management for the ScrapeBadger SDK.\n */\n\nexport interface ScrapeBadgerConfig {\n /** API key for authentication */\n apiKey: string;\n /** Base URL for the API (default: https://scrapebadger.com) */\n baseUrl?: string;\n /** Request timeout in milliseconds (default: 30000) */\n timeout?: number;\n /** Maximum number of retry attempts (default: 3) */\n maxRetries?: number;\n /** Initial retry delay in milliseconds (default: 1000) */\n retryDelay?: number;\n}\n\nexport interface ResolvedConfig {\n apiKey: string;\n baseUrl: string;\n timeout: number;\n maxRetries: number;\n retryDelay: number;\n}\n\nconst DEFAULT_BASE_URL = \"https://scrapebadger.com\";\nconst DEFAULT_TIMEOUT = 30000;\nconst DEFAULT_MAX_RETRIES = 3;\nconst DEFAULT_RETRY_DELAY = 1000;\n\n/**\n * Resolve configuration with defaults.\n */\nexport function resolveConfig(config: ScrapeBadgerConfig): ResolvedConfig {\n if (!config.apiKey) {\n throw new Error(\"API key is required\");\n }\n\n return {\n apiKey: config.apiKey,\n baseUrl: config.baseUrl ?? DEFAULT_BASE_URL,\n timeout: config.timeout ?? DEFAULT_TIMEOUT,\n maxRetries: config.maxRetries ?? DEFAULT_MAX_RETRIES,\n retryDelay: config.retryDelay ?? DEFAULT_RETRY_DELAY,\n };\n}\n\n/**\n * Load API key from environment variable.\n */\nexport function getApiKeyFromEnv(): string | undefined {\n if (typeof process !== \"undefined\" && process.env) {\n return process.env.SCRAPEBADGER_API_KEY;\n }\n return undefined;\n}\n","/**\n * Pagination utilities for the ScrapeBadger SDK.\n */\n\n/**\n * Response wrapper for paginated API responses.\n */\nexport interface PaginatedResponse<T> {\n /** Array of items in the current page */\n data: T[];\n /** Cursor for the next page, if available */\n nextCursor?: string;\n /** Whether there are more pages available */\n hasMore: boolean;\n}\n\n/**\n * Options for paginated requests.\n */\nexport interface PaginationOptions {\n /** Maximum number of items to fetch per request (default: 20) */\n count?: number;\n /** Cursor for pagination */\n cursor?: string;\n}\n\n/**\n * Options for async iteration.\n */\nexport interface IteratorOptions extends PaginationOptions {\n /** Maximum total number of items to fetch (default: unlimited) */\n maxItems?: number;\n}\n\n/**\n * Create a paginated response from API response data.\n */\nexport function createPaginatedResponse<T>(\n data: T[],\n cursor?: string\n): PaginatedResponse<T> {\n return {\n data,\n nextCursor: cursor,\n hasMore: !!cursor,\n };\n}\n\n/**\n * Async generator for paginating through API results.\n *\n * @param fetchPage - Function to fetch a single page\n * @param options - Pagination options\n * @yields Individual items from each page\n *\n * @example\n * ```typescript\n * // Iterate through all results\n * for await (const tweet of client.twitter.tweets.searchAll(\"query\")) {\n * console.log(tweet.text);\n * }\n *\n * // With max items limit\n * for await (const tweet of client.twitter.tweets.searchAll(\"query\", { maxItems: 100 })) {\n * console.log(tweet.text);\n * }\n * ```\n */\nexport async function* paginate<T>(\n fetchPage: (cursor?: string) => Promise<PaginatedResponse<T>>,\n options: IteratorOptions = {}\n): AsyncGenerator<T, void, undefined> {\n const { maxItems } = options;\n let cursor: string | undefined;\n let totalYielded = 0;\n\n do {\n const response = await fetchPage(cursor);\n\n for (const item of response.data) {\n yield item;\n totalYielded++;\n\n if (maxItems !== undefined && totalYielded >= maxItems) {\n return;\n }\n }\n\n cursor = response.nextCursor;\n } while (cursor);\n}\n\n/**\n * Collect all items from an async generator into an array.\n *\n * @param generator - Async generator to collect from\n * @returns Array of all yielded items\n *\n * @example\n * ```typescript\n * const tweets = await collectAll(client.twitter.tweets.searchAll(\"query\", { maxItems: 100 }));\n * console.log(`Fetched ${tweets.length} tweets`);\n * ```\n */\nexport async function collectAll<T>(generator: AsyncGenerator<T, void, undefined>): Promise<T[]> {\n const items: T[] = [];\n for await (const item of generator) {\n items.push(item);\n }\n return items;\n}\n","/**\n * Twitter Tweets API client.\n *\n * Provides methods for fetching tweets, searching, and getting tweet metadata.\n */\n\nimport type { BaseClient } from \"../internal/client.js\";\nimport type {\n PaginatedResponse,\n PaginationOptions,\n IteratorOptions,\n} from \"../internal/pagination.js\";\nimport { createPaginatedResponse, paginate } from \"../internal/pagination.js\";\nimport type { Tweet, User, QueryType } from \"./types.js\";\n\n/**\n * Client for Twitter tweets endpoints.\n *\n * Provides async methods for fetching individual tweets, searching tweets,\n * and getting tweet engagement data (retweeters, favoriters, replies).\n *\n * @example\n * ```typescript\n * const client = new ScrapeBadger({ apiKey: \"key\" });\n *\n * // Get single tweet\n * const tweet = await client.twitter.tweets.getById(\"1234567890\");\n *\n * // Search tweets\n * const results = await client.twitter.tweets.search(\"python programming\");\n * for (const tweet of results.data) {\n * console.log(tweet.text);\n * }\n *\n * // Iterate through all results\n * for await (const tweet of client.twitter.tweets.searchAll(\"python\")) {\n * console.log(tweet.text);\n * }\n * ```\n */\nexport class TweetsClient {\n private readonly client: BaseClient;\n\n constructor(client: BaseClient) {\n this.client = client;\n }\n\n /**\n * Get a single tweet by ID.\n *\n * @param tweetId - The tweet ID to fetch.\n * @returns The tweet data.\n * @throws NotFoundError - If the tweet doesn't exist.\n * @throws AuthenticationError - If the API key is invalid.\n *\n * @example\n * ```typescript\n * const tweet = await client.twitter.tweets.getById(\"1234567890\");\n * console.log(`@${tweet.username}: ${tweet.text}`);\n * ```\n */\n async getById(tweetId: string): Promise<Tweet> {\n return this.client.request<Tweet>(`/v1/twitter/tweets/tweet/${tweetId}`);\n }\n\n /**\n * Get multiple tweets by their IDs.\n *\n * @param tweetIds - List of tweet IDs to fetch.\n * @returns Paginated response containing the tweets.\n *\n * @example\n * ```typescript\n * const tweets = await client.twitter.tweets.getByIds([\n * \"1234567890\",\n * \"0987654321\"\n * ]);\n * for (const tweet of tweets.data) {\n * console.log(tweet.text);\n * }\n * ```\n */\n async getByIds(tweetIds: string[]): Promise<PaginatedResponse<Tweet>> {\n const tweetsParam = tweetIds.join(\",\");\n const response = await this.client.request<{ data?: Tweet[]; next_cursor?: string }>(\n \"/v1/twitter/tweets/\",\n { params: { tweets: tweetsParam } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Get replies to a tweet.\n *\n * @param tweetId - The tweet ID to get replies for.\n * @param options - Pagination options.\n * @returns Paginated response containing reply tweets.\n *\n * @example\n * ```typescript\n * const replies = await client.twitter.tweets.getReplies(\"1234567890\");\n * for (const reply of replies.data) {\n * console.log(`@${reply.username}: ${reply.text}`);\n * }\n *\n * // Get next page\n * if (replies.hasMore) {\n * const more = await client.twitter.tweets.getReplies(\"1234567890\", {\n * cursor: replies.nextCursor\n * });\n * }\n * ```\n */\n async getReplies(\n tweetId: string,\n options: PaginationOptions = {}\n ): Promise<PaginatedResponse<Tweet>> {\n const response = await this.client.request<{ data?: Tweet[]; next_cursor?: string }>(\n `/v1/twitter/tweets/tweet/${tweetId}/replies`,\n { params: { cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Get users who retweeted a tweet.\n *\n * @param tweetId - The tweet ID to get retweeters for.\n * @param options - Pagination options.\n * @returns Paginated response containing users who retweeted.\n *\n * @example\n * ```typescript\n * const retweeters = await client.twitter.tweets.getRetweeters(\"1234567890\");\n * for (const user of retweeters.data) {\n * console.log(`@${user.username} retweeted`);\n * }\n * ```\n */\n async getRetweeters(\n tweetId: string,\n options: PaginationOptions = {}\n ): Promise<PaginatedResponse<User>> {\n const response = await this.client.request<{ data?: User[]; next_cursor?: string }>(\n `/v1/twitter/tweets/tweet/${tweetId}/retweeters`,\n { params: { cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Get users who liked/favorited a tweet.\n *\n * @param tweetId - The tweet ID to get favoriters for.\n * @param options - Pagination options with optional count.\n * @returns Paginated response containing users who liked.\n *\n * @example\n * ```typescript\n * const likers = await client.twitter.tweets.getFavoriters(\"1234567890\");\n * console.log(`${likers.data.length} users liked this tweet`);\n * ```\n */\n async getFavoriters(\n tweetId: string,\n options: PaginationOptions & { count?: number } = {}\n ): Promise<PaginatedResponse<User>> {\n const response = await this.client.request<{ data?: User[]; next_cursor?: string }>(\n `/v1/twitter/tweets/tweet/${tweetId}/favoriters`,\n { params: { count: options.count ?? 40, cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Get tweets similar to a given tweet.\n *\n * @param tweetId - The tweet ID to find similar tweets for.\n * @returns Paginated response containing similar tweets.\n *\n * @example\n * ```typescript\n * const similar = await client.twitter.tweets.getSimilar(\"1234567890\");\n * for (const tweet of similar.data) {\n * console.log(`Similar: ${tweet.text.slice(0, 100)}...`);\n * }\n * ```\n */\n async getSimilar(tweetId: string): Promise<PaginatedResponse<Tweet>> {\n const response = await this.client.request<{ data?: Tweet[]; next_cursor?: string }>(\n `/v1/twitter/tweets/tweet/${tweetId}/similar`\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Get tweets that quote a specific tweet.\n *\n * @param tweetId - The tweet ID to get quote tweets for.\n * @param options - Pagination options.\n * @returns Paginated response containing tweets that quote this tweet.\n *\n * @example\n * ```typescript\n * const quotes = await client.twitter.tweets.getQuotes(\"1234567890\");\n * for (const quote of quotes.data) {\n * console.log(`@${quote.username} quoted: ${quote.text.slice(0, 100)}...`);\n * }\n *\n * // Get next page\n * if (quotes.hasMore) {\n * const more = await client.twitter.tweets.getQuotes(\"1234567890\", {\n * cursor: quotes.nextCursor\n * });\n * }\n * ```\n */\n async getQuotes(\n tweetId: string,\n options: PaginationOptions = {}\n ): Promise<PaginatedResponse<Tweet>> {\n const response = await this.client.request<{ data?: Tweet[]; next_cursor?: string }>(\n `/v1/twitter/tweets/tweet/${tweetId}/quotes`,\n { params: { cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Iterate through all quote tweets with automatic pagination.\n *\n * This is a convenience method that automatically handles pagination,\n * yielding quote tweets one at a time.\n *\n * @param tweetId - The tweet ID to get quote tweets for.\n * @param options - Iteration options.\n * @yields Tweet objects that quote the specified tweet.\n *\n * @example\n * ```typescript\n * // Get all quote tweets (up to 500)\n * for await (const quote of client.twitter.tweets.getQuotesAll(\"1234567890\", {\n * maxItems: 500\n * })) {\n * console.log(`@${quote.username}: ${quote.text}`);\n * }\n *\n * // Collect into an array\n * import { collectAll } from \"scrapebadger\";\n * const quotes = await collectAll(\n * client.twitter.tweets.getQuotesAll(\"1234567890\", { maxItems: 100 })\n * );\n * ```\n */\n async *getQuotesAll(\n tweetId: string,\n options: IteratorOptions = {}\n ): AsyncGenerator<Tweet, void, undefined> {\n const fetchPage = async (cursor?: string) => {\n return this.getQuotes(tweetId, { ...options, cursor });\n };\n yield* paginate(fetchPage, options);\n }\n\n /**\n * Search for tweets.\n *\n * @param query - Search query string. Supports Twitter advanced search operators.\n * @param options - Search options including query type and pagination.\n * @returns Paginated response containing matching tweets.\n *\n * @example\n * ```typescript\n * // Basic search\n * const results = await client.twitter.tweets.search(\"python programming\");\n *\n * // Latest tweets only\n * const latest = await client.twitter.tweets.search(\"python\", {\n * queryType: \"Latest\"\n * });\n *\n * // Advanced search operators\n * const fromUser = await client.twitter.tweets.search(\"from:elonmusk lang:en\");\n * ```\n */\n async search(\n query: string,\n options: PaginationOptions & { queryType?: QueryType; count?: number } = {}\n ): Promise<PaginatedResponse<Tweet>> {\n const response = await this.client.request<{ data?: Tweet[]; next_cursor?: string }>(\n \"/v1/twitter/tweets/advanced_search\",\n {\n params: {\n query,\n query_type: options.queryType ?? \"Top\",\n count: options.count,\n cursor: options.cursor,\n },\n }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Iterate through all search results with automatic pagination.\n *\n * This is a convenience method that automatically handles pagination,\n * yielding tweets one at a time.\n *\n * @param query - Search query string.\n * @param options - Search and iteration options.\n * @yields Tweet objects matching the search query.\n *\n * @example\n * ```typescript\n * // Get up to 1000 tweets\n * for await (const tweet of client.twitter.tweets.searchAll(\"python\", {\n * maxItems: 1000\n * })) {\n * console.log(tweet.text);\n * }\n *\n * // Collect into an array\n * import { collectAll } from \"scrapebadger\";\n * const tweets = await collectAll(\n * client.twitter.tweets.searchAll(\"python\", { maxItems: 100 })\n * );\n * ```\n */\n async *searchAll(\n query: string,\n options: IteratorOptions & { queryType?: QueryType; count?: number } = {}\n ): AsyncGenerator<Tweet, void, undefined> {\n const fetchPage = async (cursor?: string) => {\n return this.search(query, { ...options, cursor });\n };\n yield* paginate(fetchPage, options);\n }\n\n /**\n * Get tweets from a user's timeline.\n *\n * @param username - Twitter username (without @).\n * @param options - Pagination options.\n * @returns Paginated response containing the user's tweets.\n *\n * @example\n * ```typescript\n * const tweets = await client.twitter.tweets.getUserTweets(\"elonmusk\");\n * for (const tweet of tweets.data) {\n * console.log(`${tweet.created_at}: ${tweet.text.slice(0, 100)}...`);\n * }\n * ```\n */\n async getUserTweets(\n username: string,\n options: PaginationOptions = {}\n ): Promise<PaginatedResponse<Tweet>> {\n const response = await this.client.request<{ data?: Tweet[]; next_cursor?: string }>(\n `/v1/twitter/users/${username}/latest_tweets`,\n { params: { cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Iterate through all tweets from a user with automatic pagination.\n *\n * @param username - Twitter username (without @).\n * @param options - Iteration options.\n * @yields Tweet objects from the user's timeline.\n *\n * @example\n * ```typescript\n * for await (const tweet of client.twitter.tweets.getUserTweetsAll(\"elonmusk\", {\n * maxItems: 500\n * })) {\n * console.log(tweet.text);\n * }\n * ```\n */\n async *getUserTweetsAll(\n username: string,\n options: IteratorOptions = {}\n ): AsyncGenerator<Tweet, void, undefined> {\n const fetchPage = async (cursor?: string) => {\n return this.getUserTweets(username, { ...options, cursor });\n };\n yield* paginate(fetchPage, options);\n }\n}\n","/**\n * Twitter Users API client.\n *\n * Provides methods for fetching user profiles, followers, following, and related data.\n */\n\nimport type { BaseClient } from \"../internal/client.js\";\nimport type {\n PaginatedResponse,\n PaginationOptions,\n IteratorOptions,\n} from \"../internal/pagination.js\";\nimport { createPaginatedResponse, paginate } from \"../internal/pagination.js\";\nimport type { User, UserAbout, UserIds, Tweet } from \"./types.js\";\n\n/**\n * Client for Twitter users endpoints.\n *\n * Provides async methods for fetching user profiles, followers, following,\n * and other user-related data.\n *\n * @example\n * ```typescript\n * const client = new ScrapeBadger({ apiKey: \"key\" });\n *\n * // Get user profile\n * const user = await client.twitter.users.getByUsername(\"elonmusk\");\n * console.log(`${user.name}: ${user.followers_count.toLocaleString()} followers`);\n *\n * // Get followers\n * const followers = await client.twitter.users.getFollowers(\"elonmusk\");\n *\n * // Iterate through all followers\n * for await (const follower of client.twitter.users.getFollowersAll(\"elonmusk\")) {\n * console.log(follower.username);\n * }\n * ```\n */\nexport class UsersClient {\n private readonly client: BaseClient;\n\n constructor(client: BaseClient) {\n this.client = client;\n }\n\n /**\n * Get a user by their numeric ID.\n *\n * @param userId - The user's numeric ID.\n * @returns The user profile.\n * @throws NotFoundError - If the user doesn't exist.\n *\n * @example\n * ```typescript\n * const user = await client.twitter.users.getById(\"44196397\");\n * console.log(`@${user.username}`);\n * ```\n */\n async getById(userId: string): Promise<User> {\n return this.client.request<User>(`/v1/twitter/users/${userId}/by_id`);\n }\n\n /**\n * Get a user by their username.\n *\n * @param username - The user's username (without @).\n * @returns The user profile.\n * @throws NotFoundError - If the user doesn't exist.\n *\n * @example\n * ```typescript\n * const user = await client.twitter.users.getByUsername(\"elonmusk\");\n * console.log(`${user.name} has ${user.followers_count.toLocaleString()} followers`);\n * ```\n */\n async getByUsername(username: string): Promise<User> {\n return this.client.request<User>(`/v1/twitter/users/${username}/by_username`);\n }\n\n /**\n * Get extended \"About\" information for a user.\n *\n * Returns additional metadata including account location,\n * username change history, and verification details.\n *\n * @param username - The user's username (without @).\n * @returns Extended user information.\n *\n * @example\n * ```typescript\n * const about = await client.twitter.users.getAbout(\"elonmusk\");\n * console.log(`Account based in: ${about.account_based_in}`);\n * console.log(`Username changes: ${about.username_changes}`);\n * ```\n */\n async getAbout(username: string): Promise<UserAbout> {\n return this.client.request<UserAbout>(`/v1/twitter/users/${username}/about`);\n }\n\n /**\n * Get a user's followers.\n *\n * @param username - The user's username (without @).\n * @param options - Pagination options.\n * @returns Paginated response containing follower users.\n *\n * @example\n * ```typescript\n * const followers = await client.twitter.users.getFollowers(\"elonmusk\");\n * for (const user of followers.data) {\n * console.log(`@${user.username}`);\n * }\n *\n * // Get next page\n * if (followers.hasMore) {\n * const more = await client.twitter.users.getFollowers(\"elonmusk\", {\n * cursor: followers.nextCursor\n * });\n * }\n * ```\n */\n async getFollowers(\n username: string,\n options: PaginationOptions = {}\n ): Promise<PaginatedResponse<User>> {\n const response = await this.client.request<{ data?: User[]; next_cursor?: string }>(\n `/v1/twitter/users/${username}/followers`,\n { params: { cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Iterate through all followers with automatic pagination.\n *\n * @param username - The user's username (without @).\n * @param options - Iteration options.\n * @yields User objects for each follower.\n *\n * @example\n * ```typescript\n * for await (const follower of client.twitter.users.getFollowersAll(\"elonmusk\", {\n * maxItems: 1000\n * })) {\n * console.log(follower.username);\n * }\n * ```\n */\n async *getFollowersAll(\n username: string,\n options: IteratorOptions = {}\n ): AsyncGenerator<User, void, undefined> {\n const fetchPage = async (cursor?: string) => {\n return this.getFollowers(username, { ...options, cursor });\n };\n yield* paginate(fetchPage, options);\n }\n\n /**\n * Get users that a user is following.\n *\n * @param username - The user's username (without @).\n * @param options - Pagination options.\n * @returns Paginated response containing followed users.\n *\n * @example\n * ```typescript\n * const following = await client.twitter.users.getFollowing(\"elonmusk\");\n * for (const user of following.data) {\n * console.log(`Follows @${user.username}`);\n * }\n * ```\n */\n async getFollowing(\n username: string,\n options: PaginationOptions = {}\n ): Promise<PaginatedResponse<User>> {\n const response = await this.client.request<{ data?: User[]; next_cursor?: string }>(\n `/v1/twitter/users/${username}/followings`,\n { params: { cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Iterate through all following with automatic pagination.\n *\n * @param username - The user's username (without @).\n * @param options - Iteration options.\n * @yields User objects for each followed account.\n */\n async *getFollowingAll(\n username: string,\n options: IteratorOptions = {}\n ): AsyncGenerator<User, void, undefined> {\n const fetchPage = async (cursor?: string) => {\n return this.getFollowing(username, { ...options, cursor });\n };\n yield* paginate(fetchPage, options);\n }\n\n /**\n * Get a user's most recent followers.\n *\n * @param username - The user's username (without @).\n * @param options - Pagination options with optional count.\n * @returns Paginated response containing recent followers.\n */\n async getLatestFollowers(\n username: string,\n options: PaginationOptions & { count?: number } = {}\n ): Promise<PaginatedResponse<User>> {\n const response = await this.client.request<{ data?: User[]; next_cursor?: string }>(\n `/v1/twitter/users/${username}/latest_followers`,\n { params: { count: options.count ?? 200, cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Get accounts a user most recently followed.\n *\n * @param username - The user's username (without @).\n * @param options - Pagination options with optional count.\n * @returns Paginated response containing recently followed users.\n */\n async getLatestFollowing(\n username: string,\n options: PaginationOptions & { count?: number } = {}\n ): Promise<PaginatedResponse<User>> {\n const response = await this.client.request<{ data?: User[]; next_cursor?: string }>(\n `/v1/twitter/users/${username}/latest_following`,\n { params: { count: options.count ?? 200, cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Get follower IDs for a user.\n *\n * More efficient than getFollowers when you only need IDs.\n *\n * @param username - The user's username (without @).\n * @param options - Pagination options with optional count.\n * @returns UserIds containing list of follower IDs.\n *\n * @example\n * ```typescript\n * const ids = await client.twitter.users.getFollowerIds(\"elonmusk\");\n * console.log(`Found ${ids.ids.length.toLocaleString()} follower IDs`);\n * ```\n */\n async getFollowerIds(\n username: string,\n options: PaginationOptions & { count?: number } = {}\n ): Promise<UserIds> {\n const response = await this.client.request<{ data?: { ids?: number[]; next_cursor?: string } }>(\n `/v1/twitter/users/${username}/follower_ids`,\n { params: { count: options.count ?? 5000, cursor: options.cursor } }\n );\n return {\n ids: response.data?.ids ?? [],\n next_cursor: response.data?.next_cursor,\n };\n }\n\n /**\n * Get following IDs for a user.\n *\n * More efficient than getFollowing when you only need IDs.\n *\n * @param username - The user's username (without @).\n * @param options - Pagination options with optional count.\n * @returns UserIds containing list of following IDs.\n */\n async getFollowingIds(\n username: string,\n options: PaginationOptions & { count?: number } = {}\n ): Promise<UserIds> {\n const response = await this.client.request<{ data?: { ids?: number[]; next_cursor?: string } }>(\n `/v1/twitter/users/${username}/following_ids`,\n { params: { count: options.count ?? 5000, cursor: options.cursor } }\n );\n return {\n ids: response.data?.ids ?? [],\n next_cursor: response.data?.next_cursor,\n };\n }\n\n /**\n * Get verified followers for a user.\n *\n * @param userId - The user's numeric ID.\n * @param options - Pagination options with optional count.\n * @returns Paginated response containing verified followers.\n */\n async getVerifiedFollowers(\n userId: string,\n options: PaginationOptions & { count?: number } = {}\n ): Promise<PaginatedResponse<User>> {\n const response = await this.client.request<{ data?: User[]; next_cursor?: string }>(\n `/v1/twitter/users/${userId}/verified_followers`,\n { params: { count: options.count ?? 20, cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Get followers that the authenticated user also follows.\n *\n * @param userId - The user's numeric ID.\n * @param options - Pagination options with optional count.\n * @returns Paginated response containing mutual connections.\n */\n async getFollowersYouKnow(\n userId: string,\n options: PaginationOptions & { count?: number } = {}\n ): Promise<PaginatedResponse<User>> {\n const response = await this.client.request<{ data?: User[]; next_cursor?: string }>(\n `/v1/twitter/users/${userId}/followers_you_know`,\n { params: { count: options.count ?? 20, cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Get premium accounts that a user subscribes to.\n *\n * @param userId - The user's numeric ID.\n * @param options - Pagination options with optional count.\n * @returns Paginated response containing subscribed accounts.\n */\n async getSubscriptions(\n userId: string,\n options: PaginationOptions & { count?: number } = {}\n ): Promise<PaginatedResponse<User>> {\n const response = await this.client.request<{ data?: User[]; next_cursor?: string }>(\n `/v1/twitter/users/${userId}/subscriptions`,\n { params: { count: options.count ?? 20, cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Get a user's highlighted tweets.\n *\n * @param userId - The user's numeric ID.\n * @param options - Pagination options with optional count.\n * @returns Paginated response containing highlighted tweets.\n */\n async getHighlights(\n userId: string,\n options: PaginationOptions & { count?: number } = {}\n ): Promise<PaginatedResponse<Tweet>> {\n const response = await this.client.request<{ data?: Tweet[]; next_cursor?: string }>(\n `/v1/twitter/users/${userId}/highlights`,\n { params: { count: options.count ?? 20, cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Search for users.\n *\n * @param query - Search query string.\n * @param options - Pagination options.\n * @returns Paginated response containing matching users.\n *\n * @example\n * ```typescript\n * const results = await client.twitter.users.search(\"python developer\");\n * for (const user of results.data) {\n * console.log(`@${user.username}: ${user.description}`);\n * }\n * ```\n */\n async search(\n query: string,\n options: PaginationOptions = {}\n ): Promise<PaginatedResponse<User>> {\n const response = await this.client.request<{ data?: User[]; next_cursor?: string }>(\n \"/v1/twitter/users/search_users\",\n { params: { query, cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Iterate through all search results with automatic pagination.\n *\n * @param query - Search query string.\n * @param options - Iteration options.\n * @yields User objects matching the search query.\n */\n async *searchAll(\n query: string,\n options: IteratorOptions = {}\n ): AsyncGenerator<User, void, undefined> {\n const fetchPage = async (cursor?: string) => {\n return this.search(query, { ...options, cursor });\n };\n yield* paginate(fetchPage, options);\n }\n}\n","/**\n * Twitter Lists API client.\n *\n * Provides methods for fetching Twitter lists, list members, and list tweets.\n */\n\nimport type { BaseClient } from \"../internal/client.js\";\nimport type {\n PaginatedResponse,\n PaginationOptions,\n IteratorOptions,\n} from \"../internal/pagination.js\";\nimport { createPaginatedResponse, paginate } from \"../internal/pagination.js\";\nimport type { List, Tweet, User } from \"./types.js\";\n\n/**\n * Client for Twitter lists endpoints.\n *\n * Provides async methods for fetching list details, members, subscribers,\n * and tweets from lists.\n *\n * @example\n * ```typescript\n * const client = new ScrapeBadger({ apiKey: \"key\" });\n *\n * // Search for lists\n * const lists = await client.twitter.lists.search(\"tech leaders\");\n *\n * // Get list details\n * const list = await client.twitter.lists.getDetail(\"123456\");\n * console.log(`${list.name}: ${list.member_count} members`);\n *\n * // Get list tweets\n * const tweets = await client.twitter.lists.getTweets(\"123456\");\n * ```\n */\nexport class ListsClient {\n private readonly client: BaseClient;\n\n constructor(client: BaseClient) {\n this.client = client;\n }\n\n /**\n * Get details for a specific list.\n *\n * @param listId - The list ID.\n * @returns The list details.\n * @throws NotFoundError - If the list doesn't exist.\n *\n * @example\n * ```typescript\n * const list = await client.twitter.lists.getDetail(\"123456\");\n * console.log(`${list.name} by @${list.username}`);\n * console.log(`${list.member_count} members, ${list.subscriber_count} subscribers`);\n * ```\n */\n async getDetail(listId: string): Promise<List> {\n return this.client.request<List>(`/v1/twitter/lists/${listId}/detail`);\n }\n\n /**\n * Get tweets from a list's timeline.\n *\n * @param listId - The list ID.\n * @param options - Pagination options.\n * @returns Paginated response containing tweets from list members.\n *\n * @example\n * ```typescript\n * const tweets = await client.twitter.lists.getTweets(\"123456\");\n * for (const tweet of tweets.data) {\n * console.log(`@${tweet.username}: ${tweet.text.slice(0, 100)}...`);\n * }\n * ```\n */\n async getTweets(\n listId: string,\n options: PaginationOptions = {}\n ): Promise<PaginatedResponse<Tweet>> {\n const response = await this.client.request<{ data?: Tweet[]; next_cursor?: string }>(\n `/v1/twitter/lists/${listId}/tweets`,\n { params: { cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Iterate through all list tweets with automatic pagination.\n *\n * @param listId - The list ID.\n * @param options - Iteration options.\n * @yields Tweet objects from the list timeline.\n */\n async *getTweetsAll(\n listId: string,\n options: IteratorOptions = {}\n ): AsyncGenerator<Tweet, void, undefined> {\n const fetchPage = async (cursor?: string) => {\n return this.getTweets(listId, { ...options, cursor });\n };\n yield* paginate(fetchPage, options);\n }\n\n /**\n * Get members of a list.\n *\n * @param listId - The list ID.\n * @param options - Pagination options.\n * @returns Paginated response containing list members.\n *\n * @example\n * ```typescript\n * const members = await client.twitter.lists.getMembers(\"123456\");\n * for (const user of members.data) {\n * console.log(`@${user.username}`);\n * }\n * ```\n */\n async getMembers(\n listId: string,\n options: PaginationOptions = {}\n ): Promise<PaginatedResponse<User>> {\n const response = await this.client.request<{ data?: User[]; next_cursor?: string }>(\n `/v1/twitter/lists/${listId}/members`,\n { params: { cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Iterate through all list members with automatic pagination.\n *\n * @param listId - The list ID.\n * @param options - Iteration options.\n * @yields User objects for each list member.\n */\n async *getMembersAll(\n listId: string,\n options: IteratorOptions = {}\n ): AsyncGenerator<User, void, undefined> {\n const fetchPage = async (cursor?: string) => {\n return this.getMembers(listId, { ...options, cursor });\n };\n yield* paginate(fetchPage, options);\n }\n\n /**\n * Get subscribers of a list.\n *\n * @param listId - The list ID.\n * @param options - Pagination options with optional count.\n * @returns Paginated response containing list subscribers.\n */\n async getSubscribers(\n listId: string,\n options: PaginationOptions & { count?: number } = {}\n ): Promise<PaginatedResponse<User>> {\n const response = await this.client.request<{ data?: User[]; next_cursor?: string }>(\n `/v1/twitter/lists/${listId}/subscribers`,\n { params: { count: options.count ?? 20, cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Search for lists.\n *\n * @param query - Search query string.\n * @param options - Pagination options with optional count.\n * @returns Paginated response containing matching lists.\n *\n * @example\n * ```typescript\n * const results = await client.twitter.lists.search(\"tech leaders\");\n * for (const list of results.data) {\n * console.log(`${list.name}: ${list.member_count} members`);\n * }\n * ```\n */\n async search(\n query: string,\n options: PaginationOptions & { count?: number } = {}\n ): Promise<PaginatedResponse<List>> {\n const response = await this.client.request<{ data?: List[]; next_cursor?: string }>(\n \"/v1/twitter/lists/search\",\n { params: { query, count: options.count ?? 20, cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Get lists owned by the authenticated user.\n *\n * @param options - Pagination options with optional count.\n * @returns Paginated response containing the user's lists.\n */\n async getMyLists(\n options: PaginationOptions & { count?: number } = {}\n ): Promise<PaginatedResponse<List>> {\n const response = await this.client.request<{ data?: List[]; next_cursor?: string }>(\n \"/v1/twitter/lists/my_lists\",\n { params: { count: options.count ?? 100, cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n}\n","/**\n * Twitter Communities API client.\n *\n * Provides methods for fetching Twitter communities, members, and tweets.\n */\n\nimport type { BaseClient } from \"../internal/client.js\";\nimport type {\n PaginatedResponse,\n PaginationOptions,\n IteratorOptions,\n} from \"../internal/pagination.js\";\nimport { createPaginatedResponse, paginate } from \"../internal/pagination.js\";\nimport type { Community, CommunityMember, CommunityTweetType, Tweet } from \"./types.js\";\n\n/**\n * Client for Twitter communities endpoints.\n *\n * Provides async methods for fetching community details, members,\n * moderators, and tweets.\n *\n * @example\n * ```typescript\n * const client = new ScrapeBadger({ apiKey: \"key\" });\n *\n * // Search communities\n * const communities = await client.twitter.communities.search(\"python\");\n *\n * // Get community details\n * const community = await client.twitter.communities.getDetail(\"123456\");\n * console.log(`${community.name}: ${community.member_count} members`);\n *\n * // Get community tweets\n * const tweets = await client.twitter.communities.getTweets(\"123456\");\n * ```\n */\nexport class CommunitiesClient {\n private readonly client: BaseClient;\n\n constructor(client: BaseClient) {\n this.client = client;\n }\n\n /**\n * Parse a community member from the API response.\n * Handles both flat format (user_id, username, role at top level)\n * and nested format (user object with id, username).\n */\n private parseCommunityMember(item: Record<string, unknown>): CommunityMember {\n if (\"user\" in item && item.user) {\n return item as unknown as CommunityMember;\n }\n // Flat format: map user_id -> id for User interface\n return {\n user: {\n id: (item.user_id as string) ?? \"\",\n username: (item.username as string) ?? \"\",\n name: (item.name as string) ?? \"\",\n profile_image_url: item.profile_image_url as string | undefined,\n verified: (item.verified as boolean) ?? false,\n is_blue_verified: item.is_blue_verified as boolean | undefined,\n },\n role: item.role as string | undefined,\n joined_at: item.joined_at as string | undefined,\n };\n }\n\n /**\n * Get details for a specific community.\n *\n * @param communityId - The community ID.\n * @returns The community details including rules and admin info.\n * @throws NotFoundError - If the community doesn't exist.\n *\n * @example\n * ```typescript\n * const community = await client.twitter.communities.getDetail(\"123456\");\n * console.log(`${community.name}`);\n * console.log(`Members: ${community.member_count?.toLocaleString()}`);\n * console.log(`Join policy: ${community.join_policy}`);\n *\n * if (community.rules) {\n * console.log(\"Rules:\");\n * for (const rule of community.rules) {\n * console.log(` - ${rule.name}`);\n * }\n * }\n * ```\n */\n async getDetail(communityId: string): Promise<Community> {\n return this.client.request<Community>(`/v1/twitter/communities/${communityId}`);\n }\n\n /**\n * Get tweets from a community.\n *\n * @param communityId - The community ID.\n * @param options - Options including tweet type, count, and pagination.\n * @returns Paginated response containing community tweets.\n *\n * @example\n * ```typescript\n * // Get top tweets\n * const tweets = await client.twitter.communities.getTweets(\"123456\");\n *\n * // Get latest tweets\n * const latest = await client.twitter.communities.getTweets(\"123456\", {\n * tweetType: \"Latest\"\n * });\n * ```\n */\n async getTweets(\n communityId: string,\n options: PaginationOptions & { tweetType?: CommunityTweetType; count?: number } = {}\n ): Promise<PaginatedResponse<Tweet>> {\n const response = await this.client.request<{ data?: Tweet[]; next_cursor?: string }>(\n `/v1/twitter/communities/${communityId}/tweets`,\n {\n params: {\n tweet_type: options.tweetType ?? \"Top\",\n count: options.count ?? 40,\n cursor: options.cursor,\n },\n }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Iterate through all community tweets with automatic pagination.\n *\n * @param communityId - The community ID.\n * @param options - Options including tweet type and iteration limits.\n * @yields Tweet objects from the community.\n */\n async *getTweetsAll(\n communityId: string,\n options: IteratorOptions & { tweetType?: CommunityTweetType } = {}\n ): AsyncGenerator<Tweet, void, undefined> {\n const fetchPage = async (cursor?: string) => {\n return this.getTweets(communityId, { ...options, cursor });\n };\n yield* paginate(fetchPage, options);\n }\n\n /**\n * Get members of a community.\n *\n * @param communityId - The community ID.\n * @param options - Pagination options with optional count.\n * @returns Paginated response containing community members.\n *\n * @example\n * ```typescript\n * const members = await client.twitter.communities.getMembers(\"123456\");\n * for (const member of members.data) {\n * console.log(`@${member.user.username} (${member.role})`);\n * }\n * ```\n */\n async getMembers(\n communityId: string,\n options: PaginationOptions & { count?: number } = {}\n ): Promise<PaginatedResponse<CommunityMember>> {\n const response = await this.client.request<{\n data?: Record<string, unknown>[];\n next_cursor?: string;\n }>(`/v1/twitter/communities/${communityId}/members`, {\n params: { count: options.count ?? 20, cursor: options.cursor },\n });\n\n const data: CommunityMember[] = (response.data ?? []).map((item) =>\n this.parseCommunityMember(item)\n );\n\n return createPaginatedResponse(data, response.next_cursor);\n }\n\n /**\n * Get moderators of a community.\n *\n * @param communityId - The community ID.\n * @param options - Pagination options with optional count.\n * @returns Paginated response containing community moderators.\n */\n async getModerators(\n communityId: string,\n options: PaginationOptions & { count?: number } = {}\n ): Promise<PaginatedResponse<CommunityMember>> {\n const response = await this.client.request<{\n data?: Record<string, unknown>[];\n next_cursor?: string;\n }>(`/v1/twitter/communities/${communityId}/moderators`, {\n params: { count: options.count ?? 20, cursor: options.cursor },\n });\n\n const data: CommunityMember[] = (response.data ?? []).map((item) =>\n this.parseCommunityMember(item)\n );\n\n return createPaginatedResponse(data, response.next_cursor);\n }\n\n /**\n * Search for communities.\n *\n * @param query - Search query string.\n * @param options - Pagination options.\n * @returns Paginated response containing matching communities.\n *\n * @example\n * ```typescript\n * const results = await client.twitter.communities.search(\"python developers\");\n * for (const community of results.data) {\n * console.log(`${community.name}: ${community.member_count} members`);\n * }\n * ```\n */\n async search(\n query: string,\n options: PaginationOptions = {}\n ): Promise<PaginatedResponse<Community>> {\n const response = await this.client.request<{ data?: Community[]; next_cursor?: string }>(\n \"/v1/twitter/communities/search\",\n { params: { query, cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Search for tweets within a community.\n *\n * @param communityId - The community ID.\n * @param query - Search query string.\n * @param options - Pagination options with optional count.\n * @returns Paginated response containing matching tweets.\n */\n async searchTweets(\n communityId: string,\n query: string,\n options: PaginationOptions & { count?: number } = {}\n ): Promise<PaginatedResponse<Tweet>> {\n const response = await this.client.request<{ data?: Tweet[]; next_cursor?: string }>(\n `/v1/twitter/communities/${communityId}/search_tweets`,\n { params: { query, count: options.count ?? 20, cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Get the community timeline (tweets from communities you're in).\n *\n * @param options - Pagination options with optional count.\n * @returns Paginated response containing community timeline tweets.\n */\n async getTimeline(\n options: PaginationOptions & { count?: number } = {}\n ): Promise<PaginatedResponse<Tweet>> {\n const response = await this.client.request<{ data?: Tweet[]; next_cursor?: string }>(\n \"/v1/twitter/communities/timeline\",\n { params: { count: options.count ?? 20, cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n}\n","/**\n * Twitter Trends API client.\n *\n * Provides methods for fetching trending topics and trend locations.\n */\n\nimport type { BaseClient } from \"../internal/client.js\";\nimport type { PaginatedResponse } from \"../internal/pagination.js\";\nimport { createPaginatedResponse } from \"../internal/pagination.js\";\nimport type { Trend, TrendCategory, Location, PlaceTrends } from \"./types.js\";\n\n/**\n * Client for Twitter trends endpoints.\n *\n * Provides async methods for fetching trending topics, place-specific trends,\n * and available trend locations.\n *\n * @example\n * ```typescript\n * const client = new ScrapeBadger({ apiKey: \"key\" });\n *\n * // Get global trends\n * const trends = await client.twitter.trends.getTrends();\n * for (const trend of trends.data) {\n * console.log(`${trend.name}: ${trend.tweet_count || 'N/A'} tweets`);\n * }\n *\n * // Get trends for a specific location\n * const usTrends = await client.twitter.trends.getPlaceTrends(23424977);\n *\n * // Get available locations\n * const locations = await client.twitter.trends.getAvailableLocations();\n * ```\n */\nexport class TrendsClient {\n private readonly client: BaseClient;\n\n constructor(client: BaseClient) {\n this.client = client;\n }\n\n /**\n * Get trending topics.\n *\n * @param options - Options for filtering trends.\n * @returns Paginated response containing trending topics.\n *\n * @example\n * ```typescript\n * // Get general trending topics\n * const trends = await client.twitter.trends.getTrends();\n *\n * // Get news trends\n * const newsTrends = await client.twitter.trends.getTrends({\n * category: \"news\"\n * });\n *\n * for (const trend of trends.data) {\n * const count = trend.tweet_count?.toLocaleString() || \"N/A\";\n * console.log(`${trend.name}: ${count} tweets`);\n * }\n * ```\n */\n async getTrends(\n options: { category?: TrendCategory; count?: number } = {}\n ): Promise<PaginatedResponse<Trend>> {\n const response = await this.client.request<{ data?: Trend[] }>(\"/v1/twitter/trends/\", {\n params: {\n category: options.category ?? \"trending\",\n count: options.count ?? 20,\n },\n });\n return createPaginatedResponse(response.data ?? []);\n }\n\n /**\n * Get trends for a specific location.\n *\n * @param woeid - Where On Earth ID for the location.\n * Common WOEIDs:\n * - 1: Worldwide\n * - 23424977: United States\n * - 23424975: United Kingdom\n * - 23424856: Japan\n * - 23424829: Germany\n * @returns PlaceTrends containing location info and trends.\n * @throws NotFoundError - If the WOEID is invalid.\n *\n * @example\n * ```typescript\n * // Get US trends\n * const usTrends = await client.twitter.trends.getPlaceTrends(23424977);\n * console.log(`Trends in ${usTrends.name}:`);\n * for (const trend of usTrends.trends) {\n * console.log(` - ${trend.name}`);\n * }\n *\n * // Get worldwide trends\n * const globalTrends = await client.twitter.trends.getPlaceTrends(1);\n * ```\n */\n async getPlaceTrends(woeid: number): Promise<PlaceTrends> {\n return this.client.request<PlaceTrends>(`/v1/twitter/trends/place/${woeid}`);\n }\n\n /**\n * Get all locations where trends are available.\n *\n * @returns Paginated response containing available trend locations.\n *\n * @example\n * ```typescript\n * const locations = await client.twitter.trends.getAvailableLocations();\n *\n * // Filter by country\n * const usLocations = locations.data.filter(\n * loc => loc.country_code === \"US\"\n * );\n * console.log(`Found ${usLocations.length} US locations`);\n *\n * // Get countries only\n * const countries = locations.data.filter(\n * loc => loc.place_type === \"Country\"\n * );\n * ```\n */\n async getAvailableLocations(): Promise<PaginatedResponse<Location>> {\n const response = await this.client.request<{ data?: Location[] }>(\n \"/v1/twitter/trends/locations\"\n );\n return createPaginatedResponse(response.data ?? []);\n }\n}\n","/**\n * Twitter Geo API client.\n *\n * Provides methods for fetching geographic place information.\n */\n\nimport type { BaseClient } from \"../internal/client.js\";\nimport type { PaginatedResponse } from \"../internal/pagination.js\";\nimport { createPaginatedResponse } from \"../internal/pagination.js\";\nimport type { Place } from \"./types.js\";\n\n/**\n * Options for searching places.\n */\nexport interface GeoSearchOptions {\n /** Latitude coordinate */\n lat?: number;\n /** Longitude coordinate */\n long?: number;\n /** Free-form text search query (e.g., \"San Francisco\") */\n query?: string;\n /** IP address for location lookup */\n ip?: string;\n /** Result granularity (\"neighborhood\", \"city\", \"admin\", \"country\") */\n granularity?: string;\n /** Maximum number of results (1-100) */\n maxResults?: number;\n}\n\n/**\n * Client for Twitter geo/places endpoints.\n *\n * Provides async methods for fetching place details and searching\n * for geographic locations.\n *\n * @example\n * ```typescript\n * const client = new ScrapeBadger({ apiKey: \"key\" });\n *\n * // Search for places\n * const places = await client.twitter.geo.search({ query: \"San Francisco\" });\n *\n * // Search by coordinates\n * const nearby = await client.twitter.geo.search({ lat: 37.7749, long: -122.4194 });\n *\n * // Get place details\n * const place = await client.twitter.geo.getDetail(\"5a110d312052166f\");\n * ```\n */\nexport class GeoClient {\n private readonly client: BaseClient;\n\n constructor(client: BaseClient) {\n this.client = client;\n }\n\n /**\n * Get details for a specific place.\n *\n * @param placeId - The Twitter place ID.\n * @returns The place details.\n * @throws NotFoundError - If the place doesn't exist.\n *\n * @example\n * ```typescript\n * const place = await client.twitter.geo.getDetail(\"5a110d312052166f\");\n * console.log(`${place.full_name}`);\n * console.log(`Type: ${place.place_type}`);\n * console.log(`Country: ${place.country}`);\n * ```\n */\n async getDetail(placeId: string): Promise<Place> {\n return this.client.request<Place>(`/v1/twitter/geo/places/${placeId}`);\n }\n\n /**\n * Search for geographic places.\n *\n * At least one of lat/long, query, or ip must be provided.\n *\n * @param options - Search options.\n * @returns Paginated response containing matching places.\n * @throws ValidationError - If no search parameters are provided.\n *\n * @example\n * ```typescript\n * // Search by name\n * const places = await client.twitter.geo.search({ query: \"San Francisco\" });\n * for (const place of places.data) {\n * console.log(`${place.full_name} (${place.place_type})`);\n * }\n *\n * // Search by coordinates\n * const nearby = await client.twitter.geo.search({\n * lat: 37.7749,\n * long: -122.4194,\n * granularity: \"city\"\n * });\n *\n * // Search by IP\n * const ipPlaces = await client.twitter.geo.search({ ip: \"8.8.8.8\" });\n * ```\n */\n async search(options: GeoSearchOptions = {}): Promise<PaginatedResponse<Place>> {\n const response = await this.client.request<{ data?: Place[] }>(\"/v1/twitter/geo/search\", {\n params: {\n lat: options.lat,\n long: options.long,\n query: options.query,\n ip: options.ip,\n granularity: options.granularity,\n max_results: options.maxResults,\n },\n });\n return createPaginatedResponse(response.data ?? []);\n }\n}\n","/**\n * StreamClient -- stream monitor management and live WebSocket streaming.\n */\n\nimport { createHmac, timingSafeEqual } from \"node:crypto\";\nimport { EventEmitter } from \"node:events\";\nimport WebSocket from \"ws\";\nimport type { BaseClient } from \"../internal/client.js\";\nimport { WebSocketStreamError } from \"../internal/exceptions.js\";\nimport type {\n BillingLogList,\n ConnectOptions,\n ConnectedEvent,\n CreateMonitorParams,\n DeliveryLogList,\n ErrorEvent,\n FilterRuleCreate,\n FilterRuleDeliveryLogListResponse,\n FilterRuleListResponse,\n FilterRulePricingTiersResponse,\n FilterRuleResponse,\n FilterRuleUpdate,\n FilterRuleValidateResponse,\n PingEvent,\n StreamEvent,\n StreamMonitor,\n StreamMonitorList,\n StreamTweet,\n TweetEvent,\n UpdateMonitorParams,\n} from \"./stream-types.js\";\n\n// Minimum reconnect delay regardless of caller configuration (seconds)\nconst MIN_RECONNECT_DELAY_SECONDS = 5;\n\n/**\n * Derive WebSocket URL from HTTP base URL.\n * 'https://...' -> 'wss://...'\n * 'http://...' -> 'ws://...'\n */\nexport function wsUrlFromBase(baseUrl: string): string {\n if (baseUrl.startsWith(\"https://\")) {\n return baseUrl.replace(\"https://\", \"wss://\") + \"/v1/twitter/stream\";\n }\n if (baseUrl.startsWith(\"http://\")) {\n return baseUrl.replace(\"http://\", \"ws://\") + \"/v1/twitter/stream\";\n }\n return baseUrl + \"/v1/twitter/stream\";\n}\n\n/**\n * Map a raw server JSON object to a camelCase StreamEvent.\n * Unknown types return an ErrorEvent with code 0.\n */\nexport function parseEvent(raw: Record<string, unknown>): StreamEvent {\n const type = raw[\"type\"] as string | undefined;\n\n switch (type) {\n case \"connected\":\n return {\n type: \"connected\",\n connectionId: raw[\"connection_id\"] as string,\n apiKeyId: raw[\"api_key_id\"] as string,\n } satisfies ConnectedEvent;\n\n case \"ping\":\n return {\n type: \"ping\",\n timestamp: raw[\"timestamp\"] as string,\n } satisfies PingEvent;\n\n case \"tweet\":\n return {\n type: \"tweet\",\n monitorId: raw[\"monitor_id\"] as string,\n tweetId: raw[\"tweet_id\"] as string,\n authorUsername: raw[\"author_username\"] as string,\n tweetPublishedAt: raw[\"tweet_published_at\"] as string,\n detectedAt: raw[\"detected_at\"] as string,\n latencyMs: raw[\"latency_ms\"] as number,\n tweet: raw[\"tweet\"] as StreamTweet,\n } satisfies TweetEvent;\n\n case \"error\":\n return {\n type: \"error\",\n code: raw[\"code\"] as number,\n message: raw[\"message\"] as string,\n } satisfies ErrorEvent;\n\n default:\n return {\n type: \"error\",\n code: 0,\n message: `Unknown event type: ${String(type)}`,\n } satisfies ErrorEvent;\n }\n}\n\n/**\n * Typed EventEmitter for stream events.\n *\n * @example\n * ```typescript\n * const stream = client.twitter.stream.connect();\n * stream.on(\"tweet\", (event) => console.log(event.authorUsername));\n * stream.on(\"error\", (err) => console.error(err));\n * ```\n */\nexport interface StreamEmitter extends EventEmitter {\n on(event: \"connected\", listener: (event: ConnectedEvent) => void): this;\n on(event: \"ping\", listener: (event: PingEvent) => void): this;\n on(event: \"tweet\", listener: (event: TweetEvent) => void): this;\n on(event: \"error\", listener: (error: WebSocketStreamError) => void): this;\n on(event: \"close\", listener: () => void): this;\n\n once(event: \"connected\", listener: (event: ConnectedEvent) => void): this;\n once(event: \"tweet\", listener: (event: TweetEvent) => void): this;\n once(event: \"close\", listener: () => void): this;\n\n /** Gracefully close the WebSocket connection. */\n close(): void;\n}\n\n/**\n * Client for Twitter Streams -- monitor CRUD and live WebSocket streaming.\n *\n * Accessed as `client.twitter.stream`.\n *\n * @example Monitor CRUD\n * ```typescript\n * const monitor = await client.twitter.stream.createMonitor({\n * name: \"Tech Leaders\",\n * usernames: [\"elonmusk\", \"naval\"],\n * pollIntervalSeconds: 10,\n * });\n * console.log(`Created: ${monitor.id}, tier: ${monitor.pricing_tier}`);\n * ```\n *\n * @example EventEmitter streaming\n * ```typescript\n * const stream = client.twitter.stream.connect();\n * stream.on(\"tweet\", (event) => {\n * console.log(`@${event.authorUsername}: ${event.tweet.text}`);\n * console.log(` latency: ${event.latencyMs}ms`);\n * });\n * stream.on(\"error\", (err) => console.error(\"Stream error:\", err));\n * // Later:\n * stream.close();\n * ```\n *\n * @example AsyncIterator streaming\n * ```typescript\n * for await (const event of client.twitter.stream.connectIter()) {\n * if (event.type === \"tweet\") {\n * console.log(event.authorUsername, event.latencyMs);\n * }\n * }\n * ```\n */\nexport class StreamClient {\n private readonly client: BaseClient;\n\n constructor(client: BaseClient) {\n this.client = client;\n }\n\n // ===========================================================================\n // Monitor CRUD\n // ===========================================================================\n\n /**\n * Create a new stream monitor.\n *\n * @param params - Monitor configuration.\n * @returns The created StreamMonitor.\n * @throws InsufficientCreditsError - Credit balance below tier threshold (402).\n * @throws ValidationError - Invalid username or interval (422).\n * @throws ScrapeBadgerError - Name conflict (409).\n * @throws AuthenticationError - Invalid API key (401).\n *\n * @example\n * ```typescript\n * const monitor = await client.twitter.stream.createMonitor({\n * name: \"Breaking News\",\n * usernames: [\"cnnbrk\", \"bbcbreaking\"],\n * pollIntervalSeconds: 5,\n * });\n * ```\n */\n async createMonitor(params: CreateMonitorParams): Promise<StreamMonitor> {\n const body: Record<string, unknown> = {\n name: params.name,\n usernames: params.usernames,\n poll_interval_seconds: params.pollIntervalSeconds,\n };\n if (params.webhookUrl !== undefined) body[\"webhook_url\"] = params.webhookUrl;\n if (params.webhookSecret !== undefined) body[\"webhook_secret\"] = params.webhookSecret;\n\n return this.client.request<StreamMonitor>(\"/v1/twitter/stream/monitors\", {\n method: \"POST\",\n body,\n });\n }\n\n /**\n * List stream monitors for the authenticated API key.\n *\n * @param options - Filter and pagination options.\n * @returns StreamMonitorList with pagination metadata.\n *\n * @example\n * ```typescript\n * const { monitors, total } = await client.twitter.stream.listMonitors({\n * status: \"active\",\n * });\n * console.log(`${total} active monitors`);\n * ```\n */\n async listMonitors(options?: {\n status?: \"active\" | \"paused\" | \"error\";\n page?: number;\n pageSize?: number;\n }): Promise<StreamMonitorList> {\n const params: Record<string, string | number | boolean | undefined> = {\n page: options?.page ?? 1,\n page_size: options?.pageSize ?? 20,\n status: options?.status,\n };\n return this.client.request<StreamMonitorList>(\"/v1/twitter/stream/monitors\", {\n params,\n });\n }\n\n /**\n * Get a single stream monitor by ID.\n *\n * @param monitorId - UUID of the monitor.\n * @returns The StreamMonitor.\n * @throws NotFoundError - No monitor with that ID for this API key.\n *\n * @example\n * ```typescript\n * const monitor = await client.twitter.stream.getMonitor(\"550e8400-...\");\n * console.log(`${monitor.name}: ${monitor.status}`);\n * ```\n */\n async getMonitor(monitorId: string): Promise<StreamMonitor> {\n return this.client.request<StreamMonitor>(`/v1/twitter/stream/monitors/${monitorId}`);\n }\n\n /**\n * Partially update a stream monitor.\n *\n * Only fields that are explicitly set in params are sent to the server.\n *\n * @param monitorId - UUID of the monitor.\n * @param params - Fields to update (all optional).\n * @returns The updated StreamMonitor.\n * @throws NotFoundError - Monitor not found for this API key.\n * @throws InsufficientCreditsError - When resuming with insufficient credits.\n *\n * @example\n * ```typescript\n * const monitor = await client.twitter.stream.updateMonitor(\"550e8400-...\", {\n * pollIntervalSeconds: 60,\n * });\n * ```\n */\n async updateMonitor(monitorId: string, params: UpdateMonitorParams): Promise<StreamMonitor> {\n const body: Record<string, unknown> = {};\n if (params.name !== undefined) body[\"name\"] = params.name;\n if (params.usernames !== undefined) body[\"usernames\"] = params.usernames;\n if (params.pollIntervalSeconds !== undefined)\n body[\"poll_interval_seconds\"] = params.pollIntervalSeconds;\n if (params.status !== undefined) body[\"status\"] = params.status;\n if (params.webhookUrl !== undefined) body[\"webhook_url\"] = params.webhookUrl;\n if (params.webhookSecret !== undefined) body[\"webhook_secret\"] = params.webhookSecret;\n\n return this.client.request<StreamMonitor>(`/v1/twitter/stream/monitors/${monitorId}`, {\n method: \"PATCH\",\n body,\n });\n }\n\n /**\n * Pause an active stream monitor.\n *\n * Convenience wrapper around updateMonitor({ status: \"paused\" }).\n *\n * @param monitorId - UUID of the monitor.\n * @returns The updated StreamMonitor with status=\"paused\".\n */\n async pauseMonitor(monitorId: string): Promise<StreamMonitor> {\n return this.updateMonitor(monitorId, { status: \"paused\" });\n }\n\n /**\n * Resume a paused stream monitor.\n *\n * Convenience wrapper around updateMonitor({ status: \"active\" }).\n *\n * @param monitorId - UUID of the monitor.\n * @returns The updated StreamMonitor with status=\"active\".\n * @throws InsufficientCreditsError - If credits are below the tier threshold.\n */\n async resumeMonitor(monitorId: string): Promise<StreamMonitor> {\n return this.updateMonitor(monitorId, { status: \"active\" });\n }\n\n /**\n * Delete a stream monitor and all its associated logs. Irreversible.\n *\n * @param monitorId - UUID of the monitor.\n * @throws NotFoundError - Monitor not found for this API key.\n *\n * @example\n * ```typescript\n * await client.twitter.stream.deleteMonitor(\"550e8400-...\");\n * ```\n */\n async deleteMonitor(monitorId: string): Promise<void> {\n await this.client.request<void>(`/v1/twitter/stream/monitors/${monitorId}`, {\n method: \"DELETE\",\n });\n }\n\n // ===========================================================================\n // Delivery and Billing Logs\n // ===========================================================================\n\n /**\n * List tweet delivery logs.\n *\n * @param options - Filter and pagination options.\n * @returns DeliveryLogList with pagination metadata.\n */\n async listDeliveryLogs(options?: {\n monitorId?: string;\n authorUsername?: string;\n deliveryStatus?: string;\n page?: number;\n pageSize?: number;\n sort?: \"asc\" | \"desc\";\n }): Promise<DeliveryLogList> {\n const params: Record<string, string | number | boolean | undefined> = {\n page: options?.page ?? 1,\n page_size: options?.pageSize ?? 20,\n sort: options?.sort ?? \"desc\",\n monitor_id: options?.monitorId,\n author_username: options?.authorUsername,\n delivery_status: options?.deliveryStatus,\n };\n return this.client.request<DeliveryLogList>(\"/v1/twitter/stream/logs\", { params });\n }\n\n /**\n * List billing activity logs.\n *\n * @param options - Filter and pagination options.\n * @returns BillingLogList with pagination metadata.\n */\n async listBillingLogs(options?: {\n monitorId?: string;\n page?: number;\n pageSize?: number;\n }): Promise<BillingLogList> {\n const params: Record<string, string | number | boolean | undefined> = {\n page: options?.page ?? 1,\n page_size: options?.pageSize ?? 20,\n monitor_id: options?.monitorId,\n };\n return this.client.request<BillingLogList>(\"/v1/twitter/stream/billing-logs\", { params });\n }\n\n // ===========================================================================\n // Filter Rules CRUD\n // ===========================================================================\n\n /**\n * Create a new tweet filter rule.\n *\n * @param params - Filter rule configuration.\n * @returns The created FilterRuleResponse.\n * @throws ValidationError - Invalid query or interval (422).\n * @throws InsufficientCreditsError - Credit balance below tier threshold (402).\n * @throws AuthenticationError - Invalid API key (401).\n *\n * @example\n * ```typescript\n * const rule = await client.twitter.stream.createFilterRule({\n * tag: \"python news\",\n * query: \"#python lang:en -is:retweet\",\n * interval_seconds: 60,\n * });\n * console.log(`Created: ${rule.id}, tier: ${rule.pricing_tier}`);\n * ```\n */\n async createFilterRule(params: FilterRuleCreate): Promise<FilterRuleResponse> {\n const body: Record<string, unknown> = {\n tag: params.tag,\n query: params.query,\n interval_seconds: params.interval_seconds,\n };\n if (params.webhook_url !== undefined) body[\"webhook_url\"] = params.webhook_url;\n if (params.webhook_secret !== undefined) body[\"webhook_secret\"] = params.webhook_secret;\n if (params.max_results_per_poll !== undefined)\n body[\"max_results_per_poll\"] = params.max_results_per_poll;\n\n return this.client.request<FilterRuleResponse>(\"/v1/twitter/stream/filter-rules\", {\n method: \"POST\",\n body,\n });\n }\n\n /**\n * List filter rules for the authenticated API key.\n *\n * @param options - Filter and pagination options.\n * @returns FilterRuleListResponse with pagination metadata.\n *\n * @example\n * ```typescript\n * const { rules, total } = await client.twitter.stream.listFilterRules({\n * status: \"active\",\n * });\n * console.log(`${total} active rules`);\n * ```\n */\n async listFilterRules(options?: {\n status?: FilterRuleResponse[\"status\"];\n limit?: number;\n offset?: number;\n }): Promise<FilterRuleListResponse> {\n const params: Record<string, string | number | boolean | undefined> = {\n limit: options?.limit ?? 20,\n offset: options?.offset ?? 0,\n status: options?.status,\n };\n return this.client.request<FilterRuleListResponse>(\"/v1/twitter/stream/filter-rules\", {\n params,\n });\n }\n\n /**\n * Get a single filter rule by ID.\n *\n * @param ruleId - UUID of the filter rule.\n * @returns The FilterRuleResponse.\n * @throws NotFoundError - No rule with that ID for this API key.\n *\n * @example\n * ```typescript\n * const rule = await client.twitter.stream.getFilterRule(\"550e8400-...\");\n * console.log(`${rule.tag}: ${rule.status}`);\n * ```\n */\n async getFilterRule(ruleId: string): Promise<FilterRuleResponse> {\n return this.client.request<FilterRuleResponse>(`/v1/twitter/stream/filter-rules/${ruleId}`);\n }\n\n /**\n * Partially update a filter rule.\n *\n * Only fields that are explicitly set in params are sent to the server.\n *\n * @param ruleId - UUID of the filter rule.\n * @param params - Fields to update (all optional).\n * @returns The updated FilterRuleResponse.\n * @throws NotFoundError - Rule not found for this API key.\n * @throws ValidationError - Invalid field values (422).\n *\n * @example\n * ```typescript\n * const rule = await client.twitter.stream.updateFilterRule(\"550e8400-...\", {\n * interval_seconds: 120,\n * });\n * ```\n */\n async updateFilterRule(ruleId: string, params: FilterRuleUpdate): Promise<FilterRuleResponse> {\n const body: Record<string, unknown> = {};\n if (params.tag !== undefined) body[\"tag\"] = params.tag;\n if (params.query !== undefined) body[\"query\"] = params.query;\n if (params.interval_seconds !== undefined) body[\"interval_seconds\"] = params.interval_seconds;\n if (params.status !== undefined) body[\"status\"] = params.status;\n if (params.webhook_url !== undefined) body[\"webhook_url\"] = params.webhook_url;\n if (params.webhook_secret !== undefined) body[\"webhook_secret\"] = params.webhook_secret;\n if (params.max_results_per_poll !== undefined)\n body[\"max_results_per_poll\"] = params.max_results_per_poll;\n\n return this.client.request<FilterRuleResponse>(`/v1/twitter/stream/filter-rules/${ruleId}`, {\n method: \"PATCH\",\n body,\n });\n }\n\n /**\n * Delete a filter rule and all its associated logs. Irreversible.\n *\n * @param ruleId - UUID of the filter rule.\n * @throws NotFoundError - Rule not found for this API key.\n *\n * @example\n * ```typescript\n * await client.twitter.stream.deleteFilterRule(\"550e8400-...\");\n * ```\n */\n async deleteFilterRule(ruleId: string): Promise<void> {\n await this.client.request<void>(`/v1/twitter/stream/filter-rules/${ruleId}`, {\n method: \"DELETE\",\n });\n }\n\n // ===========================================================================\n // Filter Rules Utility\n // ===========================================================================\n\n /**\n * Validate a Twitter search query before creating a rule.\n *\n * @param query - The Twitter search query to validate.\n * @returns FilterRuleValidateResponse with validity and sample result count.\n *\n * @example\n * ```typescript\n * const result = await client.twitter.stream.validateFilterRuleQuery(\n * \"#python lang:en -is:retweet\"\n * );\n * if (!result.valid) {\n * console.error(\"Invalid query:\", result.error);\n * }\n * ```\n */\n async validateFilterRuleQuery(query: string): Promise<FilterRuleValidateResponse> {\n return this.client.request<FilterRuleValidateResponse>(\n \"/v1/twitter/stream/filter-rules/validate\",\n { method: \"POST\", body: { query } }\n );\n }\n\n /**\n * List tweet delivery logs for a specific filter rule.\n *\n * @param ruleId - UUID of the filter rule.\n * @param options - Filter and pagination options.\n * @returns FilterRuleDeliveryLogListResponse with pagination metadata.\n *\n * @example\n * ```typescript\n * const { logs, total } = await client.twitter.stream.listFilterRuleLogs(\n * \"550e8400-...\",\n * { limit: 50, deliveryStatus: \"webhook_delivered\" }\n * );\n * ```\n */\n async listFilterRuleLogs(\n ruleId: string,\n options?: {\n limit?: number;\n offset?: number;\n deliveryStatus?: string;\n sort?: \"asc\" | \"desc\";\n }\n ): Promise<FilterRuleDeliveryLogListResponse> {\n const params: Record<string, string | number | boolean | undefined> = {\n limit: options?.limit ?? 20,\n offset: options?.offset ?? 0,\n sort: options?.sort ?? \"desc\",\n delivery_status: options?.deliveryStatus,\n };\n return this.client.request<FilterRuleDeliveryLogListResponse>(\n `/v1/twitter/stream/filter-rules/${ruleId}/logs`,\n { params }\n );\n }\n\n /**\n * Get all available filter rule pricing tiers.\n *\n * @returns FilterRulePricingTiersResponse listing all tiers.\n *\n * @example\n * ```typescript\n * const { tiers } = await client.twitter.stream.getFilterRulePricingTiers();\n * tiers.forEach((t) => console.log(t.tier_label, t.credits_per_rule_per_day));\n * ```\n */\n async getFilterRulePricingTiers(): Promise<FilterRulePricingTiersResponse> {\n return this.client.request<FilterRulePricingTiersResponse>(\n \"/v1/twitter/stream/filter-rules-pricing\"\n );\n }\n\n // ===========================================================================\n // WebSocket Streaming -- EventEmitter style\n // ===========================================================================\n\n /**\n * Connect to the WebSocket stream and return an EventEmitter.\n *\n * The caller subscribes to events via `.on(\"tweet\", handler)`.\n * The SDK handles pong replies to server pings automatically.\n * Call `.close()` on the emitter to disconnect cleanly.\n *\n * If reconnect is true, the emitter automatically reconnects after\n * disconnects (other than auth failures). A new \"connected\" event is\n * emitted on each reconnect.\n *\n * @param options - Connection options (reconnect, delay, maxReconnects).\n * @returns StreamEmitter -- an EventEmitter subclass.\n *\n * @example\n * ```typescript\n * const stream = client.twitter.stream.connect();\n * stream.on(\"connected\", (e) => console.log(\"Connected:\", e.connectionId));\n * stream.on(\"tweet\", (event) => {\n * console.log(`@${event.authorUsername}: ${event.tweet.text}`);\n * console.log(` latency: ${event.latencyMs}ms`);\n * });\n * stream.on(\"error\", (err) => console.error(\"Stream error:\", err));\n * stream.on(\"close\", () => console.log(\"Stream closed\"));\n *\n * // Later:\n * stream.close();\n * ```\n */\n connect(options: ConnectOptions = {}): StreamEmitter {\n const { reconnect = false, reconnectDelaySeconds = 90, maxReconnects } = options;\n\n const delay = Math.max(MIN_RECONNECT_DELAY_SECONDS, reconnectDelaySeconds) * 1000;\n const wsUrl = wsUrlFromBase(this.client.config.baseUrl);\n const apiKey = this.client.config.apiKey;\n\n const emitter = new EventEmitter() as StreamEmitter;\n let ws: WebSocket | null = null;\n let closed = false;\n let reconnectCount = 0;\n\n const connectOnce = (): void => {\n ws = new WebSocket(wsUrl, { headers: { \"x-api-key\": apiKey } });\n\n ws.on(\"message\", (data: unknown) => {\n let raw: Record<string, unknown>;\n try {\n raw = JSON.parse(String(data)) as Record<string, unknown>;\n } catch {\n return;\n }\n\n const event = parseEvent(raw);\n\n if (event.type === \"ping\") {\n ws?.send(JSON.stringify({ type: \"pong\" }));\n emitter.emit(\"ping\", event);\n return;\n }\n\n if (event.type === \"error\") {\n const code = (event as ErrorEvent).code;\n const err = new WebSocketStreamError((event as ErrorEvent).message, code);\n emitter.emit(\"error\", err);\n if (code === 4001 || code === 4003) {\n closed = true; // Do not reconnect on auth/limit errors\n ws?.close();\n }\n return;\n }\n\n emitter.emit(event.type, event);\n });\n\n ws.on(\"open\", () => {\n // Connection is open; wait for \"connected\" event from server\n });\n\n ws.on(\"close\", (code: unknown, reason: unknown) => {\n if (closed) {\n emitter.emit(\"close\");\n return;\n }\n\n if (!reconnect) {\n const reasonStr = reason instanceof Buffer ? reason.toString() : String(reason ?? \"\");\n emitter.emit(\n \"error\",\n new WebSocketStreamError(`WebSocket closed: ${reasonStr || String(code)}`)\n );\n emitter.emit(\"close\");\n return;\n }\n\n if (maxReconnects !== undefined && reconnectCount >= maxReconnects) {\n emitter.emit(\n \"error\",\n new WebSocketStreamError(`Max reconnects (${maxReconnects}) exhausted`)\n );\n emitter.emit(\"close\");\n return;\n }\n\n reconnectCount++;\n setTimeout(connectOnce, delay);\n });\n\n ws.on(\"error\", (err: unknown) => {\n const message = err instanceof Error ? err.message : String(err);\n emitter.emit(\"error\", new WebSocketStreamError(message));\n });\n };\n\n // Attach close() method to emitter\n (emitter as unknown as { close: () => void }).close = (): void => {\n closed = true;\n ws?.close(1000, \"Client closed\");\n };\n\n connectOnce();\n return emitter;\n }\n\n // ===========================================================================\n // WebSocket Streaming -- AsyncIterator style\n // ===========================================================================\n\n /**\n * Connect to the WebSocket stream and return an AsyncIterator.\n *\n * Iterates over StreamEvent objects. The SDK handles pong replies\n * automatically but still yields PingEvent to the caller (the caller\n * may ignore ping events).\n *\n * @param options - Connection options (reconnect, delay, maxReconnects).\n * @yields StreamEvent\n *\n * @example\n * ```typescript\n * for await (const event of client.twitter.stream.connectIter()) {\n * if (event.type === \"tweet\") {\n * console.log(`@${event.authorUsername}: ${event.latencyMs}ms`);\n * }\n * }\n * ```\n *\n * @example With auto-reconnect\n * ```typescript\n * for await (const event of client.twitter.stream.connectIter({\n * reconnect: true,\n * reconnectDelaySeconds: 90,\n * })) {\n * if (event.type === \"tweet\") {\n * // process(event);\n * }\n * }\n * ```\n */\n async *connectIter(options: ConnectOptions = {}): AsyncIterableIterator<StreamEvent> {\n const { reconnect = false, reconnectDelaySeconds = 90, maxReconnects } = options;\n\n const delay = Math.max(MIN_RECONNECT_DELAY_SECONDS, reconnectDelaySeconds) * 1000;\n const wsUrl = wsUrlFromBase(this.client.config.baseUrl);\n const apiKey = this.client.config.apiKey;\n let reconnectCount = 0;\n\n while (true) {\n const events: StreamEvent[] = [];\n let resolveWait: (() => void) | null = null;\n let rejectWait: ((err: Error) => void) | null = null;\n let done = false;\n\n const ws = new WebSocket(wsUrl, { headers: { \"x-api-key\": apiKey } });\n\n const waitForEvent = (): Promise<void> =>\n new Promise<void>((res, rej) => {\n resolveWait = res;\n rejectWait = rej;\n });\n\n ws.on(\"message\", (data: unknown) => {\n let raw: Record<string, unknown>;\n try {\n raw = JSON.parse(String(data)) as Record<string, unknown>;\n } catch {\n return;\n }\n\n const event = parseEvent(raw);\n\n if (event.type === \"ping\") {\n ws.send(JSON.stringify({ type: \"pong\" }));\n }\n\n if (event.type === \"error\") {\n const code = (event as ErrorEvent).code;\n if (code === 4001 || code === 4003) {\n rejectWait?.(new WebSocketStreamError((event as ErrorEvent).message, code));\n rejectWait = null;\n resolveWait = null;\n return;\n }\n }\n\n events.push(event);\n resolveWait?.();\n resolveWait = null;\n rejectWait = null;\n });\n\n ws.on(\"close\", () => {\n done = true;\n resolveWait?.();\n resolveWait = null;\n rejectWait = null;\n });\n\n ws.on(\"error\", (err: unknown) => {\n const message = err instanceof Error ? err.message : String(err);\n rejectWait?.(new WebSocketStreamError(message));\n rejectWait = null;\n resolveWait = null;\n });\n\n try {\n while (!done || events.length > 0) {\n if (events.length === 0) {\n await waitForEvent();\n }\n while (events.length > 0) {\n yield events.shift()!;\n }\n }\n } catch (err) {\n ws.close();\n throw err;\n } finally {\n ws.close();\n }\n\n // Connection ended cleanly\n if (!reconnect) {\n return;\n }\n\n if (maxReconnects !== undefined && reconnectCount >= maxReconnects) {\n throw new WebSocketStreamError(`Max reconnects (${maxReconnects}) exhausted`);\n }\n\n reconnectCount++;\n await new Promise<void>((res) => setTimeout(res, delay));\n // Continue outer while loop for reconnect\n }\n }\n}\n\n/**\n * Verify the HMAC-SHA256 signature of an incoming webhook request.\n *\n * The server sets the header:\n * X-ScrapeBadger-Signature: sha256=<hex-digest>\n *\n * @param secret - The webhook secret configured on the monitor.\n * @param body - The raw request body string or Buffer.\n * @param signatureHeader - The full X-ScrapeBadger-Signature header value.\n * @returns true if the signature is valid.\n *\n * @example\n * ```typescript\n * // In an Express webhook receiver:\n * import { verifyWebhookSignature } from \"scrapebadger/twitter\";\n * import express from \"express\";\n *\n * app.post(\"/webhook\", express.raw({ type: \"application/json\" }), (req, res) => {\n * const sig = req.headers[\"x-scrapebadger-signature\"] as string;\n * if (!verifyWebhookSignature(\"my-secret\", req.body, sig)) {\n * return res.status(401).json({ error: \"Invalid signature\" });\n * }\n * const event = JSON.parse(req.body.toString());\n * // process event...\n * res.sendStatus(200);\n * });\n * ```\n */\nexport function verifyWebhookSignature(\n secret: string,\n body: string | Buffer,\n signatureHeader: string\n): boolean {\n if (!signatureHeader.startsWith(\"sha256=\")) {\n return false;\n }\n\n const expectedHex = signatureHeader.slice(\"sha256=\".length);\n const bodyBuffer = typeof body === \"string\" ? Buffer.from(body, \"utf-8\") : body;\n const actualHex = createHmac(\"sha256\", secret).update(bodyBuffer).digest(\"hex\");\n\n // Use constant-time comparison to prevent timing attacks\n try {\n return timingSafeEqual(Buffer.from(expectedHex, \"hex\"), Buffer.from(actualHex, \"hex\"));\n } catch {\n // Buffers of different lengths throw -- treat as mismatch\n return false;\n }\n}\n","/**\n * Twitter API client.\n *\n * Provides access to all Twitter API endpoints through specialized sub-clients.\n */\n\nimport type { BaseClient } from \"../internal/client.js\";\nimport { TweetsClient } from \"./tweets.js\";\nimport { UsersClient } from \"./users.js\";\nimport { ListsClient } from \"./lists.js\";\nimport { CommunitiesClient } from \"./communities.js\";\nimport { TrendsClient } from \"./trends.js\";\nimport { GeoClient } from \"./geo.js\";\nimport { StreamClient } from \"./stream.js\";\n\n/**\n * Twitter API client with access to all Twitter endpoints.\n *\n * Provides sub-clients for different resource types:\n * - `tweets` - Tweet operations (get, search, replies, retweeters, etc.)\n * - `users` - User operations (profiles, followers, following, search, etc.)\n * - `lists` - List operations (details, members, tweets, search, etc.)\n * - `communities` - Community operations (details, members, tweets, search, etc.)\n * - `trends` - Trending topics and locations\n * - `geo` - Geographic place information\n * - `stream` - Real-time stream monitor management and WebSocket streaming\n *\n * @example\n * ```typescript\n * const client = new ScrapeBadger({ apiKey: \"key\" });\n *\n * // Access tweets\n * const tweet = await client.twitter.tweets.getById(\"1234567890\");\n *\n * // Access users\n * const user = await client.twitter.users.getByUsername(\"elonmusk\");\n *\n * // Access trends\n * const trends = await client.twitter.trends.getTrends();\n *\n * // Search with automatic pagination\n * for await (const tweet of client.twitter.tweets.searchAll(\"python\")) {\n * console.log(tweet.text);\n * }\n *\n * // Stream live tweets\n * const stream = client.twitter.stream.connect();\n * stream.on(\"tweet\", (event) => console.log(event.authorUsername));\n * ```\n */\nexport class TwitterClient {\n /** Client for tweet operations */\n readonly tweets: TweetsClient;\n\n /** Client for user operations */\n readonly users: UsersClient;\n\n /** Client for list operations */\n readonly lists: ListsClient;\n\n /** Client for community operations */\n readonly communities: CommunitiesClient;\n\n /** Client for trends operations */\n readonly trends: TrendsClient;\n\n /** Client for geo/places operations */\n readonly geo: GeoClient;\n\n /** Client for real-time stream monitor management and WebSocket streaming */\n readonly stream: StreamClient;\n\n /**\n * Create a new Twitter client.\n *\n * @param client - The base HTTP client for making requests.\n */\n constructor(client: BaseClient) {\n this.tweets = new TweetsClient(client);\n this.users = new UsersClient(client);\n this.lists = new ListsClient(client);\n this.communities = new CommunitiesClient(client);\n this.trends = new TrendsClient(client);\n this.geo = new GeoClient(client);\n this.stream = new StreamClient(client);\n }\n}\n","/**\n * Web scraping API client for ScrapeBadger SDK.\n */\n\nimport type { BaseClient } from \"../internal/client.js\";\nimport type {\n ScrapeOptions,\n ScrapeResult,\n ScreenshotOptions,\n ScreenshotResult,\n ExtractOptions,\n ExtractResult,\n BatchOptions,\n BatchResult,\n SessionInfo,\n} from \"./types.js\";\n\n/**\n * Client for web scraping operations.\n *\n * @example\n * ```typescript\n * const client = new ScrapeBadger({ apiKey: \"key\" });\n *\n * // Simple scrape\n * const result = await client.web.scrape(\"https://example.com\");\n * console.log(result.content);\n *\n * // Screenshot\n * const screenshot = await client.web.screenshot(\"https://example.com\");\n *\n * // Extract structured data\n * const data = await client.web.extract(\"https://example.com\", {\n * schema: { title: \"css:h1\" }\n * });\n *\n * // Batch scrape\n * const batch = await client.web.batch([\"https://a.com\", \"https://b.com\"]);\n * ```\n */\nexport class WebClient {\n private readonly client: BaseClient;\n\n constructor(client: BaseClient) {\n this.client = client;\n }\n\n /**\n * Scrape a web page.\n */\n async scrape(url: string, options: ScrapeOptions = {}): Promise<ScrapeResult> {\n const body: Record<string, unknown> = { url };\n if (options.renderJs) body.render_js = true;\n if (options.outputFormat && options.outputFormat !== \"html\")\n body.output_format = options.outputFormat;\n if (options.proxyCountry) body.proxy_country = options.proxyCountry;\n if (options.proxyType) body.proxy_type = options.proxyType;\n if (options.sessionId) body.session_id = options.sessionId;\n if (options.engine) body.engine = options.engine;\n if (options.maxCost !== undefined) body.max_cost = options.maxCost;\n if (options.headers) body.headers = options.headers;\n if (options.waitFor) body.wait_for = options.waitFor;\n if (options.timeout !== undefined) body.timeout = options.timeout;\n if (options.jsScenario) body.js_scenario = options.jsScenario;\n\n return this.client.request<ScrapeResult>(\"/v1/web/scrape\", {\n method: \"POST\",\n body,\n });\n }\n\n /**\n * Take a screenshot of a web page.\n */\n async screenshot(\n url: string,\n options: ScreenshotOptions = {}\n ): Promise<ScreenshotResult> {\n const body: Record<string, unknown> = { url };\n if (options.fullPage) body.full_page = true;\n if (options.viewportWidth && options.viewportWidth !== 1280)\n body.viewport_width = options.viewportWidth;\n if (options.viewportHeight && options.viewportHeight !== 720)\n body.viewport_height = options.viewportHeight;\n if (options.imageFormat && options.imageFormat !== \"png\")\n body.image_format = options.imageFormat;\n if (options.waitFor) body.wait_for = options.waitFor;\n if (options.timeout !== undefined) body.timeout = options.timeout;\n\n return this.client.request<ScreenshotResult>(\"/v1/web/screenshot\", {\n method: \"POST\",\n body,\n });\n }\n\n /**\n * Extract structured data from a web page.\n */\n async extract(\n url: string,\n options: ExtractOptions = {}\n ): Promise<ExtractResult> {\n const body: Record<string, unknown> = { url };\n if (options.schema) body.extraction_schema = options.schema;\n if (options.renderJs) body.render_js = true;\n if (options.waitFor) body.wait_for = options.waitFor;\n if (options.timeout !== undefined) body.timeout = options.timeout;\n\n return this.client.request<ExtractResult>(\"/v1/web/extract\", {\n method: \"POST\",\n body,\n });\n }\n\n /**\n * Scrape multiple URLs in a batch.\n */\n async batch(\n urls: string[],\n options: BatchOptions = {}\n ): Promise<BatchResult> {\n const body: Record<string, unknown> = { urls };\n if (options.renderJs) body.render_js = true;\n if (options.outputFormat && options.outputFormat !== \"html\")\n body.output_format = options.outputFormat;\n if (options.maxConcurrency && options.maxConcurrency !== 5)\n body.max_concurrency = options.maxConcurrency;\n if (options.engine) body.engine = options.engine;\n if (options.timeout !== undefined) body.timeout = options.timeout;\n\n return this.client.request<BatchResult>(\"/v1/web/batch\", {\n method: \"POST\",\n body,\n });\n }\n\n /**\n * Create a new scraping session for a domain.\n */\n async createSession(domain: string, persist = true): Promise<SessionInfo> {\n return this.client.request<SessionInfo>(\"/v1/web/sessions\", {\n method: \"POST\",\n body: {\n domain,\n new_session: true,\n persist_session: persist,\n },\n });\n }\n\n /**\n * Scrape using an existing session.\n */\n async reuseSession(\n url: string,\n sessionId: string,\n options: ScrapeOptions = {}\n ): Promise<ScrapeResult> {\n return this.scrape(url, { ...options, sessionId });\n }\n}\n","/**\n * Main ScrapeBadger client.\n *\n * This is the primary entry point for the ScrapeBadger SDK.\n */\n\nimport { BaseClient } from \"./internal/client.js\";\nimport {\n type ScrapeBadgerConfig,\n resolveConfig,\n getApiKeyFromEnv,\n} from \"./internal/config.js\";\nimport { TwitterClient } from \"./twitter/client.js\";\nimport { WebClient } from \"./web/client.js\";\n\n/**\n * ScrapeBadger API client.\n *\n * The main client for interacting with the ScrapeBadger API.\n * Provides access to all available scrapers through typed sub-clients.\n *\n * @example\n * ```typescript\n * import { ScrapeBadger } from \"scrapebadger\";\n *\n * // Create client with API key\n * const client = new ScrapeBadger({ apiKey: \"your-api-key\" });\n *\n * // Or use environment variable (SCRAPEBADGER_API_KEY)\n * const client = new ScrapeBadger();\n *\n * // Access Twitter API\n * const tweet = await client.twitter.tweets.getById(\"1234567890\");\n * const user = await client.twitter.users.getByUsername(\"elonmusk\");\n *\n * // Search with automatic pagination\n * for await (const tweet of client.twitter.tweets.searchAll(\"python\")) {\n * console.log(tweet.text);\n * }\n *\n * // Collect all results into an array\n * import { collectAll } from \"scrapebadger\";\n * const tweets = await collectAll(\n * client.twitter.tweets.searchAll(\"python\", { maxItems: 100 })\n * );\n * ```\n */\nexport class ScrapeBadger {\n private readonly baseClient: BaseClient;\n\n /** Twitter API client */\n readonly twitter: TwitterClient;\n\n /** Web scraping API client */\n readonly web: WebClient;\n\n /**\n * Create a new ScrapeBadger client.\n *\n * @param config - Configuration options. If apiKey is not provided,\n * it will be read from the SCRAPEBADGER_API_KEY environment variable.\n * @throws Error if no API key is provided or found in environment.\n *\n * @example\n * ```typescript\n * // With explicit API key\n * const client = new ScrapeBadger({ apiKey: \"your-api-key\" });\n *\n * // With custom options\n * const client = new ScrapeBadger({\n * apiKey: \"your-api-key\",\n * baseUrl: \"https://custom.api.com\",\n * timeout: 60000,\n * maxRetries: 5\n * });\n *\n * // Using environment variable\n * // Set SCRAPEBADGER_API_KEY=your-api-key\n * const client = new ScrapeBadger();\n * ```\n */\n constructor(config: Partial<ScrapeBadgerConfig> = {}) {\n // Use provided API key or fall back to environment variable\n const apiKey = config.apiKey ?? getApiKeyFromEnv();\n\n if (!apiKey) {\n throw new Error(\n \"API key is required. Pass it in the config or set SCRAPEBADGER_API_KEY environment variable.\"\n );\n }\n\n const resolvedConfig = resolveConfig({ ...config, apiKey });\n this.baseClient = new BaseClient(resolvedConfig);\n\n // Initialize sub-clients\n this.twitter = new TwitterClient(this.baseClient);\n this.web = new WebClient(this.baseClient);\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/internal/exceptions.ts","../src/internal/client.ts","../src/internal/config.ts","../src/internal/pagination.ts","../src/twitter/tweets.ts","../src/twitter/users.ts","../src/twitter/lists.ts","../src/twitter/communities.ts","../src/twitter/trends.ts","../src/twitter/geo.ts","../src/twitter/stream.ts","../src/twitter/client.ts","../src/web/client.ts","../src/client.ts"],"names":[],"mappings":";;;;;AAOO,IAAM,iBAAA,GAAN,MAAM,kBAAA,SAA0B,KAAA,CAAM;AAAA,EAC3C,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,mBAAA;AACZ,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,kBAAA,CAAkB,SAAS,CAAA;AAAA,EACzD;AACF;AAKO,IAAM,mBAAA,GAAN,MAAM,oBAAA,SAA4B,iBAAA,CAAkB;AAAA,EACzD,WAAA,CAAY,UAAU,4CAAA,EAA8C;AAClE,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,qBAAA;AACZ,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,oBAAA,CAAoB,SAAS,CAAA;AAAA,EAC3D;AACF;AAKO,IAAM,cAAA,GAAN,MAAM,eAAA,SAAuB,iBAAA,CAAkB;AAAA;AAAA,EAE3C,UAAA;AAAA;AAAA,EAEA,KAAA;AAAA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IAAI,KAAA;AAAA,QACR;AAAA,OACF;AAAA,IACF;AAEA,IAAA,MAAM,iBAAiB,aAAA,CAAc,EAAE,GAAG,MAAA,EAAQ,QAAQ,CAAA;AAC1D,IAAA,IAAA,CAAK,UAAA,GAAa,IAAI,UAAA,CAAW,cAAc,CAAA;AAG/C,IAAA,IAAA,CAAK,OAAA,GAAU,IAAI,aAAA,CAAc,IAAA,CAAK,UAAU,CAAA;AAChD,IAAA,IAAA,CAAK,GAAA,GAAM,IAAI,SAAA,CAAU,IAAA,CAAK,UAAU,CAAA;AAAA,EAC1C;AACF","file":"index.mjs","sourcesContent":["/**\n * Custom exceptions for the ScrapeBadger SDK.\n */\n\n/**\n * Base error class for all ScrapeBadger errors.\n */\nexport class ScrapeBadgerError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ScrapeBadgerError\";\n Object.setPrototypeOf(this, ScrapeBadgerError.prototype);\n }\n}\n\n/**\n * Raised when authentication fails (invalid or missing API key).\n */\nexport class AuthenticationError extends ScrapeBadgerError {\n constructor(message = \"Authentication failed. Check your API key.\") {\n super(message);\n this.name = \"AuthenticationError\";\n Object.setPrototypeOf(this, AuthenticationError.prototype);\n }\n}\n\n/**\n * Raised when rate limit is exceeded.\n */\nexport class RateLimitError extends ScrapeBadgerError {\n /** Unix timestamp when the rate limit resets */\n readonly retryAfter: number | undefined;\n /** Maximum requests per minute for this tier */\n readonly limit: number | undefined;\n /** Remaining requests in the current window */\n readonly remaining: number | undefined;\n\n constructor(\n message = \"Rate limit exceeded.\",\n options?: { retryAfter?: number; limit?: number; remaining?: number }\n ) {\n super(message);\n this.name = \"RateLimitError\";\n this.retryAfter = options?.retryAfter;\n this.limit = options?.limit;\n this.remaining = options?.remaining;\n Object.setPrototypeOf(this, RateLimitError.prototype);\n }\n}\n\n/**\n * Raised when the requested resource is not found.\n */\nexport class NotFoundError extends ScrapeBadgerError {\n /** The resource type that was not found */\n readonly resourceType: string | undefined;\n /** The resource ID that was not found */\n readonly resourceId: string | undefined;\n\n constructor(message = \"Resource not found.\", resourceType?: string, resourceId?: string) {\n super(message);\n this.name = \"NotFoundError\";\n this.resourceType = resourceType;\n this.resourceId = resourceId;\n Object.setPrototypeOf(this, NotFoundError.prototype);\n }\n}\n\n/**\n * Raised when the request is invalid.\n */\nexport class ValidationError extends ScrapeBadgerError {\n /** Validation errors by field */\n readonly errors: Record<string, string[]> | undefined;\n\n constructor(message = \"Validation error.\", errors?: Record<string, string[]>) {\n super(message);\n this.name = \"ValidationError\";\n this.errors = errors;\n Object.setPrototypeOf(this, ValidationError.prototype);\n }\n}\n\n/**\n * Raised when an internal server error occurs.\n */\nexport class ServerError extends ScrapeBadgerError {\n /** HTTP status code */\n readonly statusCode: number;\n\n constructor(message = \"Internal server error.\", statusCode = 500) {\n super(message);\n this.name = \"ServerError\";\n this.statusCode = statusCode;\n Object.setPrototypeOf(this, ServerError.prototype);\n }\n}\n\n/**\n * Raised when the request times out.\n */\nexport class TimeoutError extends ScrapeBadgerError {\n /** Timeout duration in milliseconds */\n readonly timeout: number;\n\n constructor(message = \"Request timed out.\", timeout: number) {\n super(message);\n this.name = \"TimeoutError\";\n this.timeout = timeout;\n Object.setPrototypeOf(this, TimeoutError.prototype);\n }\n}\n\n/**\n * Raised when the account has insufficient credits.\n */\nexport class InsufficientCreditsError extends ScrapeBadgerError {\n /** Current credit balance */\n readonly creditsBalance: number | undefined;\n\n constructor(message = \"Insufficient credits.\", creditsBalance?: number) {\n super(message);\n this.name = \"InsufficientCreditsError\";\n this.creditsBalance = creditsBalance;\n Object.setPrototypeOf(this, InsufficientCreditsError.prototype);\n }\n}\n\n/**\n * Raised when the account is restricted.\n */\nexport class AccountRestrictedError extends ScrapeBadgerError {\n /** Reason for the restriction */\n readonly reason: string | undefined;\n\n constructor(message = \"Account restricted.\", reason?: string) {\n super(message);\n this.name = \"AccountRestrictedError\";\n this.reason = reason;\n Object.setPrototypeOf(this, AccountRestrictedError.prototype);\n }\n}\n\n/**\n * Raised when a resource conflict occurs (e.g. duplicate monitor name).\n *\n * Maps to HTTP 409 Conflict.\n *\n * @example\n * ```typescript\n * import { ConflictError } from \"scrapebadger\";\n *\n * try {\n * await client.twitter.stream.createMonitor({\n * name: \"Existing Monitor\",\n * usernames: [\"elonmusk\"],\n * pollIntervalSeconds: 10,\n * });\n * } catch (err) {\n * if (err instanceof ConflictError) {\n * console.error(\"Monitor name already exists:\", err.message);\n * }\n * }\n * ```\n */\nexport class ConflictError extends ScrapeBadgerError {\n constructor(message = \"Resource conflict.\") {\n super(message);\n this.name = \"ConflictError\";\n Object.setPrototypeOf(this, ConflictError.prototype);\n }\n}\n\n/**\n * Raised when the WebSocket stream connection fails or is terminated.\n *\n * Common codes:\n * - 4001 -- Invalid or missing API key (auth failure)\n * - 4003 -- Connection limit exceeded (max 5 per API key)\n * - 1001 -- Server closed due to pong timeout\n * - 0 -- Unknown/parse error\n *\n * @example\n * ```typescript\n * import { WebSocketStreamError } from \"scrapebadger\";\n *\n * try {\n * for await (const event of client.twitter.stream.connectIter()) {\n * // ...\n * }\n * } catch (err) {\n * if (err instanceof WebSocketStreamError && err.code === 4001) {\n * console.error(\"API key rejected -- check your key\");\n * }\n * }\n * ```\n */\nexport class WebSocketStreamError extends ScrapeBadgerError {\n /** WebSocket close code or server error code */\n readonly code: number | undefined;\n\n constructor(message = \"WebSocket stream error\", code?: number) {\n super(message);\n this.name = \"WebSocketStreamError\";\n this.code = code;\n Object.setPrototypeOf(this, WebSocketStreamError.prototype);\n }\n}\n","/**\n * Base HTTP client with retry logic and error handling.\n */\n\nimport type { ResolvedConfig } from \"./config.js\";\nimport {\n AuthenticationError,\n RateLimitError,\n NotFoundError,\n ValidationError,\n ServerError,\n TimeoutError,\n InsufficientCreditsError,\n AccountRestrictedError,\n ConflictError,\n ScrapeBadgerError,\n} from \"./exceptions.js\";\n\nexport interface RateLimit {\n limit: number;\n remaining: number;\n reset: number; // unix timestamp\n}\n\nexport interface ResponseWithHeaders<T> {\n data: T;\n rateLimit?: RateLimit;\n}\n\nexport interface RequestOptions {\n method?: \"GET\" | \"POST\" | \"PUT\" | \"DELETE\" | \"PATCH\";\n params?: Record<string, string | number | boolean | undefined>;\n body?: unknown;\n headers?: Record<string, string>;\n}\n\ninterface ErrorResponse {\n detail?: string;\n message?: string;\n errors?: Record<string, string[]>;\n limit?: number;\n remaining?: number;\n reset_at?: number;\n reason?: string;\n credits_balance?: number;\n}\n\n/**\n * Base HTTP client for making API requests.\n */\nexport class BaseClient {\n readonly config: ResolvedConfig;\n\n constructor(config: ResolvedConfig) {\n this.config = config;\n }\n\n /**\n * Make an HTTP request to the API.\n */\n async request<T>(path: string, options: RequestOptions = {}): Promise<T> {\n const { data } = await this.requestRaw<T>(path, options);\n return data;\n }\n\n /**\n * Make an HTTP request and return both data and rate limit headers.\n */\n async requestWithHeaders<T>(\n path: string,\n options: RequestOptions = {}\n ): Promise<ResponseWithHeaders<T>> {\n return this.requestRaw<T>(path, options);\n }\n\n /**\n * Internal method that builds the request and executes it, returning data and rate limit info.\n */\n private async requestRaw<T>(\n path: string,\n options: RequestOptions = {}\n ): Promise<ResponseWithHeaders<T>> {\n const { method = \"GET\", params, body, headers = {} } = options;\n\n // Build URL with query parameters\n const url = new URL(path, this.config.baseUrl);\n if (params) {\n for (const [key, value] of Object.entries(params)) {\n if (value !== undefined) {\n url.searchParams.set(key, String(value));\n }\n }\n }\n\n // Build headers\n const requestHeaders: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n \"X-API-Key\": this.config.apiKey,\n \"User-Agent\": \"scrapebadger-node/0.3.1\",\n ...headers,\n };\n\n // Build request options\n const fetchOptions: RequestInit = {\n method,\n headers: requestHeaders,\n };\n\n if (body && method !== \"GET\") {\n fetchOptions.body = JSON.stringify(body);\n }\n\n // Execute with retry logic\n return this.executeWithRetry<T>(url.toString(), fetchOptions);\n }\n\n /**\n * Execute request with exponential backoff retry logic.\n */\n private async executeWithRetry<T>(\n url: string,\n options: RequestInit\n ): Promise<ResponseWithHeaders<T>> {\n let lastError: Error | undefined;\n\n for (let attempt = 0; attempt <= this.config.maxRetries; attempt++) {\n try {\n const httpResponse = await this.fetchWithTimeout(url, options);\n const data = await this.handleResponse<T>(httpResponse);\n const rateLimit = this.parseRateLimitHeaders(httpResponse.headers);\n return { data, rateLimit };\n } catch (error) {\n lastError = error as Error;\n\n // Don't retry on client errors (4xx) except rate limits\n if (error instanceof ScrapeBadgerError && !(error instanceof RateLimitError)) {\n throw error;\n }\n\n // Don't retry after exhausting attempts\n if (attempt === this.config.maxRetries) {\n break;\n }\n\n // Calculate delay with exponential backoff\n const delay = this.config.retryDelay * Math.pow(2, attempt);\n const delaySec = Math.round(delay / 1000);\n const attemptNum = attempt + 1;\n const maxRetries = this.config.maxRetries;\n\n // Warn with ANSI yellow coloring\n if (error instanceof RateLimitError) {\n console.warn(\n `\\x1b[33m⚠ ScrapeBadger: 429 Rate Limited — retrying in ${delaySec}s (attempt ${attemptNum}/${maxRetries})\\x1b[0m`\n );\n // For rate limits, use retry-after if available\n if (error.retryAfter) {\n const retryDelay = (error.retryAfter - Date.now() / 1000) * 1000;\n if (retryDelay > 0 && retryDelay < 60000) {\n await this.sleep(retryDelay);\n continue;\n }\n }\n } else if (error instanceof TimeoutError) {\n console.warn(\n `\\x1b[33m⚠ ScrapeBadger: TimeoutError — retrying in ${delaySec}s (attempt ${attemptNum}/${maxRetries})\\x1b[0m`\n );\n } else if (error instanceof ServerError) {\n console.warn(\n `\\x1b[33m⚠ ScrapeBadger: ${error.statusCode} ${error.message} — retrying in ${delaySec}s (attempt ${attemptNum}/${maxRetries})\\x1b[0m`\n );\n } else {\n console.warn(\n `\\x1b[33m⚠ ScrapeBadger: ${(error as Error).name} — retrying in ${delaySec}s (attempt ${attemptNum}/${maxRetries})\\x1b[0m`\n );\n }\n\n await this.sleep(delay);\n }\n }\n\n throw lastError ?? new ScrapeBadgerError(\"Request failed after retries\");\n }\n\n /**\n * Parse rate limit headers from an HTTP response.\n */\n private parseRateLimitHeaders(headers: Headers): RateLimit | undefined {\n const limit = headers.get(\"X-RateLimit-Limit\");\n const remaining = headers.get(\"X-RateLimit-Remaining\");\n const reset = headers.get(\"X-RateLimit-Reset\");\n\n if (limit === null || remaining === null || reset === null) {\n return undefined;\n }\n\n const parsedLimit = parseInt(limit, 10);\n const parsedRemaining = parseInt(remaining, 10);\n const parsedReset = parseInt(reset, 10);\n\n if (isNaN(parsedLimit) || isNaN(parsedRemaining) || isNaN(parsedReset)) {\n return undefined;\n }\n\n return { limit: parsedLimit, remaining: parsedRemaining, reset: parsedReset };\n }\n\n /**\n * Fetch with timeout support.\n */\n private async fetchWithTimeout(url: string, options: RequestInit): Promise<Response> {\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);\n\n try {\n const response = await fetch(url, {\n ...options,\n signal: controller.signal,\n });\n return response;\n } catch (error) {\n if (error instanceof Error && error.name === \"AbortError\") {\n throw new TimeoutError(\n `Request timed out after ${this.config.timeout}ms`,\n this.config.timeout\n );\n }\n throw error;\n } finally {\n clearTimeout(timeoutId);\n }\n }\n\n /**\n * Handle HTTP response and convert errors.\n */\n private async handleResponse<T>(response: Response): Promise<T> {\n // Parse response body\n let data: T | ErrorResponse;\n const contentType = response.headers.get(\"content-type\");\n\n if (contentType?.includes(\"application/json\")) {\n data = (await response.json()) as T | ErrorResponse;\n } else {\n const text = await response.text();\n data = { detail: text } as ErrorResponse;\n }\n\n // Handle success\n if (response.ok) {\n return data as T;\n }\n\n // Handle errors\n const errorData = data as ErrorResponse;\n const message = errorData.detail ?? errorData.message ?? \"Request failed\";\n\n switch (response.status) {\n case 401:\n throw new AuthenticationError(message);\n\n case 402:\n throw new InsufficientCreditsError(message, errorData.credits_balance);\n\n case 403:\n if (message.toLowerCase().includes(\"restricted\")) {\n throw new AccountRestrictedError(message, errorData.reason);\n }\n throw new AuthenticationError(message);\n\n case 404:\n throw new NotFoundError(message);\n\n case 409:\n throw new ConflictError(message);\n\n case 422:\n throw new ValidationError(message, errorData.errors);\n\n case 429:\n throw new RateLimitError(message, {\n retryAfter: errorData.reset_at,\n limit: errorData.limit,\n remaining: errorData.remaining,\n });\n\n default:\n if (response.status >= 500) {\n throw new ServerError(message, response.status);\n }\n throw new ScrapeBadgerError(message);\n }\n }\n\n /**\n * Sleep for a given duration.\n */\n private sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n}\n","/**\n * Configuration management for the ScrapeBadger SDK.\n */\n\nexport interface ScrapeBadgerConfig {\n /** API key for authentication */\n apiKey: string;\n /** Base URL for the API (default: https://scrapebadger.com) */\n baseUrl?: string;\n /** Request timeout in milliseconds (default: 30000) */\n timeout?: number;\n /** Maximum number of retry attempts (default: 3) */\n maxRetries?: number;\n /** Initial retry delay in milliseconds (default: 1000) */\n retryDelay?: number;\n}\n\nexport interface ResolvedConfig {\n apiKey: string;\n baseUrl: string;\n timeout: number;\n maxRetries: number;\n retryDelay: number;\n}\n\nconst DEFAULT_BASE_URL = \"https://scrapebadger.com\";\nconst DEFAULT_TIMEOUT = 30000;\nconst DEFAULT_MAX_RETRIES = 10;\nconst DEFAULT_RETRY_DELAY = 1000;\n\n/**\n * Resolve configuration with defaults.\n */\nexport function resolveConfig(config: ScrapeBadgerConfig): ResolvedConfig {\n if (!config.apiKey) {\n throw new Error(\"API key is required\");\n }\n\n return {\n apiKey: config.apiKey,\n baseUrl: config.baseUrl ?? DEFAULT_BASE_URL,\n timeout: config.timeout ?? DEFAULT_TIMEOUT,\n maxRetries: config.maxRetries ?? DEFAULT_MAX_RETRIES,\n retryDelay: config.retryDelay ?? DEFAULT_RETRY_DELAY,\n };\n}\n\n/**\n * Load API key from environment variable.\n */\nexport function getApiKeyFromEnv(): string | undefined {\n if (typeof process !== \"undefined\" && process.env) {\n return process.env.SCRAPEBADGER_API_KEY;\n }\n return undefined;\n}\n","/**\n * Pagination utilities for the ScrapeBadger SDK.\n */\n\nimport type { RateLimit } from \"./client.js\";\n\n/**\n * Response wrapper for paginated API responses.\n */\nexport interface PaginatedResponse<T> {\n /** Array of items in the current page */\n data: T[];\n /** Cursor for the next page, if available */\n nextCursor?: string;\n /** Whether there are more pages available */\n hasMore: boolean;\n}\n\n/**\n * Options for paginated requests.\n */\nexport interface PaginationOptions {\n /** Maximum number of items to fetch per request (default: 20) */\n count?: number;\n /** Cursor for pagination */\n cursor?: string;\n}\n\n/**\n * Options for async iteration.\n */\nexport interface IteratorOptions extends PaginationOptions {\n /** Maximum total number of items to fetch (default: unlimited) */\n maxItems?: number;\n}\n\n/**\n * Page result returned by fetchPage callbacks passed to paginate().\n */\nexport interface PageResult<T> {\n response: PaginatedResponse<T>;\n rateLimit?: RateLimit;\n}\n\n/**\n * Create a paginated response from API response data.\n */\nexport function createPaginatedResponse<T>(\n data: T[],\n cursor?: string\n): PaginatedResponse<T> {\n return {\n data,\n nextCursor: cursor,\n hasMore: !!cursor,\n };\n}\n\nconst RATE_LIMIT_WARN_THRESHOLD = 0.2;\n\n/**\n * Async generator for paginating through API results.\n *\n * Automatically throttles when fewer than 20% of rate limit requests remain,\n * spreading requests across the remaining reset window.\n *\n * @param fetchPage - Function to fetch a single page; returns response + optional rate limit info\n * @param options - Pagination options\n * @yields Individual items from each page\n *\n * @example\n * ```typescript\n * // Iterate through all results\n * for await (const tweet of client.twitter.tweets.searchAll(\"query\")) {\n * console.log(tweet.text);\n * }\n *\n * // With max items limit\n * for await (const tweet of client.twitter.tweets.searchAll(\"query\", { maxItems: 100 })) {\n * console.log(tweet.text);\n * }\n * ```\n */\nexport async function* paginate<T>(\n fetchPage: (cursor?: string) => Promise<PageResult<T>>,\n options: IteratorOptions = {}\n): AsyncGenerator<T, void, undefined> {\n const { maxItems } = options;\n let cursor: string | undefined;\n let totalYielded = 0;\n\n do {\n const { response, rateLimit } = await fetchPage(cursor);\n\n // Throttle pagination when approaching rate limit\n if (rateLimit) {\n const { limit, remaining, reset } = rateLimit;\n if (limit > 0 && remaining / limit < RATE_LIMIT_WARN_THRESHOLD) {\n const nowSec = Date.now() / 1000;\n const windowRemainingSec = Math.max(reset - nowSec, 1);\n const delayMs = remaining > 0 ? (windowRemainingSec / remaining) * 1000 : windowRemainingSec * 1000;\n const resetInSec = Math.round(windowRemainingSec);\n console.warn(\n `\\x1b[33m⚠ ScrapeBadger: Rate limit: ${remaining}/${limit} remaining (resets in ${resetInSec}s), throttling pagination\\x1b[0m`\n );\n await sleep(delayMs);\n }\n }\n\n for (const item of response.data) {\n yield item;\n totalYielded++;\n\n if (maxItems !== undefined && totalYielded >= maxItems) {\n return;\n }\n }\n\n cursor = response.nextCursor;\n } while (cursor);\n}\n\n/**\n * Collect all items from an async generator into an array.\n *\n * @param generator - Async generator to collect from\n * @returns Array of all yielded items\n *\n * @example\n * ```typescript\n * const tweets = await collectAll(client.twitter.tweets.searchAll(\"query\", { maxItems: 100 }));\n * console.log(`Fetched ${tweets.length} tweets`);\n * ```\n */\nexport async function collectAll<T>(generator: AsyncGenerator<T, void, undefined>): Promise<T[]> {\n const items: T[] = [];\n for await (const item of generator) {\n items.push(item);\n }\n return items;\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n","/**\n * Twitter Tweets API client.\n *\n * Provides methods for fetching tweets, searching, and getting tweet metadata.\n */\n\nimport type { BaseClient } from \"../internal/client.js\";\nimport type {\n PaginatedResponse,\n PaginationOptions,\n IteratorOptions,\n} from \"../internal/pagination.js\";\nimport { createPaginatedResponse, paginate } from \"../internal/pagination.js\";\nimport type { PageResult } from \"../internal/pagination.js\";\nimport type { Tweet, User, QueryType } from \"./types.js\";\n\n/**\n * Client for Twitter tweets endpoints.\n *\n * Provides async methods for fetching individual tweets, searching tweets,\n * and getting tweet engagement data (retweeters, favoriters, replies).\n *\n * @example\n * ```typescript\n * const client = new ScrapeBadger({ apiKey: \"key\" });\n *\n * // Get single tweet\n * const tweet = await client.twitter.tweets.getById(\"1234567890\");\n *\n * // Search tweets\n * const results = await client.twitter.tweets.search(\"python programming\");\n * for (const tweet of results.data) {\n * console.log(tweet.text);\n * }\n *\n * // Iterate through all results\n * for await (const tweet of client.twitter.tweets.searchAll(\"python\")) {\n * console.log(tweet.text);\n * }\n * ```\n */\nexport class TweetsClient {\n private readonly client: BaseClient;\n\n constructor(client: BaseClient) {\n this.client = client;\n }\n\n /**\n * Get a single tweet by ID.\n *\n * @param tweetId - The tweet ID to fetch.\n * @returns The tweet data.\n * @throws NotFoundError - If the tweet doesn't exist.\n * @throws AuthenticationError - If the API key is invalid.\n *\n * @example\n * ```typescript\n * const tweet = await client.twitter.tweets.getById(\"1234567890\");\n * console.log(`@${tweet.username}: ${tweet.text}`);\n * ```\n */\n async getById(tweetId: string): Promise<Tweet> {\n return this.client.request<Tweet>(`/v1/twitter/tweets/tweet/${tweetId}`);\n }\n\n /**\n * Get multiple tweets by their IDs.\n *\n * @param tweetIds - List of tweet IDs to fetch.\n * @returns Paginated response containing the tweets.\n *\n * @example\n * ```typescript\n * const tweets = await client.twitter.tweets.getByIds([\n * \"1234567890\",\n * \"0987654321\"\n * ]);\n * for (const tweet of tweets.data) {\n * console.log(tweet.text);\n * }\n * ```\n */\n async getByIds(tweetIds: string[]): Promise<PaginatedResponse<Tweet>> {\n const tweetsParam = tweetIds.join(\",\");\n const response = await this.client.request<{ data?: Tweet[]; next_cursor?: string }>(\n \"/v1/twitter/tweets/\",\n { params: { tweets: tweetsParam } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Get replies to a tweet.\n *\n * @param tweetId - The tweet ID to get replies for.\n * @param options - Pagination options.\n * @returns Paginated response containing reply tweets.\n *\n * @example\n * ```typescript\n * const replies = await client.twitter.tweets.getReplies(\"1234567890\");\n * for (const reply of replies.data) {\n * console.log(`@${reply.username}: ${reply.text}`);\n * }\n *\n * // Get next page\n * if (replies.hasMore) {\n * const more = await client.twitter.tweets.getReplies(\"1234567890\", {\n * cursor: replies.nextCursor\n * });\n * }\n * ```\n */\n async getReplies(\n tweetId: string,\n options: PaginationOptions = {}\n ): Promise<PaginatedResponse<Tweet>> {\n const response = await this.client.request<{ data?: Tweet[]; next_cursor?: string }>(\n `/v1/twitter/tweets/tweet/${tweetId}/replies`,\n { params: { cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Get users who retweeted a tweet.\n *\n * @param tweetId - The tweet ID to get retweeters for.\n * @param options - Pagination options.\n * @returns Paginated response containing users who retweeted.\n *\n * @example\n * ```typescript\n * const retweeters = await client.twitter.tweets.getRetweeters(\"1234567890\");\n * for (const user of retweeters.data) {\n * console.log(`@${user.username} retweeted`);\n * }\n * ```\n */\n async getRetweeters(\n tweetId: string,\n options: PaginationOptions = {}\n ): Promise<PaginatedResponse<User>> {\n const response = await this.client.request<{ data?: User[]; next_cursor?: string }>(\n `/v1/twitter/tweets/tweet/${tweetId}/retweeters`,\n { params: { cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Get users who liked/favorited a tweet.\n *\n * @param tweetId - The tweet ID to get favoriters for.\n * @param options - Pagination options with optional count.\n * @returns Paginated response containing users who liked.\n *\n * @example\n * ```typescript\n * const likers = await client.twitter.tweets.getFavoriters(\"1234567890\");\n * console.log(`${likers.data.length} users liked this tweet`);\n * ```\n */\n async getFavoriters(\n tweetId: string,\n options: PaginationOptions & { count?: number } = {}\n ): Promise<PaginatedResponse<User>> {\n const response = await this.client.request<{ data?: User[]; next_cursor?: string }>(\n `/v1/twitter/tweets/tweet/${tweetId}/favoriters`,\n { params: { count: options.count ?? 40, cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Get tweets similar to a given tweet.\n *\n * @param tweetId - The tweet ID to find similar tweets for.\n * @returns Paginated response containing similar tweets.\n *\n * @example\n * ```typescript\n * const similar = await client.twitter.tweets.getSimilar(\"1234567890\");\n * for (const tweet of similar.data) {\n * console.log(`Similar: ${tweet.text.slice(0, 100)}...`);\n * }\n * ```\n */\n async getSimilar(tweetId: string): Promise<PaginatedResponse<Tweet>> {\n const response = await this.client.request<{ data?: Tweet[]; next_cursor?: string }>(\n `/v1/twitter/tweets/tweet/${tweetId}/similar`\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Get tweets that quote a specific tweet.\n *\n * @param tweetId - The tweet ID to get quote tweets for.\n * @param options - Pagination options.\n * @returns Paginated response containing tweets that quote this tweet.\n *\n * @example\n * ```typescript\n * const quotes = await client.twitter.tweets.getQuotes(\"1234567890\");\n * for (const quote of quotes.data) {\n * console.log(`@${quote.username} quoted: ${quote.text.slice(0, 100)}...`);\n * }\n *\n * // Get next page\n * if (quotes.hasMore) {\n * const more = await client.twitter.tweets.getQuotes(\"1234567890\", {\n * cursor: quotes.nextCursor\n * });\n * }\n * ```\n */\n async getQuotes(\n tweetId: string,\n options: PaginationOptions = {}\n ): Promise<PaginatedResponse<Tweet>> {\n const response = await this.client.request<{ data?: Tweet[]; next_cursor?: string }>(\n `/v1/twitter/tweets/tweet/${tweetId}/quotes`,\n { params: { cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Iterate through all quote tweets with automatic pagination.\n *\n * This is a convenience method that automatically handles pagination,\n * yielding quote tweets one at a time.\n *\n * @param tweetId - The tweet ID to get quote tweets for.\n * @param options - Iteration options.\n * @yields Tweet objects that quote the specified tweet.\n *\n * @example\n * ```typescript\n * // Get all quote tweets (up to 500)\n * for await (const quote of client.twitter.tweets.getQuotesAll(\"1234567890\", {\n * maxItems: 500\n * })) {\n * console.log(`@${quote.username}: ${quote.text}`);\n * }\n *\n * // Collect into an array\n * import { collectAll } from \"scrapebadger\";\n * const quotes = await collectAll(\n * client.twitter.tweets.getQuotesAll(\"1234567890\", { maxItems: 100 })\n * );\n * ```\n */\n async *getQuotesAll(\n tweetId: string,\n options: IteratorOptions = {}\n ): AsyncGenerator<Tweet, void, undefined> {\n const fetchPage = async (cursor?: string): Promise<PageResult<Tweet>> => {\n const { data, rateLimit } = await this.client.requestWithHeaders<{\n data?: Tweet[];\n next_cursor?: string;\n }>(`/v1/twitter/tweets/tweet/${tweetId}/quotes`, { params: { cursor } });\n return { response: createPaginatedResponse(data.data ?? [], data.next_cursor), rateLimit };\n };\n yield* paginate(fetchPage, options);\n }\n\n /**\n * Search for tweets.\n *\n * @param query - Search query string. Supports Twitter advanced search operators.\n * @param options - Search options including query type and pagination.\n * @returns Paginated response containing matching tweets.\n *\n * @example\n * ```typescript\n * // Basic search\n * const results = await client.twitter.tweets.search(\"python programming\");\n *\n * // Latest tweets only\n * const latest = await client.twitter.tweets.search(\"python\", {\n * queryType: \"Latest\"\n * });\n *\n * // Advanced search operators\n * const fromUser = await client.twitter.tweets.search(\"from:elonmusk lang:en\");\n * ```\n */\n async search(\n query: string,\n options: PaginationOptions & { queryType?: QueryType; count?: number } = {}\n ): Promise<PaginatedResponse<Tweet>> {\n const response = await this.client.request<{ data?: Tweet[]; next_cursor?: string }>(\n \"/v1/twitter/tweets/advanced_search\",\n {\n params: {\n query,\n query_type: options.queryType ?? \"Top\",\n count: options.count,\n cursor: options.cursor,\n },\n }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Iterate through all search results with automatic pagination.\n *\n * This is a convenience method that automatically handles pagination,\n * yielding tweets one at a time.\n *\n * @param query - Search query string.\n * @param options - Search and iteration options.\n * @yields Tweet objects matching the search query.\n *\n * @example\n * ```typescript\n * // Get up to 1000 tweets\n * for await (const tweet of client.twitter.tweets.searchAll(\"python\", {\n * maxItems: 1000\n * })) {\n * console.log(tweet.text);\n * }\n *\n * // Collect into an array\n * import { collectAll } from \"scrapebadger\";\n * const tweets = await collectAll(\n * client.twitter.tweets.searchAll(\"python\", { maxItems: 100 })\n * );\n * ```\n */\n async *searchAll(\n query: string,\n options: IteratorOptions & { queryType?: QueryType; count?: number } = {}\n ): AsyncGenerator<Tweet, void, undefined> {\n const fetchPage = async (cursor?: string): Promise<PageResult<Tweet>> => {\n const { data, rateLimit } = await this.client.requestWithHeaders<{\n data?: Tweet[];\n next_cursor?: string;\n }>(\"/v1/twitter/tweets/advanced_search\", {\n params: {\n query,\n query_type: options.queryType ?? \"Top\",\n count: options.count,\n cursor,\n },\n });\n return { response: createPaginatedResponse(data.data ?? [], data.next_cursor), rateLimit };\n };\n yield* paginate(fetchPage, options);\n }\n\n /**\n * Get tweets from a user's timeline.\n *\n * @param username - Twitter username (without @).\n * @param options - Pagination options.\n * @returns Paginated response containing the user's tweets.\n *\n * @example\n * ```typescript\n * const tweets = await client.twitter.tweets.getUserTweets(\"elonmusk\");\n * for (const tweet of tweets.data) {\n * console.log(`${tweet.created_at}: ${tweet.text.slice(0, 100)}...`);\n * }\n * ```\n */\n async getUserTweets(\n username: string,\n options: PaginationOptions = {}\n ): Promise<PaginatedResponse<Tweet>> {\n const response = await this.client.request<{ data?: Tweet[]; next_cursor?: string }>(\n `/v1/twitter/users/${username}/latest_tweets`,\n { params: { cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Iterate through all tweets from a user with automatic pagination.\n *\n * @param username - Twitter username (without @).\n * @param options - Iteration options.\n * @yields Tweet objects from the user's timeline.\n *\n * @example\n * ```typescript\n * for await (const tweet of client.twitter.tweets.getUserTweetsAll(\"elonmusk\", {\n * maxItems: 500\n * })) {\n * console.log(tweet.text);\n * }\n * ```\n */\n async *getUserTweetsAll(\n username: string,\n options: IteratorOptions = {}\n ): AsyncGenerator<Tweet, void, undefined> {\n const fetchPage = async (cursor?: string): Promise<PageResult<Tweet>> => {\n const { data, rateLimit } = await this.client.requestWithHeaders<{\n data?: Tweet[];\n next_cursor?: string;\n }>(`/v1/twitter/users/${username}/latest_tweets`, { params: { cursor } });\n return { response: createPaginatedResponse(data.data ?? [], data.next_cursor), rateLimit };\n };\n yield* paginate(fetchPage, options);\n }\n}\n","/**\n * Twitter Users API client.\n *\n * Provides methods for fetching user profiles, followers, following, and related data.\n */\n\nimport type { BaseClient } from \"../internal/client.js\";\nimport type {\n PaginatedResponse,\n PaginationOptions,\n IteratorOptions,\n} from \"../internal/pagination.js\";\nimport { createPaginatedResponse, paginate } from \"../internal/pagination.js\";\nimport type { PageResult } from \"../internal/pagination.js\";\nimport type { User, UserAbout, UserIds, Tweet } from \"./types.js\";\n\n/**\n * Client for Twitter users endpoints.\n *\n * Provides async methods for fetching user profiles, followers, following,\n * and other user-related data.\n *\n * @example\n * ```typescript\n * const client = new ScrapeBadger({ apiKey: \"key\" });\n *\n * // Get user profile\n * const user = await client.twitter.users.getByUsername(\"elonmusk\");\n * console.log(`${user.name}: ${user.followers_count.toLocaleString()} followers`);\n *\n * // Get followers\n * const followers = await client.twitter.users.getFollowers(\"elonmusk\");\n *\n * // Iterate through all followers\n * for await (const follower of client.twitter.users.getFollowersAll(\"elonmusk\")) {\n * console.log(follower.username);\n * }\n * ```\n */\nexport class UsersClient {\n private readonly client: BaseClient;\n\n constructor(client: BaseClient) {\n this.client = client;\n }\n\n /**\n * Get a user by their numeric ID.\n *\n * @param userId - The user's numeric ID.\n * @returns The user profile.\n * @throws NotFoundError - If the user doesn't exist.\n *\n * @example\n * ```typescript\n * const user = await client.twitter.users.getById(\"44196397\");\n * console.log(`@${user.username}`);\n * ```\n */\n async getById(userId: string): Promise<User> {\n return this.client.request<User>(`/v1/twitter/users/${userId}/by_id`);\n }\n\n /**\n * Get a user by their username.\n *\n * @param username - The user's username (without @).\n * @returns The user profile.\n * @throws NotFoundError - If the user doesn't exist.\n *\n * @example\n * ```typescript\n * const user = await client.twitter.users.getByUsername(\"elonmusk\");\n * console.log(`${user.name} has ${user.followers_count.toLocaleString()} followers`);\n * ```\n */\n async getByUsername(username: string): Promise<User> {\n return this.client.request<User>(`/v1/twitter/users/${username}/by_username`);\n }\n\n /**\n * Get extended \"About\" information for a user.\n *\n * Returns additional metadata including account location,\n * username change history, and verification details.\n *\n * @param username - The user's username (without @).\n * @returns Extended user information.\n *\n * @example\n * ```typescript\n * const about = await client.twitter.users.getAbout(\"elonmusk\");\n * console.log(`Account based in: ${about.account_based_in}`);\n * console.log(`Username changes: ${about.username_changes}`);\n * ```\n */\n async getAbout(username: string): Promise<UserAbout> {\n return this.client.request<UserAbout>(`/v1/twitter/users/${username}/about`);\n }\n\n /**\n * Get a user's followers.\n *\n * @param username - The user's username (without @).\n * @param options - Pagination options.\n * @returns Paginated response containing follower users.\n *\n * @example\n * ```typescript\n * const followers = await client.twitter.users.getFollowers(\"elonmusk\");\n * for (const user of followers.data) {\n * console.log(`@${user.username}`);\n * }\n *\n * // Get next page\n * if (followers.hasMore) {\n * const more = await client.twitter.users.getFollowers(\"elonmusk\", {\n * cursor: followers.nextCursor\n * });\n * }\n * ```\n */\n async getFollowers(\n username: string,\n options: PaginationOptions = {}\n ): Promise<PaginatedResponse<User>> {\n const response = await this.client.request<{ data?: User[]; next_cursor?: string }>(\n `/v1/twitter/users/${username}/followers`,\n { params: { cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Iterate through all followers with automatic pagination.\n *\n * @param username - The user's username (without @).\n * @param options - Iteration options.\n * @yields User objects for each follower.\n *\n * @example\n * ```typescript\n * for await (const follower of client.twitter.users.getFollowersAll(\"elonmusk\", {\n * maxItems: 1000\n * })) {\n * console.log(follower.username);\n * }\n * ```\n */\n async *getFollowersAll(\n username: string,\n options: IteratorOptions = {}\n ): AsyncGenerator<User, void, undefined> {\n const fetchPage = async (cursor?: string): Promise<PageResult<User>> => {\n const { data, rateLimit } = await this.client.requestWithHeaders<{\n data?: User[];\n next_cursor?: string;\n }>(`/v1/twitter/users/${username}/followers`, { params: { cursor } });\n return { response: createPaginatedResponse(data.data ?? [], data.next_cursor), rateLimit };\n };\n yield* paginate(fetchPage, options);\n }\n\n /**\n * Get users that a user is following.\n *\n * @param username - The user's username (without @).\n * @param options - Pagination options.\n * @returns Paginated response containing followed users.\n *\n * @example\n * ```typescript\n * const following = await client.twitter.users.getFollowing(\"elonmusk\");\n * for (const user of following.data) {\n * console.log(`Follows @${user.username}`);\n * }\n * ```\n */\n async getFollowing(\n username: string,\n options: PaginationOptions = {}\n ): Promise<PaginatedResponse<User>> {\n const response = await this.client.request<{ data?: User[]; next_cursor?: string }>(\n `/v1/twitter/users/${username}/followings`,\n { params: { cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Iterate through all following with automatic pagination.\n *\n * @param username - The user's username (without @).\n * @param options - Iteration options.\n * @yields User objects for each followed account.\n */\n async *getFollowingAll(\n username: string,\n options: IteratorOptions = {}\n ): AsyncGenerator<User, void, undefined> {\n const fetchPage = async (cursor?: string): Promise<PageResult<User>> => {\n const { data, rateLimit } = await this.client.requestWithHeaders<{\n data?: User[];\n next_cursor?: string;\n }>(`/v1/twitter/users/${username}/followings`, { params: { cursor } });\n return { response: createPaginatedResponse(data.data ?? [], data.next_cursor), rateLimit };\n };\n yield* paginate(fetchPage, options);\n }\n\n /**\n * Get a user's most recent followers.\n *\n * @param username - The user's username (without @).\n * @param options - Pagination options with optional count.\n * @returns Paginated response containing recent followers.\n */\n async getLatestFollowers(\n username: string,\n options: PaginationOptions & { count?: number } = {}\n ): Promise<PaginatedResponse<User>> {\n const response = await this.client.request<{ data?: User[]; next_cursor?: string }>(\n `/v1/twitter/users/${username}/latest_followers`,\n { params: { count: options.count ?? 200, cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Get accounts a user most recently followed.\n *\n * @param username - The user's username (without @).\n * @param options - Pagination options with optional count.\n * @returns Paginated response containing recently followed users.\n */\n async getLatestFollowing(\n username: string,\n options: PaginationOptions & { count?: number } = {}\n ): Promise<PaginatedResponse<User>> {\n const response = await this.client.request<{ data?: User[]; next_cursor?: string }>(\n `/v1/twitter/users/${username}/latest_following`,\n { params: { count: options.count ?? 200, cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Get follower IDs for a user.\n *\n * More efficient than getFollowers when you only need IDs.\n *\n * @param username - The user's username (without @).\n * @param options - Pagination options with optional count.\n * @returns UserIds containing list of follower IDs.\n *\n * @example\n * ```typescript\n * const ids = await client.twitter.users.getFollowerIds(\"elonmusk\");\n * console.log(`Found ${ids.ids.length.toLocaleString()} follower IDs`);\n * ```\n */\n async getFollowerIds(\n username: string,\n options: PaginationOptions & { count?: number } = {}\n ): Promise<UserIds> {\n const response = await this.client.request<{ data?: { ids?: number[]; next_cursor?: string } }>(\n `/v1/twitter/users/${username}/follower_ids`,\n { params: { count: options.count ?? 5000, cursor: options.cursor } }\n );\n return {\n ids: response.data?.ids ?? [],\n next_cursor: response.data?.next_cursor,\n };\n }\n\n /**\n * Get following IDs for a user.\n *\n * More efficient than getFollowing when you only need IDs.\n *\n * @param username - The user's username (without @).\n * @param options - Pagination options with optional count.\n * @returns UserIds containing list of following IDs.\n */\n async getFollowingIds(\n username: string,\n options: PaginationOptions & { count?: number } = {}\n ): Promise<UserIds> {\n const response = await this.client.request<{ data?: { ids?: number[]; next_cursor?: string } }>(\n `/v1/twitter/users/${username}/following_ids`,\n { params: { count: options.count ?? 5000, cursor: options.cursor } }\n );\n return {\n ids: response.data?.ids ?? [],\n next_cursor: response.data?.next_cursor,\n };\n }\n\n /**\n * Get verified followers for a user.\n *\n * @param userId - The user's numeric ID.\n * @param options - Pagination options with optional count.\n * @returns Paginated response containing verified followers.\n */\n async getVerifiedFollowers(\n userId: string,\n options: PaginationOptions & { count?: number } = {}\n ): Promise<PaginatedResponse<User>> {\n const response = await this.client.request<{ data?: User[]; next_cursor?: string }>(\n `/v1/twitter/users/${userId}/verified_followers`,\n { params: { count: options.count ?? 20, cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Get followers that the authenticated user also follows.\n *\n * @param userId - The user's numeric ID.\n * @param options - Pagination options with optional count.\n * @returns Paginated response containing mutual connections.\n */\n async getFollowersYouKnow(\n userId: string,\n options: PaginationOptions & { count?: number } = {}\n ): Promise<PaginatedResponse<User>> {\n const response = await this.client.request<{ data?: User[]; next_cursor?: string }>(\n `/v1/twitter/users/${userId}/followers_you_know`,\n { params: { count: options.count ?? 20, cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Get premium accounts that a user subscribes to.\n *\n * @param userId - The user's numeric ID.\n * @param options - Pagination options with optional count.\n * @returns Paginated response containing subscribed accounts.\n */\n async getSubscriptions(\n userId: string,\n options: PaginationOptions & { count?: number } = {}\n ): Promise<PaginatedResponse<User>> {\n const response = await this.client.request<{ data?: User[]; next_cursor?: string }>(\n `/v1/twitter/users/${userId}/subscriptions`,\n { params: { count: options.count ?? 20, cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Get a user's highlighted tweets.\n *\n * @param userId - The user's numeric ID.\n * @param options - Pagination options with optional count.\n * @returns Paginated response containing highlighted tweets.\n */\n async getHighlights(\n userId: string,\n options: PaginationOptions & { count?: number } = {}\n ): Promise<PaginatedResponse<Tweet>> {\n const response = await this.client.request<{ data?: Tweet[]; next_cursor?: string }>(\n `/v1/twitter/users/${userId}/highlights`,\n { params: { count: options.count ?? 20, cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Search for users.\n *\n * @param query - Search query string.\n * @param options - Pagination options.\n * @returns Paginated response containing matching users.\n *\n * @example\n * ```typescript\n * const results = await client.twitter.users.search(\"python developer\");\n * for (const user of results.data) {\n * console.log(`@${user.username}: ${user.description}`);\n * }\n * ```\n */\n async search(query: string, options: PaginationOptions = {}): Promise<PaginatedResponse<User>> {\n const response = await this.client.request<{ data?: User[]; next_cursor?: string }>(\n \"/v1/twitter/users/search_users\",\n { params: { query, cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Iterate through all search results with automatic pagination.\n *\n * @param query - Search query string.\n * @param options - Iteration options.\n * @yields User objects matching the search query.\n */\n async *searchAll(\n query: string,\n options: IteratorOptions = {}\n ): AsyncGenerator<User, void, undefined> {\n const fetchPage = async (cursor?: string): Promise<PageResult<User>> => {\n const { data, rateLimit } = await this.client.requestWithHeaders<{\n data?: User[];\n next_cursor?: string;\n }>(\"/v1/twitter/users/search_users\", { params: { query, cursor } });\n return { response: createPaginatedResponse(data.data ?? [], data.next_cursor), rateLimit };\n };\n yield* paginate(fetchPage, options);\n }\n}\n","/**\n * Twitter Lists API client.\n *\n * Provides methods for fetching Twitter lists, list members, and list tweets.\n */\n\nimport type { BaseClient } from \"../internal/client.js\";\nimport type {\n PaginatedResponse,\n PaginationOptions,\n IteratorOptions,\n} from \"../internal/pagination.js\";\nimport { createPaginatedResponse, paginate } from \"../internal/pagination.js\";\nimport type { PageResult } from \"../internal/pagination.js\";\nimport type { List, Tweet, User } from \"./types.js\";\n\n/**\n * Client for Twitter lists endpoints.\n *\n * Provides async methods for fetching list details, members, subscribers,\n * and tweets from lists.\n *\n * @example\n * ```typescript\n * const client = new ScrapeBadger({ apiKey: \"key\" });\n *\n * // Search for lists\n * const lists = await client.twitter.lists.search(\"tech leaders\");\n *\n * // Get list details\n * const list = await client.twitter.lists.getDetail(\"123456\");\n * console.log(`${list.name}: ${list.member_count} members`);\n *\n * // Get list tweets\n * const tweets = await client.twitter.lists.getTweets(\"123456\");\n * ```\n */\nexport class ListsClient {\n private readonly client: BaseClient;\n\n constructor(client: BaseClient) {\n this.client = client;\n }\n\n /**\n * Get details for a specific list.\n *\n * @param listId - The list ID.\n * @returns The list details.\n * @throws NotFoundError - If the list doesn't exist.\n *\n * @example\n * ```typescript\n * const list = await client.twitter.lists.getDetail(\"123456\");\n * console.log(`${list.name} by @${list.username}`);\n * console.log(`${list.member_count} members, ${list.subscriber_count} subscribers`);\n * ```\n */\n async getDetail(listId: string): Promise<List> {\n return this.client.request<List>(`/v1/twitter/lists/${listId}/detail`);\n }\n\n /**\n * Get tweets from a list's timeline.\n *\n * @param listId - The list ID.\n * @param options - Pagination options.\n * @returns Paginated response containing tweets from list members.\n *\n * @example\n * ```typescript\n * const tweets = await client.twitter.lists.getTweets(\"123456\");\n * for (const tweet of tweets.data) {\n * console.log(`@${tweet.username}: ${tweet.text.slice(0, 100)}...`);\n * }\n * ```\n */\n async getTweets(\n listId: string,\n options: PaginationOptions = {}\n ): Promise<PaginatedResponse<Tweet>> {\n const response = await this.client.request<{ data?: Tweet[]; next_cursor?: string }>(\n `/v1/twitter/lists/${listId}/tweets`,\n { params: { cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Iterate through all list tweets with automatic pagination.\n *\n * @param listId - The list ID.\n * @param options - Iteration options.\n * @yields Tweet objects from the list timeline.\n */\n async *getTweetsAll(\n listId: string,\n options: IteratorOptions = {}\n ): AsyncGenerator<Tweet, void, undefined> {\n const fetchPage = async (cursor?: string): Promise<PageResult<Tweet>> => {\n const { data, rateLimit } = await this.client.requestWithHeaders<{\n data?: Tweet[];\n next_cursor?: string;\n }>(`/v1/twitter/lists/${listId}/tweets`, { params: { cursor } });\n return { response: createPaginatedResponse(data.data ?? [], data.next_cursor), rateLimit };\n };\n yield* paginate(fetchPage, options);\n }\n\n /**\n * Get members of a list.\n *\n * @param listId - The list ID.\n * @param options - Pagination options.\n * @returns Paginated response containing list members.\n *\n * @example\n * ```typescript\n * const members = await client.twitter.lists.getMembers(\"123456\");\n * for (const user of members.data) {\n * console.log(`@${user.username}`);\n * }\n * ```\n */\n async getMembers(\n listId: string,\n options: PaginationOptions = {}\n ): Promise<PaginatedResponse<User>> {\n const response = await this.client.request<{ data?: User[]; next_cursor?: string }>(\n `/v1/twitter/lists/${listId}/members`,\n { params: { cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Iterate through all list members with automatic pagination.\n *\n * @param listId - The list ID.\n * @param options - Iteration options.\n * @yields User objects for each list member.\n */\n async *getMembersAll(\n listId: string,\n options: IteratorOptions = {}\n ): AsyncGenerator<User, void, undefined> {\n const fetchPage = async (cursor?: string): Promise<PageResult<User>> => {\n const { data, rateLimit } = await this.client.requestWithHeaders<{\n data?: User[];\n next_cursor?: string;\n }>(`/v1/twitter/lists/${listId}/members`, { params: { cursor } });\n return { response: createPaginatedResponse(data.data ?? [], data.next_cursor), rateLimit };\n };\n yield* paginate(fetchPage, options);\n }\n\n /**\n * Get subscribers of a list.\n *\n * @param listId - The list ID.\n * @param options - Pagination options with optional count.\n * @returns Paginated response containing list subscribers.\n */\n async getSubscribers(\n listId: string,\n options: PaginationOptions & { count?: number } = {}\n ): Promise<PaginatedResponse<User>> {\n const response = await this.client.request<{ data?: User[]; next_cursor?: string }>(\n `/v1/twitter/lists/${listId}/subscribers`,\n { params: { count: options.count ?? 20, cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Search for lists.\n *\n * @param query - Search query string.\n * @param options - Pagination options with optional count.\n * @returns Paginated response containing matching lists.\n *\n * @example\n * ```typescript\n * const results = await client.twitter.lists.search(\"tech leaders\");\n * for (const list of results.data) {\n * console.log(`${list.name}: ${list.member_count} members`);\n * }\n * ```\n */\n async search(\n query: string,\n options: PaginationOptions & { count?: number } = {}\n ): Promise<PaginatedResponse<List>> {\n const response = await this.client.request<{ data?: List[]; next_cursor?: string }>(\n \"/v1/twitter/lists/search\",\n { params: { query, count: options.count ?? 20, cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Get lists owned by the authenticated user.\n *\n * @param options - Pagination options with optional count.\n * @returns Paginated response containing the user's lists.\n */\n async getMyLists(\n options: PaginationOptions & { count?: number } = {}\n ): Promise<PaginatedResponse<List>> {\n const response = await this.client.request<{ data?: List[]; next_cursor?: string }>(\n \"/v1/twitter/lists/my_lists\",\n { params: { count: options.count ?? 100, cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n}\n","/**\n * Twitter Communities API client.\n *\n * Provides methods for fetching Twitter communities, members, and tweets.\n */\n\nimport type { BaseClient } from \"../internal/client.js\";\nimport type {\n PaginatedResponse,\n PaginationOptions,\n IteratorOptions,\n} from \"../internal/pagination.js\";\nimport { createPaginatedResponse, paginate } from \"../internal/pagination.js\";\nimport type { PageResult } from \"../internal/pagination.js\";\nimport type { Community, CommunityMember, CommunityTweetType, Tweet } from \"./types.js\";\n\n/**\n * Client for Twitter communities endpoints.\n *\n * Provides async methods for fetching community details, members,\n * moderators, and tweets.\n *\n * @example\n * ```typescript\n * const client = new ScrapeBadger({ apiKey: \"key\" });\n *\n * // Search communities\n * const communities = await client.twitter.communities.search(\"python\");\n *\n * // Get community details\n * const community = await client.twitter.communities.getDetail(\"123456\");\n * console.log(`${community.name}: ${community.member_count} members`);\n *\n * // Get community tweets\n * const tweets = await client.twitter.communities.getTweets(\"123456\");\n * ```\n */\nexport class CommunitiesClient {\n private readonly client: BaseClient;\n\n constructor(client: BaseClient) {\n this.client = client;\n }\n\n /**\n * Parse a community member from the API response.\n * Handles both flat format (user_id, username, role at top level)\n * and nested format (user object with id, username).\n */\n private parseCommunityMember(item: Record<string, unknown>): CommunityMember {\n if (\"user\" in item && item.user) {\n return item as unknown as CommunityMember;\n }\n // Flat format: map user_id -> id for User interface\n return {\n user: {\n id: (item.user_id as string) ?? \"\",\n username: (item.username as string) ?? \"\",\n name: (item.name as string) ?? \"\",\n profile_image_url: item.profile_image_url as string | undefined,\n verified: (item.verified as boolean) ?? false,\n is_blue_verified: item.is_blue_verified as boolean | undefined,\n },\n role: item.role as string | undefined,\n joined_at: item.joined_at as string | undefined,\n };\n }\n\n /**\n * Get details for a specific community.\n *\n * @param communityId - The community ID.\n * @returns The community details including rules and admin info.\n * @throws NotFoundError - If the community doesn't exist.\n *\n * @example\n * ```typescript\n * const community = await client.twitter.communities.getDetail(\"123456\");\n * console.log(`${community.name}`);\n * console.log(`Members: ${community.member_count?.toLocaleString()}`);\n * console.log(`Join policy: ${community.join_policy}`);\n *\n * if (community.rules) {\n * console.log(\"Rules:\");\n * for (const rule of community.rules) {\n * console.log(` - ${rule.name}`);\n * }\n * }\n * ```\n */\n async getDetail(communityId: string): Promise<Community> {\n return this.client.request<Community>(`/v1/twitter/communities/${communityId}`);\n }\n\n /**\n * Get tweets from a community.\n *\n * @param communityId - The community ID.\n * @param options - Options including tweet type, count, and pagination.\n * @returns Paginated response containing community tweets.\n *\n * @example\n * ```typescript\n * // Get top tweets\n * const tweets = await client.twitter.communities.getTweets(\"123456\");\n *\n * // Get latest tweets\n * const latest = await client.twitter.communities.getTweets(\"123456\", {\n * tweetType: \"Latest\"\n * });\n * ```\n */\n async getTweets(\n communityId: string,\n options: PaginationOptions & { tweetType?: CommunityTweetType; count?: number } = {}\n ): Promise<PaginatedResponse<Tweet>> {\n const response = await this.client.request<{ data?: Tweet[]; next_cursor?: string }>(\n `/v1/twitter/communities/${communityId}/tweets`,\n {\n params: {\n tweet_type: options.tweetType ?? \"Top\",\n count: options.count ?? 40,\n cursor: options.cursor,\n },\n }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Iterate through all community tweets with automatic pagination.\n *\n * @param communityId - The community ID.\n * @param options - Options including tweet type and iteration limits.\n * @yields Tweet objects from the community.\n */\n async *getTweetsAll(\n communityId: string,\n options: IteratorOptions & { tweetType?: CommunityTweetType } = {}\n ): AsyncGenerator<Tweet, void, undefined> {\n const fetchPage = async (cursor?: string): Promise<PageResult<Tweet>> => {\n const { data, rateLimit } = await this.client.requestWithHeaders<{\n data?: Tweet[];\n next_cursor?: string;\n }>(`/v1/twitter/communities/${communityId}/tweets`, {\n params: {\n tweet_type: options.tweetType ?? \"Top\",\n count: options.count ?? 40,\n cursor,\n },\n });\n return { response: createPaginatedResponse(data.data ?? [], data.next_cursor), rateLimit };\n };\n yield* paginate(fetchPage, options);\n }\n\n /**\n * Get members of a community.\n *\n * @param communityId - The community ID.\n * @param options - Pagination options with optional count.\n * @returns Paginated response containing community members.\n *\n * @example\n * ```typescript\n * const members = await client.twitter.communities.getMembers(\"123456\");\n * for (const member of members.data) {\n * console.log(`@${member.user.username} (${member.role})`);\n * }\n * ```\n */\n async getMembers(\n communityId: string,\n options: PaginationOptions & { count?: number } = {}\n ): Promise<PaginatedResponse<CommunityMember>> {\n const response = await this.client.request<{\n data?: Record<string, unknown>[];\n next_cursor?: string;\n }>(`/v1/twitter/communities/${communityId}/members`, {\n params: { count: options.count ?? 20, cursor: options.cursor },\n });\n\n const data: CommunityMember[] = (response.data ?? []).map((item) =>\n this.parseCommunityMember(item)\n );\n\n return createPaginatedResponse(data, response.next_cursor);\n }\n\n /**\n * Get moderators of a community.\n *\n * @param communityId - The community ID.\n * @param options - Pagination options with optional count.\n * @returns Paginated response containing community moderators.\n */\n async getModerators(\n communityId: string,\n options: PaginationOptions & { count?: number } = {}\n ): Promise<PaginatedResponse<CommunityMember>> {\n const response = await this.client.request<{\n data?: Record<string, unknown>[];\n next_cursor?: string;\n }>(`/v1/twitter/communities/${communityId}/moderators`, {\n params: { count: options.count ?? 20, cursor: options.cursor },\n });\n\n const data: CommunityMember[] = (response.data ?? []).map((item) =>\n this.parseCommunityMember(item)\n );\n\n return createPaginatedResponse(data, response.next_cursor);\n }\n\n /**\n * Search for communities.\n *\n * @param query - Search query string.\n * @param options - Pagination options.\n * @returns Paginated response containing matching communities.\n *\n * @example\n * ```typescript\n * const results = await client.twitter.communities.search(\"python developers\");\n * for (const community of results.data) {\n * console.log(`${community.name}: ${community.member_count} members`);\n * }\n * ```\n */\n async search(\n query: string,\n options: PaginationOptions = {}\n ): Promise<PaginatedResponse<Community>> {\n const response = await this.client.request<{ data?: Community[]; next_cursor?: string }>(\n \"/v1/twitter/communities/search\",\n { params: { query, cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Search for tweets within a community.\n *\n * @param communityId - The community ID.\n * @param query - Search query string.\n * @param options - Pagination options with optional count.\n * @returns Paginated response containing matching tweets.\n */\n async searchTweets(\n communityId: string,\n query: string,\n options: PaginationOptions & { count?: number } = {}\n ): Promise<PaginatedResponse<Tweet>> {\n const response = await this.client.request<{ data?: Tweet[]; next_cursor?: string }>(\n `/v1/twitter/communities/${communityId}/search_tweets`,\n { params: { query, count: options.count ?? 20, cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n\n /**\n * Get the community timeline (tweets from communities you're in).\n *\n * @param options - Pagination options with optional count.\n * @returns Paginated response containing community timeline tweets.\n */\n async getTimeline(\n options: PaginationOptions & { count?: number } = {}\n ): Promise<PaginatedResponse<Tweet>> {\n const response = await this.client.request<{ data?: Tweet[]; next_cursor?: string }>(\n \"/v1/twitter/communities/timeline\",\n { params: { count: options.count ?? 20, cursor: options.cursor } }\n );\n return createPaginatedResponse(response.data ?? [], response.next_cursor);\n }\n}\n","/**\n * Twitter Trends API client.\n *\n * Provides methods for fetching trending topics and trend locations.\n */\n\nimport type { BaseClient } from \"../internal/client.js\";\nimport type { PaginatedResponse } from \"../internal/pagination.js\";\nimport { createPaginatedResponse } from \"../internal/pagination.js\";\nimport type { Trend, TrendCategory, Location, PlaceTrends } from \"./types.js\";\n\n/**\n * Client for Twitter trends endpoints.\n *\n * Provides async methods for fetching trending topics, place-specific trends,\n * and available trend locations.\n *\n * @example\n * ```typescript\n * const client = new ScrapeBadger({ apiKey: \"key\" });\n *\n * // Get global trends\n * const trends = await client.twitter.trends.getTrends();\n * for (const trend of trends.data) {\n * console.log(`${trend.name}: ${trend.tweet_count || 'N/A'} tweets`);\n * }\n *\n * // Get trends for a specific location\n * const usTrends = await client.twitter.trends.getPlaceTrends(23424977);\n *\n * // Get available locations\n * const locations = await client.twitter.trends.getAvailableLocations();\n * ```\n */\nexport class TrendsClient {\n private readonly client: BaseClient;\n\n constructor(client: BaseClient) {\n this.client = client;\n }\n\n /**\n * Get trending topics.\n *\n * @param options - Options for filtering trends.\n * @returns Paginated response containing trending topics.\n *\n * @example\n * ```typescript\n * // Get general trending topics\n * const trends = await client.twitter.trends.getTrends();\n *\n * // Get news trends\n * const newsTrends = await client.twitter.trends.getTrends({\n * category: \"news\"\n * });\n *\n * for (const trend of trends.data) {\n * const count = trend.tweet_count?.toLocaleString() || \"N/A\";\n * console.log(`${trend.name}: ${count} tweets`);\n * }\n * ```\n */\n async getTrends(\n options: { category?: TrendCategory; count?: number } = {}\n ): Promise<PaginatedResponse<Trend>> {\n const response = await this.client.request<{ data?: Trend[] }>(\"/v1/twitter/trends/\", {\n params: {\n category: options.category ?? \"trending\",\n count: options.count ?? 20,\n },\n });\n return createPaginatedResponse(response.data ?? []);\n }\n\n /**\n * Get trends for a specific location.\n *\n * @param woeid - Where On Earth ID for the location.\n * Common WOEIDs:\n * - 1: Worldwide\n * - 23424977: United States\n * - 23424975: United Kingdom\n * - 23424856: Japan\n * - 23424829: Germany\n * @returns PlaceTrends containing location info and trends.\n * @throws NotFoundError - If the WOEID is invalid.\n *\n * @example\n * ```typescript\n * // Get US trends\n * const usTrends = await client.twitter.trends.getPlaceTrends(23424977);\n * console.log(`Trends in ${usTrends.name}:`);\n * for (const trend of usTrends.trends) {\n * console.log(` - ${trend.name}`);\n * }\n *\n * // Get worldwide trends\n * const globalTrends = await client.twitter.trends.getPlaceTrends(1);\n * ```\n */\n async getPlaceTrends(woeid: number): Promise<PlaceTrends> {\n return this.client.request<PlaceTrends>(`/v1/twitter/trends/place/${woeid}`);\n }\n\n /**\n * Get all locations where trends are available.\n *\n * @returns Paginated response containing available trend locations.\n *\n * @example\n * ```typescript\n * const locations = await client.twitter.trends.getAvailableLocations();\n *\n * // Filter by country\n * const usLocations = locations.data.filter(\n * loc => loc.country_code === \"US\"\n * );\n * console.log(`Found ${usLocations.length} US locations`);\n *\n * // Get countries only\n * const countries = locations.data.filter(\n * loc => loc.place_type === \"Country\"\n * );\n * ```\n */\n async getAvailableLocations(): Promise<PaginatedResponse<Location>> {\n const response = await this.client.request<{ data?: Location[] }>(\n \"/v1/twitter/trends/locations\"\n );\n return createPaginatedResponse(response.data ?? []);\n }\n}\n","/**\n * Twitter Geo API client.\n *\n * Provides methods for fetching geographic place information.\n */\n\nimport type { BaseClient } from \"../internal/client.js\";\nimport type { PaginatedResponse } from \"../internal/pagination.js\";\nimport { createPaginatedResponse } from \"../internal/pagination.js\";\nimport type { Place } from \"./types.js\";\n\n/**\n * Options for searching places.\n */\nexport interface GeoSearchOptions {\n /** Latitude coordinate */\n lat?: number;\n /** Longitude coordinate */\n long?: number;\n /** Free-form text search query (e.g., \"San Francisco\") */\n query?: string;\n /** IP address for location lookup */\n ip?: string;\n /** Result granularity (\"neighborhood\", \"city\", \"admin\", \"country\") */\n granularity?: string;\n /** Maximum number of results (1-100) */\n maxResults?: number;\n}\n\n/**\n * Client for Twitter geo/places endpoints.\n *\n * Provides async methods for fetching place details and searching\n * for geographic locations.\n *\n * @example\n * ```typescript\n * const client = new ScrapeBadger({ apiKey: \"key\" });\n *\n * // Search for places\n * const places = await client.twitter.geo.search({ query: \"San Francisco\" });\n *\n * // Search by coordinates\n * const nearby = await client.twitter.geo.search({ lat: 37.7749, long: -122.4194 });\n *\n * // Get place details\n * const place = await client.twitter.geo.getDetail(\"5a110d312052166f\");\n * ```\n */\nexport class GeoClient {\n private readonly client: BaseClient;\n\n constructor(client: BaseClient) {\n this.client = client;\n }\n\n /**\n * Get details for a specific place.\n *\n * @param placeId - The Twitter place ID.\n * @returns The place details.\n * @throws NotFoundError - If the place doesn't exist.\n *\n * @example\n * ```typescript\n * const place = await client.twitter.geo.getDetail(\"5a110d312052166f\");\n * console.log(`${place.full_name}`);\n * console.log(`Type: ${place.place_type}`);\n * console.log(`Country: ${place.country}`);\n * ```\n */\n async getDetail(placeId: string): Promise<Place> {\n return this.client.request<Place>(`/v1/twitter/geo/places/${placeId}`);\n }\n\n /**\n * Search for geographic places.\n *\n * At least one of lat/long, query, or ip must be provided.\n *\n * @param options - Search options.\n * @returns Paginated response containing matching places.\n * @throws ValidationError - If no search parameters are provided.\n *\n * @example\n * ```typescript\n * // Search by name\n * const places = await client.twitter.geo.search({ query: \"San Francisco\" });\n * for (const place of places.data) {\n * console.log(`${place.full_name} (${place.place_type})`);\n * }\n *\n * // Search by coordinates\n * const nearby = await client.twitter.geo.search({\n * lat: 37.7749,\n * long: -122.4194,\n * granularity: \"city\"\n * });\n *\n * // Search by IP\n * const ipPlaces = await client.twitter.geo.search({ ip: \"8.8.8.8\" });\n * ```\n */\n async search(options: GeoSearchOptions = {}): Promise<PaginatedResponse<Place>> {\n const response = await this.client.request<{ data?: Place[] }>(\"/v1/twitter/geo/search\", {\n params: {\n lat: options.lat,\n long: options.long,\n query: options.query,\n ip: options.ip,\n granularity: options.granularity,\n max_results: options.maxResults,\n },\n });\n return createPaginatedResponse(response.data ?? []);\n }\n}\n","/**\n * StreamClient -- stream monitor management and live WebSocket streaming.\n */\n\nimport { createHmac, timingSafeEqual } from \"node:crypto\";\nimport { EventEmitter } from \"node:events\";\nimport WebSocket from \"ws\";\nimport type { BaseClient } from \"../internal/client.js\";\nimport { WebSocketStreamError } from \"../internal/exceptions.js\";\nimport type {\n BillingLogList,\n ConnectOptions,\n ConnectedEvent,\n CreateMonitorParams,\n DeliveryLogList,\n ErrorEvent,\n FilterRuleCreate,\n FilterRuleDeliveryLogListResponse,\n FilterRuleListResponse,\n FilterRulePricingTiersResponse,\n FilterRuleResponse,\n FilterRuleUpdate,\n FilterRuleValidateResponse,\n PingEvent,\n StreamEvent,\n StreamMonitor,\n StreamMonitorList,\n StreamTweet,\n TweetEvent,\n UpdateMonitorParams,\n} from \"./stream-types.js\";\n\n// Minimum reconnect delay regardless of caller configuration (seconds)\nconst MIN_RECONNECT_DELAY_SECONDS = 5;\n\n/**\n * Derive WebSocket URL from HTTP base URL.\n * 'https://...' -> 'wss://...'\n * 'http://...' -> 'ws://...'\n */\nexport function wsUrlFromBase(baseUrl: string): string {\n if (baseUrl.startsWith(\"https://\")) {\n return baseUrl.replace(\"https://\", \"wss://\") + \"/v1/twitter/stream\";\n }\n if (baseUrl.startsWith(\"http://\")) {\n return baseUrl.replace(\"http://\", \"ws://\") + \"/v1/twitter/stream\";\n }\n return baseUrl + \"/v1/twitter/stream\";\n}\n\n/**\n * Map a raw server JSON object to a camelCase StreamEvent.\n * Unknown types return an ErrorEvent with code 0.\n */\nexport function parseEvent(raw: Record<string, unknown>): StreamEvent {\n const type = raw[\"type\"] as string | undefined;\n\n switch (type) {\n case \"connected\":\n return {\n type: \"connected\",\n connectionId: raw[\"connection_id\"] as string,\n apiKeyId: raw[\"api_key_id\"] as string,\n } satisfies ConnectedEvent;\n\n case \"ping\":\n return {\n type: \"ping\",\n timestamp: raw[\"timestamp\"] as string,\n } satisfies PingEvent;\n\n case \"tweet\":\n return {\n type: \"tweet\",\n monitorId: raw[\"monitor_id\"] as string,\n tweetId: raw[\"tweet_id\"] as string,\n authorUsername: raw[\"author_username\"] as string,\n tweetPublishedAt: raw[\"tweet_published_at\"] as string,\n detectedAt: raw[\"detected_at\"] as string,\n latencyMs: raw[\"latency_ms\"] as number,\n tweet: raw[\"tweet\"] as StreamTweet,\n } satisfies TweetEvent;\n\n case \"error\":\n return {\n type: \"error\",\n code: raw[\"code\"] as number,\n message: raw[\"message\"] as string,\n } satisfies ErrorEvent;\n\n default:\n return {\n type: \"error\",\n code: 0,\n message: `Unknown event type: ${String(type)}`,\n } satisfies ErrorEvent;\n }\n}\n\n/**\n * Typed EventEmitter for stream events.\n *\n * @example\n * ```typescript\n * const stream = client.twitter.stream.connect();\n * stream.on(\"tweet\", (event) => console.log(event.authorUsername));\n * stream.on(\"error\", (err) => console.error(err));\n * ```\n */\nexport interface StreamEmitter extends EventEmitter {\n on(event: \"connected\", listener: (event: ConnectedEvent) => void): this;\n on(event: \"ping\", listener: (event: PingEvent) => void): this;\n on(event: \"tweet\", listener: (event: TweetEvent) => void): this;\n on(event: \"error\", listener: (error: WebSocketStreamError) => void): this;\n on(event: \"close\", listener: () => void): this;\n\n once(event: \"connected\", listener: (event: ConnectedEvent) => void): this;\n once(event: \"tweet\", listener: (event: TweetEvent) => void): this;\n once(event: \"close\", listener: () => void): this;\n\n /** Gracefully close the WebSocket connection. */\n close(): void;\n}\n\n/**\n * Client for Twitter Streams -- monitor CRUD and live WebSocket streaming.\n *\n * Accessed as `client.twitter.stream`.\n *\n * @example Monitor CRUD\n * ```typescript\n * const monitor = await client.twitter.stream.createMonitor({\n * name: \"Tech Leaders\",\n * usernames: [\"elonmusk\", \"naval\"],\n * pollIntervalSeconds: 10,\n * });\n * console.log(`Created: ${monitor.id}, tier: ${monitor.pricing_tier}`);\n * ```\n *\n * @example EventEmitter streaming\n * ```typescript\n * const stream = client.twitter.stream.connect();\n * stream.on(\"tweet\", (event) => {\n * console.log(`@${event.authorUsername}: ${event.tweet.text}`);\n * console.log(` latency: ${event.latencyMs}ms`);\n * });\n * stream.on(\"error\", (err) => console.error(\"Stream error:\", err));\n * // Later:\n * stream.close();\n * ```\n *\n * @example AsyncIterator streaming\n * ```typescript\n * for await (const event of client.twitter.stream.connectIter()) {\n * if (event.type === \"tweet\") {\n * console.log(event.authorUsername, event.latencyMs);\n * }\n * }\n * ```\n */\nexport class StreamClient {\n private readonly client: BaseClient;\n\n constructor(client: BaseClient) {\n this.client = client;\n }\n\n // ===========================================================================\n // Monitor CRUD\n // ===========================================================================\n\n /**\n * Create a new stream monitor.\n *\n * @param params - Monitor configuration.\n * @returns The created StreamMonitor.\n * @throws InsufficientCreditsError - Credit balance below tier threshold (402).\n * @throws ValidationError - Invalid username or interval (422).\n * @throws ScrapeBadgerError - Name conflict (409).\n * @throws AuthenticationError - Invalid API key (401).\n *\n * @example\n * ```typescript\n * const monitor = await client.twitter.stream.createMonitor({\n * name: \"Breaking News\",\n * usernames: [\"cnnbrk\", \"bbcbreaking\"],\n * pollIntervalSeconds: 5,\n * });\n * ```\n */\n async createMonitor(params: CreateMonitorParams): Promise<StreamMonitor> {\n const body: Record<string, unknown> = {\n name: params.name,\n usernames: params.usernames,\n poll_interval_seconds: params.pollIntervalSeconds,\n };\n if (params.webhookUrl !== undefined) body[\"webhook_url\"] = params.webhookUrl;\n if (params.webhookSecret !== undefined) body[\"webhook_secret\"] = params.webhookSecret;\n\n return this.client.request<StreamMonitor>(\"/v1/twitter/stream/monitors\", {\n method: \"POST\",\n body,\n });\n }\n\n /**\n * List stream monitors for the authenticated API key.\n *\n * @param options - Filter and pagination options.\n * @returns StreamMonitorList with pagination metadata.\n *\n * @example\n * ```typescript\n * const { monitors, total } = await client.twitter.stream.listMonitors({\n * status: \"active\",\n * });\n * console.log(`${total} active monitors`);\n * ```\n */\n async listMonitors(options?: {\n status?: \"active\" | \"paused\" | \"error\";\n page?: number;\n pageSize?: number;\n }): Promise<StreamMonitorList> {\n const params: Record<string, string | number | boolean | undefined> = {\n page: options?.page ?? 1,\n page_size: options?.pageSize ?? 20,\n status: options?.status,\n };\n return this.client.request<StreamMonitorList>(\"/v1/twitter/stream/monitors\", {\n params,\n });\n }\n\n /**\n * Get a single stream monitor by ID.\n *\n * @param monitorId - UUID of the monitor.\n * @returns The StreamMonitor.\n * @throws NotFoundError - No monitor with that ID for this API key.\n *\n * @example\n * ```typescript\n * const monitor = await client.twitter.stream.getMonitor(\"550e8400-...\");\n * console.log(`${monitor.name}: ${monitor.status}`);\n * ```\n */\n async getMonitor(monitorId: string): Promise<StreamMonitor> {\n return this.client.request<StreamMonitor>(`/v1/twitter/stream/monitors/${monitorId}`);\n }\n\n /**\n * Partially update a stream monitor.\n *\n * Only fields that are explicitly set in params are sent to the server.\n *\n * @param monitorId - UUID of the monitor.\n * @param params - Fields to update (all optional).\n * @returns The updated StreamMonitor.\n * @throws NotFoundError - Monitor not found for this API key.\n * @throws InsufficientCreditsError - When resuming with insufficient credits.\n *\n * @example\n * ```typescript\n * const monitor = await client.twitter.stream.updateMonitor(\"550e8400-...\", {\n * pollIntervalSeconds: 60,\n * });\n * ```\n */\n async updateMonitor(monitorId: string, params: UpdateMonitorParams): Promise<StreamMonitor> {\n const body: Record<string, unknown> = {};\n if (params.name !== undefined) body[\"name\"] = params.name;\n if (params.usernames !== undefined) body[\"usernames\"] = params.usernames;\n if (params.pollIntervalSeconds !== undefined)\n body[\"poll_interval_seconds\"] = params.pollIntervalSeconds;\n if (params.status !== undefined) body[\"status\"] = params.status;\n if (params.webhookUrl !== undefined) body[\"webhook_url\"] = params.webhookUrl;\n if (params.webhookSecret !== undefined) body[\"webhook_secret\"] = params.webhookSecret;\n\n return this.client.request<StreamMonitor>(`/v1/twitter/stream/monitors/${monitorId}`, {\n method: \"PATCH\",\n body,\n });\n }\n\n /**\n * Pause an active stream monitor.\n *\n * Convenience wrapper around updateMonitor({ status: \"paused\" }).\n *\n * @param monitorId - UUID of the monitor.\n * @returns The updated StreamMonitor with status=\"paused\".\n */\n async pauseMonitor(monitorId: string): Promise<StreamMonitor> {\n return this.updateMonitor(monitorId, { status: \"paused\" });\n }\n\n /**\n * Resume a paused stream monitor.\n *\n * Convenience wrapper around updateMonitor({ status: \"active\" }).\n *\n * @param monitorId - UUID of the monitor.\n * @returns The updated StreamMonitor with status=\"active\".\n * @throws InsufficientCreditsError - If credits are below the tier threshold.\n */\n async resumeMonitor(monitorId: string): Promise<StreamMonitor> {\n return this.updateMonitor(monitorId, { status: \"active\" });\n }\n\n /**\n * Delete a stream monitor and all its associated logs. Irreversible.\n *\n * @param monitorId - UUID of the monitor.\n * @throws NotFoundError - Monitor not found for this API key.\n *\n * @example\n * ```typescript\n * await client.twitter.stream.deleteMonitor(\"550e8400-...\");\n * ```\n */\n async deleteMonitor(monitorId: string): Promise<void> {\n await this.client.request<void>(`/v1/twitter/stream/monitors/${monitorId}`, {\n method: \"DELETE\",\n });\n }\n\n // ===========================================================================\n // Delivery and Billing Logs\n // ===========================================================================\n\n /**\n * List tweet delivery logs.\n *\n * @param options - Filter and pagination options.\n * @returns DeliveryLogList with pagination metadata.\n */\n async listDeliveryLogs(options?: {\n monitorId?: string;\n authorUsername?: string;\n deliveryStatus?: string;\n page?: number;\n pageSize?: number;\n sort?: \"asc\" | \"desc\";\n }): Promise<DeliveryLogList> {\n const params: Record<string, string | number | boolean | undefined> = {\n page: options?.page ?? 1,\n page_size: options?.pageSize ?? 20,\n sort: options?.sort ?? \"desc\",\n monitor_id: options?.monitorId,\n author_username: options?.authorUsername,\n delivery_status: options?.deliveryStatus,\n };\n return this.client.request<DeliveryLogList>(\"/v1/twitter/stream/logs\", { params });\n }\n\n /**\n * List billing activity logs.\n *\n * @param options - Filter and pagination options.\n * @returns BillingLogList with pagination metadata.\n */\n async listBillingLogs(options?: {\n monitorId?: string;\n page?: number;\n pageSize?: number;\n }): Promise<BillingLogList> {\n const params: Record<string, string | number | boolean | undefined> = {\n page: options?.page ?? 1,\n page_size: options?.pageSize ?? 20,\n monitor_id: options?.monitorId,\n };\n return this.client.request<BillingLogList>(\"/v1/twitter/stream/billing-logs\", { params });\n }\n\n // ===========================================================================\n // Filter Rules CRUD\n // ===========================================================================\n\n /**\n * Create a new tweet filter rule.\n *\n * @param params - Filter rule configuration.\n * @returns The created FilterRuleResponse.\n * @throws ValidationError - Invalid query or interval (422).\n * @throws InsufficientCreditsError - Credit balance below tier threshold (402).\n * @throws AuthenticationError - Invalid API key (401).\n *\n * @example\n * ```typescript\n * const rule = await client.twitter.stream.createFilterRule({\n * tag: \"python news\",\n * query: \"#python lang:en -is:retweet\",\n * interval_seconds: 60,\n * });\n * console.log(`Created: ${rule.id}, tier: ${rule.pricing_tier}`);\n * ```\n */\n async createFilterRule(params: FilterRuleCreate): Promise<FilterRuleResponse> {\n const body: Record<string, unknown> = {\n tag: params.tag,\n query: params.query,\n interval_seconds: params.interval_seconds,\n };\n if (params.webhook_url !== undefined) body[\"webhook_url\"] = params.webhook_url;\n if (params.webhook_secret !== undefined) body[\"webhook_secret\"] = params.webhook_secret;\n if (params.max_results_per_poll !== undefined)\n body[\"max_results_per_poll\"] = params.max_results_per_poll;\n\n return this.client.request<FilterRuleResponse>(\"/v1/twitter/stream/filter-rules\", {\n method: \"POST\",\n body,\n });\n }\n\n /**\n * List filter rules for the authenticated API key.\n *\n * @param options - Filter and pagination options.\n * @returns FilterRuleListResponse with pagination metadata.\n *\n * @example\n * ```typescript\n * const { rules, total } = await client.twitter.stream.listFilterRules({\n * status: \"active\",\n * });\n * console.log(`${total} active rules`);\n * ```\n */\n async listFilterRules(options?: {\n status?: FilterRuleResponse[\"status\"];\n limit?: number;\n offset?: number;\n }): Promise<FilterRuleListResponse> {\n const params: Record<string, string | number | boolean | undefined> = {\n limit: options?.limit ?? 20,\n offset: options?.offset ?? 0,\n status: options?.status,\n };\n return this.client.request<FilterRuleListResponse>(\"/v1/twitter/stream/filter-rules\", {\n params,\n });\n }\n\n /**\n * Get a single filter rule by ID.\n *\n * @param ruleId - UUID of the filter rule.\n * @returns The FilterRuleResponse.\n * @throws NotFoundError - No rule with that ID for this API key.\n *\n * @example\n * ```typescript\n * const rule = await client.twitter.stream.getFilterRule(\"550e8400-...\");\n * console.log(`${rule.tag}: ${rule.status}`);\n * ```\n */\n async getFilterRule(ruleId: string): Promise<FilterRuleResponse> {\n return this.client.request<FilterRuleResponse>(`/v1/twitter/stream/filter-rules/${ruleId}`);\n }\n\n /**\n * Partially update a filter rule.\n *\n * Only fields that are explicitly set in params are sent to the server.\n *\n * @param ruleId - UUID of the filter rule.\n * @param params - Fields to update (all optional).\n * @returns The updated FilterRuleResponse.\n * @throws NotFoundError - Rule not found for this API key.\n * @throws ValidationError - Invalid field values (422).\n *\n * @example\n * ```typescript\n * const rule = await client.twitter.stream.updateFilterRule(\"550e8400-...\", {\n * interval_seconds: 120,\n * });\n * ```\n */\n async updateFilterRule(ruleId: string, params: FilterRuleUpdate): Promise<FilterRuleResponse> {\n const body: Record<string, unknown> = {};\n if (params.tag !== undefined) body[\"tag\"] = params.tag;\n if (params.query !== undefined) body[\"query\"] = params.query;\n if (params.interval_seconds !== undefined) body[\"interval_seconds\"] = params.interval_seconds;\n if (params.status !== undefined) body[\"status\"] = params.status;\n if (params.webhook_url !== undefined) body[\"webhook_url\"] = params.webhook_url;\n if (params.webhook_secret !== undefined) body[\"webhook_secret\"] = params.webhook_secret;\n if (params.max_results_per_poll !== undefined)\n body[\"max_results_per_poll\"] = params.max_results_per_poll;\n\n return this.client.request<FilterRuleResponse>(`/v1/twitter/stream/filter-rules/${ruleId}`, {\n method: \"PATCH\",\n body,\n });\n }\n\n /**\n * Delete a filter rule and all its associated logs. Irreversible.\n *\n * @param ruleId - UUID of the filter rule.\n * @throws NotFoundError - Rule not found for this API key.\n *\n * @example\n * ```typescript\n * await client.twitter.stream.deleteFilterRule(\"550e8400-...\");\n * ```\n */\n async deleteFilterRule(ruleId: string): Promise<void> {\n await this.client.request<void>(`/v1/twitter/stream/filter-rules/${ruleId}`, {\n method: \"DELETE\",\n });\n }\n\n // ===========================================================================\n // Filter Rules Utility\n // ===========================================================================\n\n /**\n * Validate a Twitter search query before creating a rule.\n *\n * @param query - The Twitter search query to validate.\n * @returns FilterRuleValidateResponse with validity and sample result count.\n *\n * @example\n * ```typescript\n * const result = await client.twitter.stream.validateFilterRuleQuery(\n * \"#python lang:en -is:retweet\"\n * );\n * if (!result.valid) {\n * console.error(\"Invalid query:\", result.error);\n * }\n * ```\n */\n async validateFilterRuleQuery(query: string): Promise<FilterRuleValidateResponse> {\n return this.client.request<FilterRuleValidateResponse>(\n \"/v1/twitter/stream/filter-rules/validate\",\n { method: \"POST\", body: { query } }\n );\n }\n\n /**\n * List tweet delivery logs for a specific filter rule.\n *\n * @param ruleId - UUID of the filter rule.\n * @param options - Filter and pagination options.\n * @returns FilterRuleDeliveryLogListResponse with pagination metadata.\n *\n * @example\n * ```typescript\n * const { logs, total } = await client.twitter.stream.listFilterRuleLogs(\n * \"550e8400-...\",\n * { limit: 50, deliveryStatus: \"webhook_delivered\" }\n * );\n * ```\n */\n async listFilterRuleLogs(\n ruleId: string,\n options?: {\n limit?: number;\n offset?: number;\n deliveryStatus?: string;\n sort?: \"asc\" | \"desc\";\n }\n ): Promise<FilterRuleDeliveryLogListResponse> {\n const params: Record<string, string | number | boolean | undefined> = {\n limit: options?.limit ?? 20,\n offset: options?.offset ?? 0,\n sort: options?.sort ?? \"desc\",\n delivery_status: options?.deliveryStatus,\n };\n return this.client.request<FilterRuleDeliveryLogListResponse>(\n `/v1/twitter/stream/filter-rules/${ruleId}/logs`,\n { params }\n );\n }\n\n /**\n * Get all available filter rule pricing tiers.\n *\n * @returns FilterRulePricingTiersResponse listing all tiers.\n *\n * @example\n * ```typescript\n * const { tiers } = await client.twitter.stream.getFilterRulePricingTiers();\n * tiers.forEach((t) => console.log(t.tier_label, t.credits_per_rule_per_day));\n * ```\n */\n async getFilterRulePricingTiers(): Promise<FilterRulePricingTiersResponse> {\n return this.client.request<FilterRulePricingTiersResponse>(\n \"/v1/twitter/stream/filter-rules-pricing\"\n );\n }\n\n // ===========================================================================\n // WebSocket Streaming -- EventEmitter style\n // ===========================================================================\n\n /**\n * Connect to the WebSocket stream and return an EventEmitter.\n *\n * The caller subscribes to events via `.on(\"tweet\", handler)`.\n * The SDK handles pong replies to server pings automatically.\n * Call `.close()` on the emitter to disconnect cleanly.\n *\n * If reconnect is true, the emitter automatically reconnects after\n * disconnects (other than auth failures). A new \"connected\" event is\n * emitted on each reconnect.\n *\n * @param options - Connection options (reconnect, delay, maxReconnects).\n * @returns StreamEmitter -- an EventEmitter subclass.\n *\n * @example\n * ```typescript\n * const stream = client.twitter.stream.connect();\n * stream.on(\"connected\", (e) => console.log(\"Connected:\", e.connectionId));\n * stream.on(\"tweet\", (event) => {\n * console.log(`@${event.authorUsername}: ${event.tweet.text}`);\n * console.log(` latency: ${event.latencyMs}ms`);\n * });\n * stream.on(\"error\", (err) => console.error(\"Stream error:\", err));\n * stream.on(\"close\", () => console.log(\"Stream closed\"));\n *\n * // Later:\n * stream.close();\n * ```\n */\n connect(options: ConnectOptions = {}): StreamEmitter {\n const { reconnect = false, reconnectDelaySeconds = 90, maxReconnects } = options;\n\n const delay = Math.max(MIN_RECONNECT_DELAY_SECONDS, reconnectDelaySeconds) * 1000;\n const wsUrl = wsUrlFromBase(this.client.config.baseUrl);\n const apiKey = this.client.config.apiKey;\n\n const emitter = new EventEmitter() as StreamEmitter;\n let ws: WebSocket | null = null;\n let closed = false;\n let reconnectCount = 0;\n\n const connectOnce = (): void => {\n ws = new WebSocket(wsUrl, { headers: { \"x-api-key\": apiKey } });\n\n ws.on(\"message\", (data: unknown) => {\n let raw: Record<string, unknown>;\n try {\n raw = JSON.parse(String(data)) as Record<string, unknown>;\n } catch {\n return;\n }\n\n const event = parseEvent(raw);\n\n if (event.type === \"ping\") {\n ws?.send(JSON.stringify({ type: \"pong\" }));\n emitter.emit(\"ping\", event);\n return;\n }\n\n if (event.type === \"error\") {\n const code = (event as ErrorEvent).code;\n const err = new WebSocketStreamError((event as ErrorEvent).message, code);\n emitter.emit(\"error\", err);\n if (code === 4001 || code === 4003) {\n closed = true; // Do not reconnect on auth/limit errors\n ws?.close();\n }\n return;\n }\n\n emitter.emit(event.type, event);\n });\n\n ws.on(\"open\", () => {\n // Connection is open; wait for \"connected\" event from server\n });\n\n ws.on(\"close\", (code: unknown, reason: unknown) => {\n if (closed) {\n emitter.emit(\"close\");\n return;\n }\n\n if (!reconnect) {\n const reasonStr = reason instanceof Buffer ? reason.toString() : String(reason ?? \"\");\n emitter.emit(\n \"error\",\n new WebSocketStreamError(`WebSocket closed: ${reasonStr || String(code)}`)\n );\n emitter.emit(\"close\");\n return;\n }\n\n if (maxReconnects !== undefined && reconnectCount >= maxReconnects) {\n emitter.emit(\n \"error\",\n new WebSocketStreamError(`Max reconnects (${maxReconnects}) exhausted`)\n );\n emitter.emit(\"close\");\n return;\n }\n\n reconnectCount++;\n setTimeout(connectOnce, delay);\n });\n\n ws.on(\"error\", (err: unknown) => {\n const message = err instanceof Error ? err.message : String(err);\n emitter.emit(\"error\", new WebSocketStreamError(message));\n });\n };\n\n // Attach close() method to emitter\n (emitter as unknown as { close: () => void }).close = (): void => {\n closed = true;\n ws?.close(1000, \"Client closed\");\n };\n\n connectOnce();\n return emitter;\n }\n\n // ===========================================================================\n // WebSocket Streaming -- AsyncIterator style\n // ===========================================================================\n\n /**\n * Connect to the WebSocket stream and return an AsyncIterator.\n *\n * Iterates over StreamEvent objects. The SDK handles pong replies\n * automatically but still yields PingEvent to the caller (the caller\n * may ignore ping events).\n *\n * @param options - Connection options (reconnect, delay, maxReconnects).\n * @yields StreamEvent\n *\n * @example\n * ```typescript\n * for await (const event of client.twitter.stream.connectIter()) {\n * if (event.type === \"tweet\") {\n * console.log(`@${event.authorUsername}: ${event.latencyMs}ms`);\n * }\n * }\n * ```\n *\n * @example With auto-reconnect\n * ```typescript\n * for await (const event of client.twitter.stream.connectIter({\n * reconnect: true,\n * reconnectDelaySeconds: 90,\n * })) {\n * if (event.type === \"tweet\") {\n * // process(event);\n * }\n * }\n * ```\n */\n async *connectIter(options: ConnectOptions = {}): AsyncIterableIterator<StreamEvent> {\n const { reconnect = false, reconnectDelaySeconds = 90, maxReconnects } = options;\n\n const delay = Math.max(MIN_RECONNECT_DELAY_SECONDS, reconnectDelaySeconds) * 1000;\n const wsUrl = wsUrlFromBase(this.client.config.baseUrl);\n const apiKey = this.client.config.apiKey;\n let reconnectCount = 0;\n\n while (true) {\n const events: StreamEvent[] = [];\n let resolveWait: (() => void) | null = null;\n let rejectWait: ((err: Error) => void) | null = null;\n let done = false;\n\n const ws = new WebSocket(wsUrl, { headers: { \"x-api-key\": apiKey } });\n\n const waitForEvent = (): Promise<void> =>\n new Promise<void>((res, rej) => {\n resolveWait = res;\n rejectWait = rej;\n });\n\n ws.on(\"message\", (data: unknown) => {\n let raw: Record<string, unknown>;\n try {\n raw = JSON.parse(String(data)) as Record<string, unknown>;\n } catch {\n return;\n }\n\n const event = parseEvent(raw);\n\n if (event.type === \"ping\") {\n ws.send(JSON.stringify({ type: \"pong\" }));\n }\n\n if (event.type === \"error\") {\n const code = (event as ErrorEvent).code;\n if (code === 4001 || code === 4003) {\n rejectWait?.(new WebSocketStreamError((event as ErrorEvent).message, code));\n rejectWait = null;\n resolveWait = null;\n return;\n }\n }\n\n events.push(event);\n resolveWait?.();\n resolveWait = null;\n rejectWait = null;\n });\n\n ws.on(\"close\", () => {\n done = true;\n resolveWait?.();\n resolveWait = null;\n rejectWait = null;\n });\n\n ws.on(\"error\", (err: unknown) => {\n const message = err instanceof Error ? err.message : String(err);\n rejectWait?.(new WebSocketStreamError(message));\n rejectWait = null;\n resolveWait = null;\n });\n\n try {\n while (!done || events.length > 0) {\n if (events.length === 0) {\n await waitForEvent();\n }\n while (events.length > 0) {\n yield events.shift()!;\n }\n }\n } catch (err) {\n ws.close();\n throw err;\n } finally {\n ws.close();\n }\n\n // Connection ended cleanly\n if (!reconnect) {\n return;\n }\n\n if (maxReconnects !== undefined && reconnectCount >= maxReconnects) {\n throw new WebSocketStreamError(`Max reconnects (${maxReconnects}) exhausted`);\n }\n\n reconnectCount++;\n await new Promise<void>((res) => setTimeout(res, delay));\n // Continue outer while loop for reconnect\n }\n }\n}\n\n/**\n * Verify the HMAC-SHA256 signature of an incoming webhook request.\n *\n * The server sets the header:\n * X-ScrapeBadger-Signature: sha256=<hex-digest>\n *\n * @param secret - The webhook secret configured on the monitor.\n * @param body - The raw request body string or Buffer.\n * @param signatureHeader - The full X-ScrapeBadger-Signature header value.\n * @returns true if the signature is valid.\n *\n * @example\n * ```typescript\n * // In an Express webhook receiver:\n * import { verifyWebhookSignature } from \"scrapebadger/twitter\";\n * import express from \"express\";\n *\n * app.post(\"/webhook\", express.raw({ type: \"application/json\" }), (req, res) => {\n * const sig = req.headers[\"x-scrapebadger-signature\"] as string;\n * if (!verifyWebhookSignature(\"my-secret\", req.body, sig)) {\n * return res.status(401).json({ error: \"Invalid signature\" });\n * }\n * const event = JSON.parse(req.body.toString());\n * // process event...\n * res.sendStatus(200);\n * });\n * ```\n */\nexport function verifyWebhookSignature(\n secret: string,\n body: string | Buffer,\n signatureHeader: string\n): boolean {\n if (!signatureHeader.startsWith(\"sha256=\")) {\n return false;\n }\n\n const expectedHex = signatureHeader.slice(\"sha256=\".length);\n const bodyBuffer = typeof body === \"string\" ? Buffer.from(body, \"utf-8\") : body;\n const actualHex = createHmac(\"sha256\", secret).update(bodyBuffer).digest(\"hex\");\n\n // Use constant-time comparison to prevent timing attacks\n try {\n return timingSafeEqual(Buffer.from(expectedHex, \"hex\"), Buffer.from(actualHex, \"hex\"));\n } catch {\n // Buffers of different lengths throw -- treat as mismatch\n return false;\n }\n}\n","/**\n * Twitter API client.\n *\n * Provides access to all Twitter API endpoints through specialized sub-clients.\n */\n\nimport type { BaseClient } from \"../internal/client.js\";\nimport { TweetsClient } from \"./tweets.js\";\nimport { UsersClient } from \"./users.js\";\nimport { ListsClient } from \"./lists.js\";\nimport { CommunitiesClient } from \"./communities.js\";\nimport { TrendsClient } from \"./trends.js\";\nimport { GeoClient } from \"./geo.js\";\nimport { StreamClient } from \"./stream.js\";\n\n/**\n * Twitter API client with access to all Twitter endpoints.\n *\n * Provides sub-clients for different resource types:\n * - `tweets` - Tweet operations (get, search, replies, retweeters, etc.)\n * - `users` - User operations (profiles, followers, following, search, etc.)\n * - `lists` - List operations (details, members, tweets, search, etc.)\n * - `communities` - Community operations (details, members, tweets, search, etc.)\n * - `trends` - Trending topics and locations\n * - `geo` - Geographic place information\n * - `stream` - Real-time stream monitor management and WebSocket streaming\n *\n * @example\n * ```typescript\n * const client = new ScrapeBadger({ apiKey: \"key\" });\n *\n * // Access tweets\n * const tweet = await client.twitter.tweets.getById(\"1234567890\");\n *\n * // Access users\n * const user = await client.twitter.users.getByUsername(\"elonmusk\");\n *\n * // Access trends\n * const trends = await client.twitter.trends.getTrends();\n *\n * // Search with automatic pagination\n * for await (const tweet of client.twitter.tweets.searchAll(\"python\")) {\n * console.log(tweet.text);\n * }\n *\n * // Stream live tweets\n * const stream = client.twitter.stream.connect();\n * stream.on(\"tweet\", (event) => console.log(event.authorUsername));\n * ```\n */\nexport class TwitterClient {\n /** Client for tweet operations */\n readonly tweets: TweetsClient;\n\n /** Client for user operations */\n readonly users: UsersClient;\n\n /** Client for list operations */\n readonly lists: ListsClient;\n\n /** Client for community operations */\n readonly communities: CommunitiesClient;\n\n /** Client for trends operations */\n readonly trends: TrendsClient;\n\n /** Client for geo/places operations */\n readonly geo: GeoClient;\n\n /** Client for real-time stream monitor management and WebSocket streaming */\n readonly stream: StreamClient;\n\n /**\n * Create a new Twitter client.\n *\n * @param client - The base HTTP client for making requests.\n */\n constructor(client: BaseClient) {\n this.tweets = new TweetsClient(client);\n this.users = new UsersClient(client);\n this.lists = new ListsClient(client);\n this.communities = new CommunitiesClient(client);\n this.trends = new TrendsClient(client);\n this.geo = new GeoClient(client);\n this.stream = new StreamClient(client);\n }\n}\n","/**\n * Web scraping API client for ScrapeBadger SDK.\n */\n\nimport type { BaseClient } from \"../internal/client.js\";\nimport type {\n ScrapeOptions,\n ScrapeResult,\n ScreenshotOptions,\n ScreenshotResult,\n ExtractOptions,\n ExtractResult,\n BatchOptions,\n BatchResult,\n SessionInfo,\n} from \"./types.js\";\n\n/**\n * Client for web scraping operations.\n *\n * @example\n * ```typescript\n * const client = new ScrapeBadger({ apiKey: \"key\" });\n *\n * // Simple scrape\n * const result = await client.web.scrape(\"https://example.com\");\n * console.log(result.content);\n *\n * // Screenshot\n * const screenshot = await client.web.screenshot(\"https://example.com\");\n *\n * // Extract structured data\n * const data = await client.web.extract(\"https://example.com\", {\n * schema: { title: \"css:h1\" }\n * });\n *\n * // Batch scrape\n * const batch = await client.web.batch([\"https://a.com\", \"https://b.com\"]);\n * ```\n */\nexport class WebClient {\n private readonly client: BaseClient;\n\n constructor(client: BaseClient) {\n this.client = client;\n }\n\n /**\n * Scrape a web page.\n */\n async scrape(url: string, options: ScrapeOptions = {}): Promise<ScrapeResult> {\n const body: Record<string, unknown> = { url };\n if (options.renderJs) body.render_js = true;\n if (options.outputFormat && options.outputFormat !== \"html\")\n body.output_format = options.outputFormat;\n if (options.proxyCountry) body.proxy_country = options.proxyCountry;\n if (options.proxyType) body.proxy_type = options.proxyType;\n if (options.sessionId) body.session_id = options.sessionId;\n if (options.engine) body.engine = options.engine;\n if (options.maxCost !== undefined) body.max_cost = options.maxCost;\n if (options.headers) body.headers = options.headers;\n if (options.waitFor) body.wait_for = options.waitFor;\n if (options.timeout !== undefined) body.timeout = options.timeout;\n if (options.jsScenario) body.js_scenario = options.jsScenario;\n\n return this.client.request<ScrapeResult>(\"/v1/web/scrape\", {\n method: \"POST\",\n body,\n });\n }\n\n /**\n * Take a screenshot of a web page.\n */\n async screenshot(\n url: string,\n options: ScreenshotOptions = {}\n ): Promise<ScreenshotResult> {\n const body: Record<string, unknown> = { url };\n if (options.fullPage) body.full_page = true;\n if (options.viewportWidth && options.viewportWidth !== 1280)\n body.viewport_width = options.viewportWidth;\n if (options.viewportHeight && options.viewportHeight !== 720)\n body.viewport_height = options.viewportHeight;\n if (options.imageFormat && options.imageFormat !== \"png\")\n body.image_format = options.imageFormat;\n if (options.waitFor) body.wait_for = options.waitFor;\n if (options.timeout !== undefined) body.timeout = options.timeout;\n\n return this.client.request<ScreenshotResult>(\"/v1/web/screenshot\", {\n method: \"POST\",\n body,\n });\n }\n\n /**\n * Extract structured data from a web page.\n */\n async extract(\n url: string,\n options: ExtractOptions = {}\n ): Promise<ExtractResult> {\n const body: Record<string, unknown> = { url };\n if (options.schema) body.extraction_schema = options.schema;\n if (options.renderJs) body.render_js = true;\n if (options.waitFor) body.wait_for = options.waitFor;\n if (options.timeout !== undefined) body.timeout = options.timeout;\n\n return this.client.request<ExtractResult>(\"/v1/web/extract\", {\n method: \"POST\",\n body,\n });\n }\n\n /**\n * Scrape multiple URLs in a batch.\n */\n async batch(\n urls: string[],\n options: BatchOptions = {}\n ): Promise<BatchResult> {\n const body: Record<string, unknown> = { urls };\n if (options.renderJs) body.render_js = true;\n if (options.outputFormat && options.outputFormat !== \"html\")\n body.output_format = options.outputFormat;\n if (options.maxConcurrency && options.maxConcurrency !== 5)\n body.max_concurrency = options.maxConcurrency;\n if (options.engine) body.engine = options.engine;\n if (options.timeout !== undefined) body.timeout = options.timeout;\n\n return this.client.request<BatchResult>(\"/v1/web/batch\", {\n method: \"POST\",\n body,\n });\n }\n\n /**\n * Create a new scraping session for a domain.\n */\n async createSession(domain: string, persist = true): Promise<SessionInfo> {\n return this.client.request<SessionInfo>(\"/v1/web/sessions\", {\n method: \"POST\",\n body: {\n domain,\n new_session: true,\n persist_session: persist,\n },\n });\n }\n\n /**\n * Scrape using an existing session.\n */\n async reuseSession(\n url: string,\n sessionId: string,\n options: ScrapeOptions = {}\n ): Promise<ScrapeResult> {\n return this.scrape(url, { ...options, sessionId });\n }\n}\n","/**\n * Main ScrapeBadger client.\n *\n * This is the primary entry point for the ScrapeBadger SDK.\n */\n\nimport { BaseClient } from \"./internal/client.js\";\nimport {\n type ScrapeBadgerConfig,\n resolveConfig,\n getApiKeyFromEnv,\n} from \"./internal/config.js\";\nimport { TwitterClient } from \"./twitter/client.js\";\nimport { WebClient } from \"./web/client.js\";\n\n/**\n * ScrapeBadger API client.\n *\n * The main client for interacting with the ScrapeBadger API.\n * Provides access to all available scrapers through typed sub-clients.\n *\n * @example\n * ```typescript\n * import { ScrapeBadger } from \"scrapebadger\";\n *\n * // Create client with API key\n * const client = new ScrapeBadger({ apiKey: \"your-api-key\" });\n *\n * // Or use environment variable (SCRAPEBADGER_API_KEY)\n * const client = new ScrapeBadger();\n *\n * // Access Twitter API\n * const tweet = await client.twitter.tweets.getById(\"1234567890\");\n * const user = await client.twitter.users.getByUsername(\"elonmusk\");\n *\n * // Search with automatic pagination\n * for await (const tweet of client.twitter.tweets.searchAll(\"python\")) {\n * console.log(tweet.text);\n * }\n *\n * // Collect all results into an array\n * import { collectAll } from \"scrapebadger\";\n * const tweets = await collectAll(\n * client.twitter.tweets.searchAll(\"python\", { maxItems: 100 })\n * );\n * ```\n */\nexport class ScrapeBadger {\n private readonly baseClient: BaseClient;\n\n /** Twitter API client */\n readonly twitter: TwitterClient;\n\n /** Web scraping API client */\n readonly web: WebClient;\n\n /**\n * Create a new ScrapeBadger client.\n *\n * @param config - Configuration options. If apiKey is not provided,\n * it will be read from the SCRAPEBADGER_API_KEY environment variable.\n * @throws Error if no API key is provided or found in environment.\n *\n * @example\n * ```typescript\n * // With explicit API key\n * const client = new ScrapeBadger({ apiKey: \"your-api-key\" });\n *\n * // With custom options\n * const client = new ScrapeBadger({\n * apiKey: \"your-api-key\",\n * baseUrl: \"https://custom.api.com\",\n * timeout: 60000,\n * maxRetries: 5\n * });\n *\n * // Using environment variable\n * // Set SCRAPEBADGER_API_KEY=your-api-key\n * const client = new ScrapeBadger();\n * ```\n */\n constructor(config: Partial<ScrapeBadgerConfig> = {}) {\n // Use provided API key or fall back to environment variable\n const apiKey = config.apiKey ?? getApiKeyFromEnv();\n\n if (!apiKey) {\n throw new Error(\n \"API key is required. Pass it in the config or set SCRAPEBADGER_API_KEY environment variable.\"\n );\n }\n\n const resolvedConfig = resolveConfig({ ...config, apiKey });\n this.baseClient = new BaseClient(resolvedConfig);\n\n // Initialize sub-clients\n this.twitter = new TwitterClient(this.baseClient);\n this.web = new WebClient(this.baseClient);\n }\n}\n"]}