All Available Functions
This page contains all the public method available to work with
Attention
All methods requires user to be authenticated
Attention
All method’s examples assumes app
is authenticated instance of Twitter
Get User Info
Get User ID
Get User Tweets
- Twitter().get_tweets(username: str, pages: int = 1, replies: bool = False, wait_time: int = 2, cursor: str = None)
- Twitter().iter_tweets(username: str, 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 = app.get_tweets('elonmusk') for tweet in tweets: print(tweet)
Get User Medias
- Twitter().get_user_media(username: str, pages: int = 1, wait_time: int = 2, cursor: str = None)
Searching a Keyword
- Twitter().search(keyword: str, pages: int = 1, filter_: str = None, wait_time: int = 2, cursor: str = None)
- Twitter().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 = app.search('elonmusk') for tweet in tweets: print(tweet)
Get Trends
Get a Tweet Detail
Getting Home Timeline
- Twitter().get_home_timeline(timeline_type: str = "HomeTimeline", pages: int = 1, wait_time: int = 2, cursor: str = None)
- Twitter().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 = app.get_home_timeline(timeline_type=HOME_TIMELINE_TYPE_FOR_YOU) for tweet in tweets: print(tweet)
Getting Tweet Likes
- Twitter().get_tweet_likes(tweet_id: Union[str, Tweet] ,pages: int = 1, wait_time: int = 2, cursor: str = None)
- Twitter().iter_tweet_likes(tweet_id: Union[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 = app.tweet_detail("1232515235253352") likes = app.get_tweet_likes(tweet) for like in likes: print(like)
Getting Tweet Retweets
- Twitter().get_tweet_retweets(tweet_id: Union[str, Tweet] ,pages: int = 1, wait_time: int = 2, cursor: str = None)
- Twitter().iter_tweet_retweets(tweet_id: Union[str, Tweet] ,pages: int = 1, wait_time: int = 2, cursor: str = None)
Getting the Users who have Retweeted of Tweet (
iter
for generator)- Arguments
- Return
- Returns:
- Returns:
Generator: (
TweetRetweets
, list[Tweet
])
tweet = app.tweet_detail("1232515235253352") users = app.get_tweet_retweets(tweet) for user in users: print(user)
Getting Mentioned Tweets
- Twitter().get_mentions(pages: int = 1, wait_time: int = 2, cursor: str = None)
Getting Bookmarks
- Twitter().get_bookmarks(pages: int = 1, wait_time: int = 2, cursor: str = None)
Getting Inbox
- Twitter().get_inbox(user_id: Union[int, str, User] = None, cursor: str = None)
Getting the inbox of authenticated user
- Arguments
inbox = app.get_inbox() for conversation in inbox: print(conversation)
Sending Message
Creating a Tweet
- Twitter().create_tweet(text: str, files: list[Union[str, UploadedMedia, tuple[str, str]]] = None, filter_: str = None, reply_to: str = None, quote: str = None)
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 = 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
- Twitter().get_community_tweets(community_id: str, pages: int = 1, filter_: str = None, wait_time: int = 2, cursor: str = None)
- Twitter().iter_community_tweets(community_id: str, 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 = app.get_community_tweets(12345678) for tweet in tweets: print(tweet)
Get Community Members
- Twitter().get_community_members(community_id: str, pages: int = 1, filter_: str = None, wait_time: int = 2, cursor: str = None)
- Twitter().iter_community_members(community_id: str, 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 = app.get_community_members(12345678) for user in users: print(user)
Delete Tweet
Enable User Notifications
Disable User Notifications
Get Notified Tweets
- Twitter().get_tweet_notifications(pages: int = 1, wait_time: int = 2, cursor: str = None)
- Twitter().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 = app.get_tweet_notifications() for tweet in tweets: print(tweet)
Get User Followers
- Twitter().get_user_followers(username: str, pages: int = 1, wait_time: int = 2, cursor: str = None)
- Twitter().iter_user_followers(username: str, 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 = app.get_user_followers() for user in users: print(user)
Get User Followings
- Twitter().get_user_followings(username: str, pages: int = 1, wait_time: int = 2, cursor: str = None)
- Twitter().iter_user_followings(username: str, 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 = app.get_user_followings() for user in users: print(user)
Get Tweet Comments
- Twitter().get_tweet_comments(tweet_id: int, pages: int = 1, wait_time: int = 2, cursor: str = None, get_hidden: bool = False)
- Twitter().iter_tweet_comments(tweet_id: int, 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 = app.get_tweet_comments("123456789") for thread in threads: print(thread)
Get Lists
Create List
Delete List
Get List
Get List Tweets
- Twitter().get_list_tweets(list_id: int, pages: int = 1, wait_time: int = 2, cursor: str = None)
Get List Members
- Twitter().get_list_member(list_id: int, pages: int = 1, wait_time: int = 2, cursor: str = None)
Add List Member
Remove List Member
Get Topic
Get Topic Tweets
- Twitter().get_topic_tweets(topic_id: str, pages: int = 1, wait_time: int = 2, cursor: str = None)
- Twitter().iter_topic_tweets(topic_id: str, 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 = app.get_topic_tweets('123456') for tweet in tweets: print(tweet)
Get Tweet Analytics
Get Mutual Friends/Followers
- Twitter().get_mutual_followers(username: str, pages: int = 1, wait_time: int = 2, cursor: str = None)
- Twitter().iter_mutual_followers(username: str, 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 = app.get_mutual_followers('elonmusk') for user in users: print(user)
Get Blocked Users
- Twitter().get_blocked_users(pages: int = 1, wait_time: int = 2, cursor: str = None)