Overview
TheGuestClient class provides unauthenticated access to public Twitter data. Itβs designed for read-only operations without requiring login credentials. All methods are asynchronous and must be executed using await.
GuestClient has limited functionality compared to the authenticated Client. It can only access public information and cannot perform write operations like posting tweets or sending DMs.
Initialization
The language code to use in API requests (e.g., βen-USβ, βja-JPβ).
The proxy server URL to use for requests (e.g., βhttp://0.0.0.0:8080β).
Activation
activate
Activates the client by generating a guest token. This must be called before making any API requests.The generated guest token.
User Operations
get_user_by_screen_name
Retrieves a user object based on the screen name (username).The screen name (username) of the user to retrieve.
User object containing user details.
get_user_by_id
Retrieves a user object based on the user ID.The ID of the user to retrieve.
User object containing user details.
Tweet Operations
get_user_tweets
Fetches tweets from a specific userβs public timeline.The ID of the Twitter user whose tweets to retrieve.
The type of tweets to retrieve. Currently only βTweetsβ is supported for guest access.
The number of tweets to retrieve.
List of Tweet objects.
Unlike the authenticated Client, GuestClient does not support pagination for tweets and returns a list instead of a Result object.
get_tweet_by_id
Fetches a single tweet by its ID.The ID of the tweet to retrieve.
Tweet object containing the tweet data.
get_user_highlights_tweets
Retrieves highlighted tweets from a userβs timeline.The user ID.
The number of tweets to retrieve.
Cursor for pagination.
Result object containing highlighted tweets with pagination support.
Limitations
TheGuestClient has several limitations compared to the authenticated Client:
Read-Only Access
- Cannot create, delete, or modify tweets
- Cannot follow/unfollow users
- Cannot like or retweet tweets
- Cannot send direct messages
- Cannot access private accounts or protected tweets
Limited Functionality
- No access to authenticated timeline (For You, Following)
- No access to bookmarks
- No access to notifications
- No access to direct messages
- Limited tweet search capabilities
- No access to trends
- Cannot access user lists
- Cannot access communities
Rate Limits
- Guest tokens may have stricter rate limits
- Guest sessions may expire more quickly
- Some endpoints may return less data
Example Usage
When to Use GuestClient
UseGuestClient when:
- You only need to read public data
- You donβt have Twitter credentials
- You want to build a read-only monitoring tool
- Youβre analyzing public tweets or user profiles
- You need to fetch public information without authentication
Client when:
- You need to post tweets or interact with content
- You need access to private or protected accounts
- You need to use authenticated endpoints
- You need access to your timeline, bookmarks, or DMs
- You need higher rate limits
Migration to Authenticated Client
If you need more functionality, you can easily migrate fromGuestClient to Client:
The API for common operations (like
get_user_by_screen_name and get_tweet_by_id) is the same between GuestClient and Client, making migration straightforward.