Twitter

This is the general entrypoint for any application, constructed with Twitter()

class tweety.bot.Twitter(max_retries: int = 10, proxy: dict | Proxy | None = None)
__weakref__

list of weak references to the object (if defined)

Get the Trends from you locale

:return:list of .types.twDataTypes.Trends

get_tweets(username: str | int | User, pages: int = 1, replies: bool = False, retweets: bool = False, wait_time: int = 2, cursor: str | None = None)

Get the tweets from a user

Param:

username: (str | int | User) username of the user whom to get the tweets of

Param:

pages: (int) number of pages to be scraped

Param:

replies: (boolean) get the replied tweets of the user too

Param:

retweets: (boolean) get the retweets of the user too

Param:

wait_time: (int) seconds to wait between multiple requests

Param:

cursor: Pagination cursor if you want to get the pages from that cursor up-to (This cursor is different from actual API cursor)

Returns:

.types.usertweet.UserTweets

get_user_info(username: str, banner_extensions: bool = False, image_extensions: bool = False)

Get the User Info of the specified username

Parameters:
  • username – (str) username to get information of

  • banner_extensions – (boolean) Get the Banner extension on the user page

  • image_extensions – (boolean) Get the Image extension on the user page

Returns:

.types.twDataTypes.User

Search for a keyword or hashtag on Twitter

Parameters:
  • query – (str) The keyword which is supposed to be searched

  • pages – (int) The number of pages to get

  • search_filter – (str) The type of search to perform (Latest,user,photos,videos)

:param wait_time : (int) seconds to wait between multiple requests :param cursor: (str) Pagination cursor if you want to get the pages from that cursor up-to (This cursor is different from actual API cursor)

Returns:

list[.types.twDataTypes.Tweet]

iter_tweets(username: str | int | User, pages: int = 1, replies: bool = False, retweets: bool = False, wait_time: int = 2, cursor: str | None = None)

Generator for getting the tweets from a user

Param:

username: (str | int | User) username of the user whom to get the tweets of

Param:

pages: (int) number of pages to be scraped

Param:

replies: (boolean) get the replied tweets of the user too

Param:

wait_time: (int) seconds to wait between multiple requests

Param:

cursor: Pagination cursor if you want to get the pages from that cursor up-to (This cursor is different from actual API cursor)

Returns:

(.types.usertweet.UserTweets, list[.types.twDataTypes.Tweet])

search(query: str, search_filter: Literal['live', 'users', 'photos', 'videos'] = 'live', pages: int = 1, wait_time: int = 2, cursor: str | None = None)

Search for a keyword or hashtag on Twitter

Parameters:
  • query – (str) The keyword which is supposed to be searched

  • pages – (int) The number of pages to get

  • search_filter – (str) The type of search to perform (live,user,photos,videos)

:param wait_time : (int) seconds to wait between multiple requests :param cursor: (str) Pagination cursor if you want to get the pages from that cursor up-to (This cursor is different from actual API cursor)

Returns:

(.types.searchtweet.SearchTweet, list[.types.twDataTypes.Tweet])

tweet_detail(identifier: str)

Get Detail of a single tweet

Parameters:

identifier – (str) The unique identifier of the tweet , either the Tweet id or Tweet Link

Returns:

.types.twDataTypes.Tweet