### Start Vite Development Server Source: https://github.com/the-convocation/twitter-scraper/blob/main/examples/react-integration/README.md Run this command in the main project directory to start the Vite development server for the React application. ```bash yarn dev ``` -------------------------------- ### Install Dependencies Source: https://github.com/the-convocation/twitter-scraper/blob/main/examples/cycletls/README.md Install project dependencies using yarn. ```sh yarn install ``` -------------------------------- ### Start CORS Proxy Server Source: https://github.com/the-convocation/twitter-scraper/blob/main/examples/react-integration/README.md Run this command in the 'cors-proxy' directory to start the proxy server. This is necessary to bypass Twitter's CORS restrictions. ```bash yarn start ``` -------------------------------- ### Example FetchTransformOptions with CORS Proxy Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/types.md Demonstrates how to use FetchTransformOptions to route requests through a CORS proxy. This example modifies the request to prepend a proxy URL. ```typescript const scraper = new Scraper({ transform: { request(input, init) { // Route through CORS proxy const proxy = 'https://corsproxy.io/?'; const url = typeof input === 'string' ? input : input.toString(); return [proxy + encodeURIComponent(url), init]; }, response(res) { return res; } } }); ``` -------------------------------- ### Example: Get Latest Tweet Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/scraper.md Demonstrates how to fetch and log the text of the latest tweet from a user. ```typescript const latestTweet = await scraper.getLatestTweet('twitter'); if (latestTweet) { console.log(latestTweet.text); } ``` -------------------------------- ### WaitingRateLimitStrategy Example Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/rate-limit-strategy.md Demonstrates initializing the scraper with the WaitingRateLimitStrategy. This strategy may cause the scraper to block for up to 13 minutes if rate-limited. ```typescript import { Scraper, WaitingRateLimitStrategy } from '@the-convocation/twitter-scraper'; const scraper = new Scraper({ rateLimitStrategy: new WaitingRateLimitStrategy(), }); // This may block for up to 13 minutes if rate-limited const tweets = scraper.searchTweets('query', 100); ``` -------------------------------- ### Example: Get Single Tweet Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/scraper.md Shows how to retrieve a tweet by its ID and handle cases where the tweet might not exist. ```typescript const tweet = await scraper.getTweet('1234567890'); ``` -------------------------------- ### Example: Get First Retweet from Timeline Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/scraper.md Demonstrates using getTweetWhere to find the first retweet within a user's timeline. ```typescript const timeline = scraper.getTweets('twitter', 200); const retweet = await scraper.getTweetWhere(timeline, { isRetweet: true }); ``` -------------------------------- ### Install twitter-scraper with NPM Source: https://github.com/the-convocation/twitter-scraper/blob/main/README.md Use this command to add the twitter-scraper package to your Node.js project using NPM. ```sh npm install @the-convocation/twitter-scraper ``` -------------------------------- ### Install twitter-scraper with Yarn Source: https://github.com/the-convocation/twitter-scraper/blob/main/README.md Use this command to add the twitter-scraper package to your Node.js project using Yarn. ```sh yarn add @the-convocation/twitter-scraper ``` -------------------------------- ### Cookie Authentication with Fallback to Login Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/errors.md Example demonstrating how to set cookies for authentication and handle an AuthenticationError if the cookies are invalid, falling back to a password login. ```typescript import { Scraper, AuthenticationError } from '@the-convocation/twitter-scraper'; import { Cookie } from 'tough-cookie'; const scraper = new Scraper(); try { const cookies = loadStoredCookies(); await scraper.setCookies(cookies); const isLoggedIn = await scraper.isLoggedIn(); if (!isLoggedIn) { throw new AuthenticationError('Cookies expired'); } } catch (err) { if (err instanceof AuthenticationError) { console.log('Stored cookies invalid, logging in with password...'); await scraper.login(username, password); } } ``` -------------------------------- ### Default Guest Authentication Example Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/authentication.md Demonstrates using guest authentication by default when a Scraper instance is created without explicit login. Enables operations like fetching trends. ```typescript const scraper = new Scraper(); // Uses guest auth by default const trends = await scraper.getTrends(); ``` -------------------------------- ### Install CycleTLS for Bot Detection Bypass Source: https://github.com/the-convocation/twitter-scraper/blob/main/README.md Install the CycleTLS package to enable bypassing Cloudflare's advanced bot detection. This is necessary when standard Node.js TLS fingerprints are flagged as non-browser clients. ```sh npm install cycletls # or yarn add cycletls ``` -------------------------------- ### Search Profiles Example Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/README.md Iterate over user profiles matching a search query. The second argument specifies the maximum number of profiles to retrieve. ```typescript // Find profiles for await (const profile of scraper.searchProfiles('developer', 50)) { console.log(profile.username); } ``` -------------------------------- ### Install Authentication Headers to Request Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/authentication.md Adds necessary authentication headers, including Bearer token, guest token, cookies, and browser fingerprint, to an outgoing request. ```typescript installTo(headers: Headers, url: string, bearerTokenOverride?: string): Promise ``` -------------------------------- ### ErrorRateLimitStrategy Example Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/rate-limit-strategy.md Shows how to use the ErrorRateLimitStrategy and catch the ApiError to implement custom retry logic. The caller must manage the backoff process. ```typescript import { Scraper, ErrorRateLimitStrategy, ApiError } from '@the-convocation/twitter-scraper'; const scraper = new Scraper({ rateLimitStrategy: new ErrorRateLimitStrategy(), }); try { const tweets = scraper.searchTweets('query', 100); for await (const tweet of tweets) { // Process tweet } } catch (err) { if (err instanceof ApiError && err.response.status === 429) { console.error('Rate limited'); // Handle backoff in application logic } } ``` -------------------------------- ### SearchMode Examples Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/search.md Demonstrates different search modes for retrieving tweets, including Top, Latest, Photos, Videos, and Users (Profile Search). ```APIDOC ## Search Modes ### SearchMode.Top (Default) Returns most relevant tweets for the query (Twitter's ranking algorithm). ```typescript for await (const tweet of scraper.searchTweets('TypeScript', 100, SearchMode.Top)) { // Most relevant tweets } ``` ### SearchMode.Latest Returns most recent tweets, chronologically ordered. ```typescript for await (const tweet of scraper.searchTweets('breaking news', 100, SearchMode.Latest)) { // Newest tweets first } ``` ### SearchMode.Photos Returns tweets with attached images. ```typescript for await (const tweet of scraper.searchTweets('sunset', 100, SearchMode.Photos)) { console.log(tweet.photos); // Has photos } ``` ### SearchMode.Videos Returns tweets with videos or GIFs. ```typescript for await (const tweet of scraper.searchTweets('demo', 100, SearchMode.Videos)) { console.log(tweet.videos); // Has videos } ``` ### SearchMode.Users (Profile Search) Returns user profiles matching query. Only used with `searchProfiles()`. ```typescript // Example usage for profile search (assuming searchProfiles exists and uses SearchMode.Users) // const profiles = await scraper.searchProfiles('some user', 50, SearchMode.Users); ``` ``` -------------------------------- ### CycleTLS Entry Point Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/README.md An optional entry point for bypassing Cloudflare bot detection during the login process. This feature is Node.js specific and requires a separate installation of 'cycletls'. ```APIDOC ## CycleTLS Entry Point (`./cycletls`) Optional entry point for bypassing Cloudflare bot detection during login: ```typescript export { cycleTLSFetch, cycleTLSExit, initCycleTLSFetch }; ``` **Note:** Node.js only; requires separate `cycletls` installation. ``` -------------------------------- ### Cookie-Based Authentication Setup Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/configuration.md Load cookies from an authenticated browser session to authenticate the scraper. Ensure cookies are parsed correctly using 'tough-cookie'. ```typescript import { Cookie } from 'tough-cookie'; import { Scraper } from '@the-convocation/twitter-scraper'; const cookieString = 'ct0=abc123; auth_token=xyz789; lang=en'; const cookies = cookieString .split(';') .map(c => Cookie.parse(c)) .filter(Boolean); const scraper = new Scraper(); await scraper.setCookies(cookies); ``` -------------------------------- ### Get All Session Cookies Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/authentication.md Fetches all cookies currently stored in the session. ```typescript getCookies(): Promise ``` -------------------------------- ### Custom Rate-Limit Strategies - Exponential Backoff Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/rate-limit-strategy.md Example of implementing a custom rate-limit strategy using exponential backoff. This strategy increases the wait time exponentially after each rate limit event. ```APIDOC ### Example: Exponential Backoff ```typescript import { RateLimitStrategy, RateLimitEvent } from '@the-convocation/twitter-scraper'; class ExponentialBackoffStrategy implements RateLimitStrategy { private retryCount = 0; async onRateLimit(event: RateLimitEvent): Promise { const waitMs = Math.pow(2, this.retryCount) * 1000; console.log(`Rate limited. Waiting ${waitMs}ms...`); await new Promise(resolve => setTimeout(resolve, waitMs)); this.retryCount++; } } const scraper = new Scraper({ rateLimitStrategy: new ExponentialBackoffStrategy(), }); ``` ``` -------------------------------- ### Custom Rate-Limit Strategies - Queue-Based Retry Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/rate-limit-strategy.md Example of implementing a custom rate-limit strategy using a queue for retries. This strategy processes retry requests sequentially after a fixed delay. ```APIDOC ### Example: Queue-Based Retry ```typescript import { RateLimitStrategy, RateLimitEvent } from '@the-convocation/twitter-scraper'; class QueuedRateLimitStrategy implements RateLimitStrategy { private queue: (() => void)[] = []; private processing = false; async onRateLimit(event: RateLimitEvent): Promise { return new Promise(resolve => { this.queue.push(resolve); this.processQueue(); }); } private async processQueue() { if (this.processing) return; this.processing = true; while (this.queue.length > 0) { const callback = this.queue.shift(); if (callback) { // Wait before processing next await new Promise(r => setTimeout(r, 60000)); callback(); } } this.processing = false; } } ``` ``` -------------------------------- ### Custom Exponential Backoff Strategy Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/rate-limit-strategy.md An example of a custom rate limit strategy implementing exponential backoff. It increases the wait time exponentially with each retry. ```typescript import { RateLimitStrategy, RateLimitEvent } from '@the-convocation/twitter-scraper'; class ExponentialBackoffStrategy implements RateLimitStrategy { private retryCount = 0; async onRateLimit(event: RateLimitEvent): Promise { const waitMs = Math.pow(2, this.retryCount) * 1000; console.log(`Rate limited. Waiting ${waitMs}ms...`); await new Promise(resolve => setTimeout(resolve, waitMs)); this.retryCount++; } } const scraper = new Scraper({ rateLimitStrategy: new ExponentialBackoffStrategy(), }); ``` -------------------------------- ### Get Profiles a User is Following Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/scraper.md Retrieves profiles that a given user is following. This function returns an AsyncGenerator and requires authentication. ```typescript getFollowing(userId: string, maxProfiles: number): AsyncGenerator ``` -------------------------------- ### Get Profiles Following a User Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/scraper.md Retrieves profiles that are following a given user. This function returns an AsyncGenerator and requires authentication. ```typescript getFollowers(userId: string, maxProfiles: number): AsyncGenerator ``` -------------------------------- ### CycleTLS Entry Point Exports Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/README.md Exports for the optional CycleTLS entry point, used for bypassing Cloudflare bot detection during login. This is Node.js specific and requires a separate 'cycletls' installation. ```typescript export { cycleTLSFetch, cycleTLSExit, initCycleTLSFetch }; ``` -------------------------------- ### Fetching Paginated Tweets with Cursor Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/utilities.md Example of paginating through tweet search results using the `cursor` field from `QueryTweetsResponse`. The loop continues as long as a cursor is provided. ```typescript let cursor: string | undefined; do { const page = await scraper.fetchSearchTweets('query', 100, SearchMode.Top, cursor); processPage(page.tweets); cursor = page.cursor; } while (cursor); ``` -------------------------------- ### Catching and Handling ApiError Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/errors.md Example of how to catch an ApiError and access its response status, headers, and data. This is useful for debugging API-related issues. ```typescript import { Scraper, ApiError } from '@the-convocation/twitter-scraper'; const scraper = new Scraper(); try { const profile = await scraper.getProfile('nonexistent_user_12345'); } catch (err) { if (err instanceof ApiError) { console.error(`HTTP ${err.response.status}`); console.error('Headers:', err.response.headers); console.error('Body:', err.data); } } ``` -------------------------------- ### Configure Scraper with CORS Proxy Source: https://github.com/the-convocation/twitter-scraper/blob/main/README.md Configure the Scraper to use a CORS proxy for browser-based requests. This example uses corsproxy.io. ```ts const scraper = new Scraper({ transform: { request(input: RequestInfo | URL, init?: RequestInit) { // The arguments here are the same as the parameters to fetch(), and // are kept as-is for flexibility of both the library and applications. if (input instanceof URL) { const proxy = 'https://corsproxy.io/?' + encodeURIComponent(input.toString()); return [proxy, init]; } else if (typeof input === 'string') { const proxy = 'https://corsproxy.io/?' + encodeURIComponent(input); return [proxy, init]; } else { // Omitting handling for example throw new Error('Unexpected request input type'); } }, }, }); ``` -------------------------------- ### Search Tweets Example Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/README.md Iterate over tweets matching a search query. The second argument specifies the maximum number of tweets to retrieve. ```typescript // Find tweets for await (const tweet of scraper.searchTweets('TypeScript', 100)) { console.log(tweet.text); } ``` -------------------------------- ### Get Recent Direct Conversation Previews Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/direct-messages.md Retrieves a list of recent direct conversation previews, including participant names and conversation metadata. The number of conversations returned can be limited. ```typescript async function getConversationPreviews(scraper, limit = 10) { const inbox = await scraper.getDmInbox(); const conversations = []; for (const conversationId in inbox.conversations) { const conversation = inbox.conversations[conversationId]; const participants = conversation.participants .map(p => inbox.users[p.user_id]?.screen_name) .filter(Boolean); conversations.push({ id: conversationId, with: participants.join(', '), trusted: conversation.trusted, muted: conversation.muted, lastRead: conversation.last_read_event_id, }); if (conversations.length >= limit) break; } return conversations; } ``` -------------------------------- ### Next.js 13.x Example with CORS Proxy Source: https://github.com/the-convocation/twitter-scraper/blob/main/README.md Demonstrates integrating the twitter-scraper with a CORS proxy in a Next.js 13.x application. Fetches the latest tweet from a specified user. ```tsx 'use client'; import { Scraper, Tweet } from '@the-convocation/twitter-scraper'; import { useEffect, useMemo, useState } from 'react'; export default function Home() { const scraper = useMemo( () => new Scraper({ transform: { request(input: RequestInfo | URL, init?: RequestInit) { if (input instanceof URL) { const proxy = 'https://corsproxy.io/?' + encodeURIComponent(input.toString()); return [proxy, init]; } else if (typeof input === 'string') { const proxy = 'https://corsproxy.io/?' + encodeURIComponent(input); return [proxy, init]; } else { throw new Error('Unexpected request input type'); } }, }, }), [], ); const [tweet, setTweet] = useState(null); useEffect(() => { async function getTweet() { const latestTweet = await scraper.getLatestTweet('twitter'); if (latestTweet) { setTweet(latestTweet); } } getTweet(); }, [scraper]); return (
{tweet?.text}
); } ``` -------------------------------- ### Scraper Initialization and Configuration Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/README.md Demonstrates how to initialize the Scraper with various configuration options, including custom fetch functions, request/response transformations, rate limit strategies, and experimental features like browser profiling. ```APIDOC ## Scraper Initialization ### Description Initialize the Scraper with custom options to control its behavior, such as network requests, rate limiting, and experimental features. ### Method `new Scraper(options?: ScraperOptions)` ### Parameters #### Options (`ScraperOptions`) - `fetch` (Function) - Optional - Custom fetch function, useful for edge runtimes. - `transform` (Object) - Optional - Request/response interceptor for proxies, headers, etc. - `request(input, init)` - Function to transform outgoing requests. - `response(res)` - Function to transform incoming responses. - `rateLimitStrategy` (RateLimitStrategy) - Optional - Strategy for handling rate limits. Defaults to `WaitingRateLimitStrategy`. - `experimental` (Object) - Optional - Enables experimental features. - `xClientTransactionId` (boolean) - Default: `false` - Add transaction ID header. - `xpff` (boolean) - Default: `false` - Add XP-Forwarded-For header. - `flowStepDelay` (number) - Default: `2000` - Delay between login steps. - `browserProfile` (Object) - Configuration for Castle.io browser fingerprinting. - `locale` (string) - Browser locale. - `timezone` (string) - Browser timezone. - `screenWidth` (number) - Browser screen width. - `screenHeight` (number) - Browser screen height. - `...other fields auto-randomized` ### Request Example ```typescript import { Scraper, ErrorRateLimitStrategy } from 'twitter-scraper'; const scraper = new Scraper({ fetch: fetch, // For edge runtimes rateLimitStrategy: new ErrorRateLimitStrategy(), experimental: { xClientTransactionId: true, browserProfile: { locale: 'en-US', timezone: 'America/New_York', screenWidth: 1920, screenHeight: 1080 } } }); ``` ``` -------------------------------- ### Custom Queue-Based Retry Strategy Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/rate-limit-strategy.md An example of a custom rate limit strategy that uses a queue to manage retries, ensuring requests are processed sequentially after a delay. ```typescript import { RateLimitStrategy, RateLimitEvent } from '@the-convocation/twitter-scraper'; class QueuedRateLimitStrategy implements RateLimitStrategy { private queue: (() => void)[] = []; private processing = false; async onRateLimit(event: RateLimitEvent): Promise { return new Promise(resolve => { this.queue.push(resolve); this.processQueue(); }); } private async processQueue() { if (this.processing) return; this.processing = true; while (this.queue.length > 0) { const callback = this.queue.shift(); if (callback) { // Wait before processing next await new Promise(r => setTimeout(r, 60000)); callback(); } } this.processing = false; } } ``` -------------------------------- ### Run Project Tests Source: https://github.com/the-convocation/twitter-scraper/blob/main/README.md Execute the unit tests for the package. Ensure environment variables for authentication are configured before running. ```shell yarn test ``` -------------------------------- ### Import and Initialize Scraper with CycleTLS Source: https://github.com/the-convocation/twitter-scraper/blob/main/examples/cycletls/README.md Import Scraper and cycleTLSFetch, then initialize the Scraper with cycleTLSFetch to use Chrome-like TLS fingerprints for bypassing Cloudflare. ```typescript import { Scraper } from '@the-convocation/twitter-scraper'; import { cycleTLSFetch, cycleTLSExit } from '@the-convocation/twitter-scraper/cycletls'; const scraper = new Scraper({ fetch: cycleTLSFetch, }); ``` -------------------------------- ### getTweetsWhere Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/scraper.md Gets all tweets matching a query from a stream of tweets. ```APIDOC ## getTweetsWhere ### Description Gets all tweets matching a query from a stream of tweets. ### Method (Not specified, likely a function call in a library) ### Parameters #### Path Parameters - **tweets** (`AsyncIterable`) - yes - Stream of tweets to search - **query** (`TweetQuery`) - yes - Object with fields to match or predicate function ### Returns `Promise` — Array of matching Tweets ``` -------------------------------- ### Manual Guest Token Management Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/authentication.md Demonstrates checking for and using a guest token. Guest tokens are automatically refreshed, but this shows how to check if one is available before making requests. ```typescript const scraper = new Scraper(); // Guest token automatically generated on first request const profile = await scraper.getProfile('twitter'); // Token can be cleared if (scraper.hasGuestToken()) { // ... use scraper } ``` -------------------------------- ### getTweetWhere Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/scraper.md Gets the first tweet matching a query from a stream of tweets. ```APIDOC ## getTweetWhere ### Description Gets the first tweet matching a query from a stream of tweets. ### Method (Not specified, likely a function call in a library) ### Parameters #### Path Parameters - **tweets** (`AsyncIterable`) - yes - Stream of tweets to search - **query** (`TweetQuery`) - yes - Object with fields to match or predicate function ### Returns `Promise` — First matching Tweet or null ### Example ```typescript const timeline = scraper.getTweets('twitter', 200); const retweet = await scraper.getTweetWhere(timeline, { isRetweet: true }); ``` ``` -------------------------------- ### Constructor Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/scraper.md Creates a new Scraper instance with optional configuration for fetch, transforms, rate limiting, and experimental features. ```APIDOC ## Constructor ### Description Creates a new Scraper instance with optional configuration. ### Parameters #### Path Parameters (No path parameters) #### Query Parameters (No query parameters) #### Request Body (No request body) ### Parameters - **options** (`Partial`) - Optional - Configuration options for fetch, transforms, rate limiting, and experimental features ``` -------------------------------- ### Get Direct Message Messages Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/README.md Retrieves messages from a specific direct message conversation. ```APIDOC ## Get Direct Message Messages ### Description Fetch messages within a specific direct message conversation. Results are returned as an asynchronous iterable. ### Method `scraper.getDmMessages(conversationId: string)` ### Parameters - **conversationId** (string) - The unique identifier for the direct message conversation. ### Requirements Requires authentication. This method is part of the Direct Messages API surface. ### Response Returns an async iterable of `DmConversationTimeline` entries, each containing message data. ``` -------------------------------- ### Get Direct Message Inbox Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/README.md Retrieves all direct message conversations for the authenticated user. ```APIDOC ## Retrieve Inbox ### Description Fetch all direct message conversations for the currently authenticated user. ### Method `await scraper.getDmInbox()` ### Requirements Requires authentication. This method is part of the Direct Messages API surface. ### Response Returns a `DmInbox` object containing paginated conversation results. ``` -------------------------------- ### Batching Operations with Promise.all Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/utilities.md Illustrates how to improve performance for multiple sequential operations by using `Promise.all` for parallel execution. Be mindful of rate limits when using this approach. ```typescript // Instead of: for (const username of usernames) { const profile = await scraper.getProfile(username); // ... } // Consider batching with Promise.all() for parallel execution (with rate limit care) const profiles = await Promise.all( usernames.slice(0, 5).map(u => scraper.getProfile(u)) ); ``` -------------------------------- ### Configure Twitter Credentials Source: https://github.com/the-convocation/twitter-scraper/blob/main/examples/cycletls/README.md Set up your Twitter username, password, and email in a .env file for authentication. ```env TWITTER_USERNAME=your_username TWITTER_PASSWORD=your_password TWITTER_EMAIL=your_email ``` -------------------------------- ### getLikedTweets Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/scraper.md Gets tweets liked by a user. Requires authentication and yields Tweet objects asynchronously. ```APIDOC ## getLikedTweets ### Description Gets tweets liked by a user. Requires authentication. ### Method (Not specified, likely a function call in a library) ### Parameters #### Path Parameters - **user** (string) - yes - Username #### Query Parameters - **maxTweets** (number) - no - 200 - Maximum liked tweets to return ### Returns `AsyncGenerator` — Yields Tweet objects ### Throws `AuthenticationError` if not logged in ``` -------------------------------- ### getTrends Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/scraper.md Gets the current Twitter trends. Returns a promise that resolves to an array of trend names. ```APIDOC ## getTrends ### Description Gets current Twitter trends. ### Method Not specified (assumed to be a client-side SDK method) ### Endpoint Not applicable (SDK method) ### Parameters None ### Returns `Promise` — Array of current trend names ### Example ```typescript const trends = await scraper.getTrends(); console.log('Top trends:', trends.slice(0, 5)); ``` ``` -------------------------------- ### Basic Scraper Initialization Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/configuration.md Initialize the scraper with default options. ```typescript const scraper = new Scraper(); ``` -------------------------------- ### getTweets Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/scraper.md Gets tweets from a user's timeline. Returns an async generator yielding Tweet objects. ```APIDOC ## getTweets ### Description Gets tweets from a user's timeline. ### Method Not specified (assumed to be a client-side SDK method) ### Endpoint Not applicable (SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **user** (string) - Required - Username or user ID - **maxTweets** (number) - Optional - Maximum tweets to return (default: 200) ### Returns `AsyncGenerator` — Yields Tweet objects ### Example ```typescript for await (const tweet of scraper.getTweets('twitter', 100)) { console.log(tweet.text); } ``` ``` -------------------------------- ### Scraper Configuration Options Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/README.md Initialize the Scraper with custom options for fetch, request/response transformation, rate limiting, and experimental features. ```typescript new Scraper({ // Custom fetch function (edge runtimes) fetch: fetch, // Request/response interceptor (proxies, headers) transform: { request(input, init) { ... }, response(res) { ... } }, // Rate limit handling rateLimitStrategy: new ErrorRateLimitStrategy(), // Experimental features experimental: { xClientTransactionId: false, // Add transaction ID header xpff: false, // Add XP-Forwarded-For header flowStepDelay: 2000, // Delay between login steps browserProfile: { ... }, // Castle.io fingerprint } }) ``` -------------------------------- ### Get Authentication Timestamp Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/authentication.md Retrieves the date and time when the current authentication session was created or last refreshed. ```typescript authenticatedAt(): Date | null ``` -------------------------------- ### Enable XP-Forwarded-For Header Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/configuration.md Configure the experimental option to enable the generation of the 'x-xp-forwarded-for' header. This can help mitigate bot-detection errors. ```typescript experimental: { xpff: true, } ``` -------------------------------- ### Get Cookie Jar Instance Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/authentication.md Retrieves the underlying tough-cookie CookieJar instance for managing session cookies. ```typescript cookieJar(): CookieJar ``` -------------------------------- ### getLatestTweet Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/scraper.md Gets the most recent tweet from a user. Optionally includes retweets and specifies a maximum number of tweets to scan. ```APIDOC ## getLatestTweet ### Description Gets the most recent tweet from a user. ### Method (Not specified, likely a function call in a library) ### Parameters #### Path Parameters - **user** (string) - yes - Username #### Query Parameters - **includeRetweets** (boolean) - no - false - Whether to include retweets - **max** (number) - no - 200 - Maximum tweets to scan ### Returns `Promise` — The latest Tweet or null if none found ### Example ```typescript const latestTweet = await scraper.getLatestTweet('twitter'); if (latestTweet) { console.log(latestTweet.text); } ``` ``` -------------------------------- ### getTweetsAndRepliesByUserId Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/scraper.md Gets tweets and replies using a numeric user ID. This method yields Tweet objects asynchronously. ```APIDOC ## getTweetsAndRepliesByUserId ### Description Gets tweets and replies using a numeric user ID. ### Method (Not specified, likely a function call in a library) ### Parameters #### Path Parameters - **userId** (string) - yes - Numeric user ID #### Query Parameters - **maxTweets** (number) - no - 200 - Maximum tweets to return ### Returns `AsyncGenerator` — Yields Tweet objects ``` -------------------------------- ### Get Latest Tweet by Username Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/scraper.md Retrieves the most recent tweet posted by a user. Can optionally include retweets in the search. ```typescript getLatestTweet(user: string, includeRetweets?: boolean, max?: number): Promise ``` -------------------------------- ### Get Liked Tweets by Username Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/scraper.md Fetches tweets that a specified user has liked. Requires authentication to access this data. ```typescript getLikedTweets(user: string, maxTweets?: number): AsyncGenerator ``` -------------------------------- ### Basic Twitter Scraper Usage Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/README.md Demonstrates creating a scraper instance, fetching a profile, logging in for authenticated access, searching for tweets, retrieving liked tweets, and logging out. ```typescript import { Scraper } from '@the-convocation/twitter-scraper'; // Create scraper (guest mode) const scraper = new Scraper(); // Get a profile const profile = await scraper.getProfile('twitter'); console.log(profile.followersCount); // Login for authenticated access await scraper.login('username', 'password'); // Search for tweets for await (const tweet of scraper.searchTweets('TypeScript', 50)) { console.log(tweet.text); } // Get liked tweets for await (const tweet of scraper.getLikedTweets('twitter', 100)) { console.log(tweet.text); } // Logout await scraper.logout(); ``` -------------------------------- ### Scraper with Experimental Options Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/configuration.md Enable experimental features like `x-client-transaction-id`, `x-xp-forwarded-for` headers, and adjust the login flow step delay. ```typescript const scraper = new Scraper({ experimental: { xClientTransactionId: true, // Adds transaction IDs to requests xpff: true, // Adds XP-Forwarded-For header flowStepDelay: 1500, // 1.5 second delay between login steps }, }); ``` -------------------------------- ### getTweetsAndReplies Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/scraper.md Gets tweets and replies from a user's timeline. Returns an async generator yielding Tweet objects. ```APIDOC ## getTweetsAndReplies ### Description Gets tweets and replies from a user's timeline. ### Method Not specified (assumed to be a client-side SDK method) ### Endpoint Not applicable (SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **user** (string) - Required - Username - **maxTweets** (number) - Optional - Maximum tweets to return (default: 200) ### Returns `AsyncGenerator` — Yields Tweet objects (tweets and replies) ``` -------------------------------- ### getTweetsByUserId Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/scraper.md Gets tweets using a numeric user ID. Returns an async generator yielding Tweet objects. ```APIDOC ## getTweetsByUserId ### Description Gets tweets using a numeric user ID instead of username. ### Method Not specified (assumed to be a client-side SDK method) ### Endpoint Not applicable (SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **userId** (string) - Required - Numeric user ID - **maxTweets** (number) - Optional - Maximum tweets to return (default: 200) ### Returns `AsyncGenerator` — Yields Tweet objects ``` -------------------------------- ### Get Current Twitter Trends Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/scraper.md Retrieves an array of current Twitter trend names. This function does not require any parameters. ```typescript getTrends(): Promise ``` ```typescript const trends = await scraper.getTrends(); console.log('Top trends:', trends.slice(0, 5)); ``` -------------------------------- ### Basic User Login and Operation Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/authentication.md Perform a user login using username, password, and email, then proceed with authenticated operations like fetching liked tweets. ```typescript const scraper = new Scraper(); await scraper.login('username', 'password', 'email@example.com'); // Now can use authenticated operations const likedTweets = scraper.getLikedTweets('twitter', 100); ``` -------------------------------- ### Search Tweets by Latest (Chronological) Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/search.md Retrieves tweets in chronological order, starting with the most recent. Ideal for monitoring real-time events. ```typescript for await (const tweet of scraper.searchTweets('breaking news', 100, SearchMode.Latest)) { // Newest tweets first } ``` -------------------------------- ### Implement Logging Rate Limit Strategy Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/rate-limit-strategy.md Implement a custom rate limit strategy to log rate limit events, calculate wait times, and collect metrics. This strategy logs details about each rate limit event and the time spent waiting. ```typescript import { RateLimitStrategy, RateLimitEvent } from '@the-convocation/twitter-scraper'; class MetricsRateLimitStrategy implements RateLimitStrategy { private rateLimitCount = 0; private totalWaitTime = 0; async onRateLimit(event: RateLimitEvent): Promise { this.rateLimitCount++; const reset = event.response.headers.get('x-rate-limit-reset'); const limit = event.response.headers.get('x-rate-limit-limit'); const remaining = event.response.headers.get('x-rate-limit-remaining'); console.warn(`Rate limit event #${this.rateLimitCount}`); console.warn(` Limit: ${limit}`); console.warn(` Remaining: ${remaining}`); if (reset) { const waitMs = Math.max(0, parseInt(reset) * 1000 - Date.now()); console.warn(` Wait: ${(waitMs / 1000).toFixed(1)}s`); this.totalWaitTime += waitMs; await new Promise(r => setTimeout(r, waitMs)); } } getMetrics() { return { rateLimitCount: this.rateLimitCount, totalWaitTime: this.totalWaitTime, avgWaitTime: this.rateLimitCount > 0 ? this.totalWaitTime / this.rateLimitCount : 0, }; } } const strategy = new MetricsRateLimitStrategy(); const scraper = new Scraper({ rateLimitStrategy: strategy }); // Later... console.log('Metrics:', strategy.getMetrics()); ``` -------------------------------- ### Get Single Tweet by ID Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/scraper.md Fetches a specific tweet using its unique identifier. Returns null if the tweet is not found. ```typescript getTweet(id: string): Promise ``` -------------------------------- ### Manually Creating tough-cookie Objects Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/utilities.md Demonstrates how to manually create a `tough-cookie` `Cookie` object by providing its properties. This is useful for setting specific cookies programmatically. ```typescript // Create manually const cookie = new Cookie({ key: 'name', value: 'value', domain: 'x.com', path: '/', secure: true, httpOnly: true, }); ``` -------------------------------- ### initCycleTLSFetch Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/utilities.md Manually initializes a CycleTLS instance. This is typically called automatically by `cycleTLSFetch` but can be used for advanced use cases requiring direct control over the CycleTLS instance. ```APIDOC ## initCycleTLSFetch ### Description Manually initialize CycleTLS instance. ### Signature ```typescript export async function initCycleTLSFetch(): Promise ``` ### Returns - **Promise** — Initialized CycleTLS instance ### Note Automatically called by `cycleTLSFetch()`. Only needed for advanced use cases. ``` -------------------------------- ### fetchProfileFollowing Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/scraper.md Fetches a page of profiles that a user is following. Supports pagination with an optional cursor. ```APIDOC ## fetchProfileFollowing ### Description Fetches a page of profiles that a user is following. ### Method Not specified (assumed to be a client-side SDK method) ### Endpoint Not applicable (SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **userId** (string) - Required - User ID - **maxProfiles** (number) - Required - Profiles per page - **cursor** (string) - Optional - Pagination cursor ### Returns `Promise` — Page of profiles with cursor ``` -------------------------------- ### Get Direct Message Inbox Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/direct-messages.md Retrieves the direct message inbox containing all conversations. Ensure you are logged in before calling this method. ```typescript const scraper = new Scraper(); await scraper.login('username', 'password'); const inbox = await scraper.getDmInbox(); console.log(`Total conversations: ${Object.keys(inbox.conversations).length}`); // List all conversations for (const conversationId in inbox.conversations) { const conversation = inbox.conversations[conversationId]; const participants = conversation.participants .map(p => inbox.users[p.user_id]?.screen_name) .filter(Boolean); console.log(`Conversation with: ${participants.join(', ')}`); } ``` -------------------------------- ### Fetch Page of Profiles a User is Following Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/scraper.md Fetches a single page of profiles that a user is following. Supports pagination with a cursor. ```typescript fetchProfileFollowing(userId: string, maxProfiles: number, cursor?: string): Promise ``` -------------------------------- ### Enable Debug Logs Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/utilities.md Control the verbosity of debug logs using the `DEBUG` environment variable. Specify the module or sub-module to log. ```bash DEBUG=twitter-scraper:* node script.js DEBUG=twitter-scraper:scraper node script.js DEBUG=twitter-scraper:auth node script.js DEBUG=twitter-scraper:api node script.js DEBUG=twitter-scraper:rate-limit node script.js ``` -------------------------------- ### fetchProfileFollowers Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/scraper.md Fetches a page of profiles that follow a user. Supports pagination with an optional cursor. ```APIDOC ## fetchProfileFollowers ### Description Fetches a page of profiles that follow a user. ### Method Not specified (assumed to be a client-side SDK method) ### Endpoint Not applicable (SDK method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **userId** (string) - Required - User ID - **maxProfiles** (number) - Required - Profiles per page - **cursor** (string) - Optional - Pagination cursor ### Returns `Promise` — Page of profiles with cursor ``` -------------------------------- ### Configure Flow Step Delay Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/configuration.md Set the experimental 'flowStepDelay' to introduce delays between login steps, mimicking human-like timing. A value of 0 disables the delay. ```typescript experimental: { flowStepDelay: 2000, // 2 seconds } ``` -------------------------------- ### Get Specific Direct Message Conversation Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/scraper.md Retrieves the timeline of messages for a particular direct message conversation. Supports pagination using cursors. ```typescript getDmConversation(conversationId: string, cursor?: DmCursorOptions): Promise ``` -------------------------------- ### Get Tweets and Replies from a Timeline Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/scraper.md Retrieves both tweets and replies from a user's timeline. Supports specifying the maximum number of items to return. ```typescript getTweetsAndReplies(user: string, maxTweets?: number): AsyncGenerator ``` -------------------------------- ### Fetch Page of Profiles Following a User Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/scraper.md Fetches a single page of profiles that are following a user. Supports pagination with a cursor. ```typescript fetchProfileFollowers(userId: string, maxProfiles: number, cursor?: string): Promise ``` -------------------------------- ### WaitingRateLimitStrategy Default Usage Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/configuration.md Demonstrates the default behavior of the `WaitingRateLimitStrategy`, which automatically waits for rate-limit periods to expire. ```typescript // Default behavior const scraper = new Scraper(); ``` -------------------------------- ### Browser Fingerprinting Configuration Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/README.md Configures experimental browser fingerprinting options for bypassing bot detection during login. ```APIDOC ## Browser Fingerprinting ### Description Configure experimental settings for browser fingerprinting, specifically for generating Castle.io v11 fingerprint tokens to enhance login success rates and bypass bot detection. ### Method Initialize the `Scraper` with the `experimental.browserProfile` option. ### Parameters #### `experimental.browserProfile` Object - `locale` (string) - Sets the browser's locale (e.g., 'en-US'). - `timezone` (string) - Sets the browser's timezone (e.g., 'America/New_York'). - `screenWidth` (number) - Sets the browser's screen width resolution. - `screenHeight` (number) - Sets the browser's screen height resolution. - `...other fields` - Additional fields can be provided and are often auto-randomized by the library. ### Request Example ```typescript new Scraper({ experimental: { browserProfile: { locale: 'en-US', timezone: 'America/New_York', screenWidth: 1920, screenHeight: 1080 } } }); ``` ``` -------------------------------- ### Fetch Search Profiles Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/search.md Fetches a paginated list of user profiles matching a search query. Use the cursor to retrieve subsequent pages. ```typescript fetchSearchProfiles( query: string, maxProfiles: number, cursor?: string ): Promise ``` ```typescript let cursor: string | undefined; const allProfiles = []; do { const page = await scraper.fetchSearchProfiles('developer', 50, cursor); allProfiles.push(...(page.profiles || [])); cursor = page.cursor; } while (cursor && allProfiles.length < 200); ``` -------------------------------- ### Get All Matching Tweets from Stream Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/scraper.md Retrieves all tweets from an asynchronous stream that satisfy a specified query. Ideal for filtering and collecting multiple relevant tweets. ```typescript getTweetsWhere(tweets: AsyncIterable, query: TweetQuery): Promise ``` -------------------------------- ### Get Tweets and Replies by User ID Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/scraper.md Retrieves tweets and replies associated with a specific user ID. Useful for gathering all public activity from a user. ```typescript getTweetsAndRepliesByUserId(userId: string, maxTweets?: number): AsyncGenerator ``` -------------------------------- ### TwitterGuestAuth Class Constructor Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/authentication.md Initializes guest authentication using Twitter's public API tokens without requiring user credentials. Automatically refreshes guest tokens. ```typescript class TwitterGuestAuth implements TwitterAuth { constructor(bearerToken: string, options?: Partial); } ``` -------------------------------- ### Browser Fingerprinting Configuration Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/README.md Configure experimental browser fingerprinting options, such as locale, timezone, and screen dimensions, to bypass bot detection. ```typescript new Scraper({ experimental: { browserProfile: { locale: 'en-US', timezone: 'America/New_York', screenWidth: 1920, screenHeight: 1080, // ... other fields auto-randomized } } }) ``` -------------------------------- ### Custom Rate Limit Strategy Implementation Source: https://github.com/the-convocation/twitter-scraper/blob/main/README.md Implement a custom rate limit strategy by extending the RateLimitStrategy interface. This allows for custom logic when a rate limit event occurs. ```typescript import { Scraper, RateLimitStrategy } from '@the-convocation/twitter-scraper'; class CustomRateLimitStrategy implements RateLimitStrategy { async onRateLimit(event: RateLimitEvent): Promise { // your own logic... } } const scraper = new Scraper({ rateLimitStrategy: new CustomRateLimitStrategy(), }); ``` -------------------------------- ### File Organization Structure Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/INDEX.md This snippet shows the directory structure for the twitter-scraper library's documentation. It helps users locate specific documentation files for different aspects of the library. ```text output/ ├── README.md # Overview & navigation ├── INDEX.md # This file ├── types.md # Type definitions ├── configuration.md # Constructor options ├── errors.md # Error handling └── api-reference/ ├── scraper.md # Main Scraper class ├── authentication.md # Auth system ├── search.md # Search operations ├── direct-messages.md # DM retrieval ├── rate-limit-strategy.md # Rate limiting └── utilities.md # Helper functions ``` -------------------------------- ### Get Tweets from a User's Timeline Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/scraper.md Retrieves tweets from a user's timeline, yielding Tweet objects. Supports specifying the maximum number of tweets to return. ```typescript getTweets(user: string, maxTweets?: number): AsyncGenerator ``` ```typescript for await (const tweet of scraper.getTweets('twitter', 100)) { console.log(tweet.text); } ``` -------------------------------- ### DmCursorOptions Interface Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/types.md Defines pagination options for fetching direct messages. Use minId for newer messages and maxId for older messages. ```typescript interface DmCursorOptions { maxId?: string; minId?: string; } ``` -------------------------------- ### Detecting Missing Login with AuthenticationError Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/errors.md Shows how to catch an AuthenticationError, which is thrown when attempting to use authenticated methods without logging in first. ```typescript import { Scraper, AuthenticationError } from '@the-convocation/twitter-scraper'; const scraper = new Scraper(); try { const tweets = scraper.searchTweets('query', 100); for await (const tweet of tweets) { console.log(tweet.text); } } catch (err) { if (err instanceof AuthenticationError) { console.error('Authentication required'); // Prompt user to login } } ``` -------------------------------- ### Get First Matching Tweet from Stream Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/scraper.md Finds and returns the first tweet from an asynchronous stream that matches a given query. Useful for targeted searches within a large dataset. ```typescript getTweetWhere(tweets: AsyncIterable, query: TweetQuery): Promise ``` -------------------------------- ### BrowserProfile Interface Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/types.md Defines the structure for simulating browser environment values for fingerprinting. Use this to customize the browser's perceived characteristics. ```typescript interface BrowserProfile { locale: string; language: string; timezone: string; screenWidth: number; screenHeight: number; availableWidth: number; availableHeight: number; gpuRenderer: string; deviceMemoryGB: number; hardwareConcurrency: number; colorDepth: number; devicePixelRatio: number; } ``` -------------------------------- ### Get Tweets Using User ID Source: https://github.com/the-convocation/twitter-scraper/blob/main/_autodocs/api-reference/scraper.md Retrieves tweets from a user's timeline using their numeric user ID. Supports specifying the maximum number of tweets to return. ```typescript getTweetsByUserId(userId: string, maxTweets?: number): AsyncGenerator ```