All Available Functions
This page contains all the public method available to work with
Attention
All methods requires user to be authenticated
Attention
All methods are async supported
Attention
All method’s examples assumes app
is authenticated instance of TwitterAsync
Get User Info
Get User ID
Get User Tweets
- async TwitterAsync.iter_tweets(username: str | int | User, pages: int = 1, replies: bool = False, wait_time: int = 2, cursor: str = None)
Get the Tweets of the specified username (
iter
for generator)- Arguments
- Return
- Returns:
- Returns:
Generator : (
UserTweets
, list[Tweet
])
tweets = await app.get_tweets('elonmusk') for tweet in tweets: print(tweet)
Get User Medias
Get User Highlights
- async TwitterAsync.iter_user_highlights(username: str | int | User, pages: int = 1, wait_time: int = 2, cursor: str = None)
Get the User Highlights of the specified username (
iter
for generator)- Arguments
- Return
- Returns:
- Returns:
Generator : (
UserHighlights
, list[Tweet
])
tweets = await app.get_user_highlights('elonmusk') for tweet in tweets: print(tweet)
Searching a Keyword
- async TwitterAsync.iter_search(keyword: str, pages: int = 1, filter_: str = None, wait_time: int = 2, cursor: str = None)
Search for a keyword or hashtag on Twitter (
iter
for generator)- Arguments
-
- filter_(optional): str = None
Filter you would like to apply on the search. More about Search Filters
tweets = await app.search('elonmusk') for tweet in tweets: print(tweet)
Get Trends
Get a Tweet Detail
Getting Home Timeline
- async TwitterAsync.iter_home_timeline(timeline_type: str = 'HomeTimeline', pages: int = 1, wait_time: int = 2, cursor: str = None)
Getting the Tweets from Home Page of Authenticated User (
iter
for generator)- Arguments
- Return
- Returns:
- Returns:
Generator: (
SelfTimeline
, list[Tweet
])
from tweety.types import HOME_TIMELINE_TYPE_FOR_YOU, HOME_TIMELINE_TYPE_FOLLOWING ... tweets = await app.get_home_timeline(timeline_type=HOME_TIMELINE_TYPE_FOR_YOU) for tweet in tweets: print(tweet)
Getting Tweet Likes
- async TwitterAsync.iter_tweet_likes(tweet_id: str | Tweet, pages: int = 1, wait_time: int = 2, cursor: str = None)
Getting the Users who have Likes of Tweet (
iter
for generator)- Arguments
- Return
- Returns:
- Returns:
Generator: (
TweetLikes
, list[Tweet
])
tweet = await app.tweet_detail("1232515235253352") likes = await app.get_tweet_likes(tweet) for like in likes: print(like)
Getting Tweet Retweets
- async TwitterAsync.iter_tweet_retweets(tweet_id: str | Tweet, pages: int = 1, wait_time: int = 2, cursor: str = None)
Getting the Users who have Retweeted the Tweet (
iter
for generator)- Arguments
- Return
- Returns:
- Returns:
Generator: (
TweetRetweets
, list[User
])
tweet = await app.tweet_detail("1232515235253352") users = await app.get_tweet_retweets(tweet) for user in users: print(user)
Getting Tweet Quotes
- async TwitterAsync.iter_tweet_quotes(tweet_id: str | Tweet, pages: int = 1, wait_time: int = 2, cursor: str = None)
Getting the Users who have Quoted the Tweet (
iter
for generator)- Arguments
tweet = await app.tweet_detail("1232515235253352") users = await app.get_tweet_quotes(tweet) for user in users: print(user)
Getting Mentioned Tweets
Getting Bookmarks
Getting Inbox
- async TwitterAsync.iter_inbox(user_id: int | str | User = None, pages: int = 1, wait_time: int = 2)
Getting the inbox of authenticated user (
iter
for generator)- Arguments
inbox = await app.get_inbox() for conversation in inbox: print(conversation)
Get a Conversation
Sending Message
- async TwitterAsync.send_message(username: str | int | User, text: str, file: str | UploadedMedia = None, in_group: bool = False, reply_to_message_id: int | str | Message = None, audio_only: bool = False, quote_tweet_id: str | int | Tweet = None)
Sending Message to a User
- Arguments
message = await app.send_message("user", "Hi")
Sending Message Reaction
- async TwitterAsync.send_message_reaction(reaction_emoji: str, message_id: str | int | Message, conversation_id: str | int | User | Conversation = None)
Sending Message to a User
- Arguments
-
- conversation_id: str | int | User | Conversation
ID of conversation in which reaction will be sent (Required if
message_id
isn’t instanceMessage
)
- Return
- Returns:
bool
await app.send_message_reaction("❤️", "123", "123-345")
Creating a Tweet
- async TwitterAsync.create_tweet(text: str, files: list[str | UploadedMedia | tuple[str, str]] = None, filter_: str = None, reply_to: str = None, quote: str = None, place: str | Place = None, batch_compose: bool = False, community_id: int | str | Community = None, post_on_timeline: bool = False)
Create a Tweet using the authenticated user
- Arguments
-
- files(optional): list[str | UploadedMedia | tuple[str, str]]
List of Filepath of the files to be sent
- filter_(optional)
- :type: str | TweetConversationFilters
Filter to be applied for Tweet Audience. More about Search Filters
message = await app.create_tweet("user", reply_to="1690430294208483322")
Liking the Tweet
Un-Liking the Tweet
Retweeting the Tweet
Delete a Retweet
Follow a User
UnFollow a User
Block a User
Un-Block a User
Get Community
Get Community Tweets
- async TwitterAsync.iter_community_tweets(community_id: str | int | Community, pages: int = 1, filter_: str = None, wait_time: int = 2, cursor: str = None)
Get the Tweets of the specified community (
iter
for generator)- Arguments
-
- filter_(optional): str = None
Filter you would like to apply on the tweets. More about Search Filters
- Return
- Returns:
- Returns:
Generator: (
CommunityTweets
, list[Tweet
])
from tweety import Twitter app = Twitter("session") tweets = await app.get_community_tweets(12345678) for tweet in tweets: print(tweet)
Get Community Members
- async TwitterAsync.iter_community_members(community_id: str | int | Community, pages: int = 1, filter_: str = None, wait_time: int = 2, cursor: str = None)
Get the Members of the specified community (
iter
for generator)- Arguments
-
- filter_(optional): str = None
Filter you would like to apply on the tweets. More about Search Filters
- Return
- Returns:
- Returns:
Generator: (
CommunityMembers
, list[User
])
from tweety import Twitter app = Twitter("session") users = await app.get_community_members(12345678) for user in users: print(user)
Delete Tweet
Enable User Notifications
Disable User Notifications
Get Notified Tweets
- async TwitterAsync.iter_tweet_notifications(pages: int = 1, wait_time: int = 2, cursor: str = None)
Get the Tweets of the user whom the authenticated user has enabled the New Tweet Notification , (use
iter
for generator)- Arguments
- Return
- Returns:
- Returns:
Generator: (
TweetNotifications
, list[Tweet
])
tweets = await app.get_tweet_notifications() for tweet in tweets: print(tweet)
Get User Followers
- async TwitterAsync.iter_user_followers(username: str | int | User, pages: int = 1, wait_time: int = 2, cursor: str = None)
Get the Followers of specified User , (use
iter
for generator)- Arguments
- Return
- Returns:
- Returns:
Generator: (
UserFollowers
, list[User
])
from tweety import Twitter app = Twitter("session") users = await app.get_user_followers() for user in users: print(user)
Get User Followings
- async TwitterAsync.iter_user_followings(username: str | int | User, pages: int = 1, wait_time: int = 2, cursor: str = None)
Get the Followings of specified User , (use
iter
for generator)- Arguments
- Return
- Returns:
- Returns:
Generator: (
UserFollowings
, list[User
])
from tweety import Twitter app = Twitter("session") users = await app.get_user_followings() for user in users: print(user)
Get User Subscribers
- async TwitterAsync.iter_user_subscribers(username: str | int | User, pages: int = 1, wait_time: int = 2, cursor: str = None)
Get the Subscribers of specified User , (use
iter
for generator)- Arguments
- Return
- Returns:
- Returns:
Generator: (
UserSubscribers
, list[User
])
from tweety import Twitter app = Twitter("session") users = await app.get_user_subscribers() for user in users: print(user)
Get Tweet Comments
- async TwitterAsync.iter_tweet_comments(tweet_id: int | str | Tweet, pages: int = 1, wait_time: int = 2, cursor: str = None, get_hidden: bool = False)
Get the Comments of specified Tweet , (use
iter
for generator)- Arguments
-
- cursor(optional): str = None
Pagination cursor if you want to get the pages from that cursor up-to (This cursor is different from actual API cursor)
Get hidden comments or not
- Return
- Returns:
- Returns:
Generator: (
TweetComments
, list[ConversationThread
])
from tweety import Twitter app = Twitter("session") threads = await app.get_tweet_comments("123456789") for thread in threads: print(thread)
Get Lists
Create List
Delete List
Get List
Get List Tweets
- async TwitterAsync.iter_list_tweets(list_id: str | int | TwList, pages: int = 1, wait_time: int = 2, cursor: str = None)
Get Tweets of specific List (
iter
for generator)- Arguments
- Return
- Returns:
- Returns:
Generator: (
ListTweets
, list[Tweet
])
tweets = await app.get_list_tweets("123515") for tweet in tweets: print(tweet)
Get List Members
- async TwitterAsync.iter_list_member(list_id: str | int | TwList, pages: int = 1, wait_time: int = 2, cursor: str = None)
Get Tweets of specific List (
iter
for generator)- Arguments
- Return
- Returns:
- Returns:
Generator: (
ListMembers
, list[User
])
users = await app.get_list_member("123515") for user in users: print(user)
Add List Member
Remove List Member
Get Topic
Get Topic Tweets
- async TwitterAsync.iter_topic_tweets(topic_id: str | int | Topic, pages: int = 1, wait_time: int = 2, cursor: str = None)
Get the Tweets of the specified Topic (
iter
for generator)- Arguments
- Return
- Returns:
- Returns:
Generator : (
TopicTweets
, list[Tweet
])
tweets = await app.get_topic_tweets('123456') for tweet in tweets: print(tweet)
Get Tweet Analytics
Get Mutual Friends/Followers
- async TwitterAsync.iter_mutual_followers(username: str | int | User, pages: int = 1, wait_time: int = 2, cursor: str = None)
Get the Mutual Followers/Friends of a User (
iter
for generator)- Arguments
- Return
- Returns:
- Returns:
Generator : (
MutualFollowers
, list[User
])
users = await app.get_mutual_followers('elonmusk') for user in users: print(user)
Get Blocked Users
- async TwitterAsync.iter_blocked_users(pages: int = 1, wait_time: int = 2, cursor: str = None)
Get the users blocked by authenticated user (
iter
for generator)- Arguments
- Return
- Returns:
- Returns:
Generator : (
BlockedUsers
, list[User
])
users = await app.get_blocked_users() for user in users: print(user)
Get Translated Tweet
Get Tweet History
Search Gifs
Get Scheduled Tweets
Delete Scheduled Tweets
- async TwitterAsync.delete_scheduled_tweet(tweet_id: str | int | ScheduledTweet)
Get the Scheduled Tweets of authenticated User
- Arguments
- tweet_id: str | int | ScheduledTweet
ID of scheduled Tweet
- Return
- Returns:
bool
await app.delete_scheduled_tweet("12345")
Pin a Tweet
Un-Pin a Tweet
New Grok Conversation
Get Grok Conversation
Get Grok Response
- async TwitterAsync.get_grok_response(text: str, conversation_id: str | int | GrokConversation = None)
Get Response against your prompt from GROK
- Arguments
-
- conversation_id: str | int | GrokConversation
Continuing previous conversation
- Return
- Returns:
(GrokMessage, GrokConversation)
await app.get_grok_response("Hi , draw a robot")