Overview
TheUser class represents a Twitter/X user profile and provides methods for following, blocking, retrieving tweets, and more.
User Class
Attributes
The unique identifier of the user.
The date and time when the user account was created.
The created_at converted to datetime object.
The user’s display name.
The user’s screen name (handle without @).
The URL of the user’s profile image (HTTPS version).
The URL of the user’s profile banner.
The user’s URL.
The user’s location information.
The user’s profile description (bio).
URLs found in the user’s profile description.
URLs associated with the user.
The IDs of tweets that the user has pinned to their profile.
Indicates if the user is verified with a blue checkmark (Twitter Blue).
Indicates if the user is verified (legacy verification).
Indicates if the user’s content may be sensitive.
Indicates whether the user can receive direct messages.
Indicates whether the user can be tagged in media.
Indicates if the user wants retweets.
Indicates if the user has the default profile.
Indicates if the user has the default profile image.
Indicates if the user has custom timelines.
The count of followers.
The count of fast followers.
The count of normal followers.
The count of users the user is following.
The count of favorites or likes.
The count of lists the user is a member of.
The count of media items associated with the user.
The count of tweets.
Indicates if the user is a translator.
The type of translator.
Countries where the user’s content is withheld.
Indicates if the user’s tweets are protected (private account).
Methods
get_tweets()
Retrieves the user’s tweets.The type of tweets to retrieve.
The number of tweets to retrieve.
Result[Tweet] - A Result object containing a list of Tweet objects.
follow()
Follows the user. Returns:httpx.Response
unfollow()
Unfollows the user. Returns:httpx.Response
block()
Blocks the user. Returns:httpx.Response
unblock()
Unblocks the user. Returns:httpx.Response
mute()
Mutes the user. Returns:httpx.Response
unmute()
Unmutes the user. Returns:httpx.Response
get_followers()
Retrieves a list of followers for the user.The number of followers to retrieve.
Result[User] - A list of User objects representing the followers.
get_verified_followers()
Retrieves a list of verified followers for the user.The number of verified followers to retrieve.
Result[User] - A list of User objects representing the verified followers.
get_followers_you_know()
Retrieves a list of followers whom the user might know.The number of followers you might know to retrieve.
Result[User] - A list of User objects representing the followers you might know.
get_following()
Retrieves a list of users whom the user is following.The number of following users to retrieve.
Result[User] - A list of User objects representing the users being followed.
get_subscriptions()
Retrieves a list of users whom the user is subscribed to.The number of subscriptions to retrieve.
Result[User] - A list of User objects representing the subscribed users.
get_latest_followers()
Retrieves the latest followers. Max count: 200.The number of followers to retrieve.
The cursor for pagination.
Result[User]
get_latest_friends()
Retrieves the latest friends (following users). Max count: 200.The number of friends to retrieve.
The cursor for pagination.
Result[User]
send_dm()
Send a direct message to the user.The text content of the direct message.
The media ID associated with any media content to be included in the message. Media ID can be received by using the
upload_media method.Message ID to reply to.
Message - Message object containing information about the message sent.
get_dm_history()
Retrieves the DM conversation history with the user.If specified, retrieves messages older than the specified max_id.
Result[Message] - A Result object containing a list of Message objects representing the DM conversation history.
get_highlights_tweets()
Retrieves highlighted tweets from the user’s timeline.The number of tweets to retrieve.
The cursor for pagination.
Result[Tweet] - An instance of the Result class containing the highlighted tweets.
