-
Notifications
You must be signed in to change notification settings - Fork 4
4. API Reference
This section of the documentation serves as a comprehensive guide to the classes, methods, and models available in PyTweetToolkit. Here, you can find detailed information on how to use the toolkit to interact with Twitter.
- Brief description of the API
- Authentication requirements
- Rate limiting and best practices
The BookmarkActions class in PyTweetToolkit is dedicated to managing Twitter bookmarks. This class allows users to bookmark tweets, remove bookmarks, and retrieve a list of bookmarked tweets using Twitter's GraphQL API. It inherits from an authentication base class for necessary credentials handling.
Rate Limits:
-
bookmark_tweet: 500 actions per 15-minute window -
unbookmark_tweet: 500 actions per 15-minute window -
get_bookmarks: 500 actions per 15-minute window
Methods:
-
bookmark_tweet(self, tweet_id: str) -> tweet_model.TweetBookmarks a specified tweet.
-
Parameters:
tweet_id(str) - The ID of the tweet to bookmark. -
Returns:
tweet_model.Tweet- An instance representing the bookmarked tweet. - Raises: HTTP errors or specific exceptions based on API response.
- Rate Limit: 500 actions per 15 minutes.
-
Parameters:
-
unbookmark_tweet(self, tweet_id: str) -> tweet_model.TweetRemoves a bookmark from a specified tweet.
-
Parameters:
tweet_id(str) - The ID of the tweet to unbookmark. -
Returns:
tweet_model.Tweet- An instance representing the tweet post-unbookmark. - Raises: HTTP errors or specific exceptions based on API response.
- Rate Limit: 500 actions per 15 minutes.
-
Parameters:
-
get_bookmarks(self, cursor: str = "") -> tuple[list[tweet_model.Tweet], str, str]Fetches a list of bookmarked tweets, with pagination support.
-
Parameters:
cursor(str, optional) - Pagination cursor for bookmark retrieval. -
Returns:
tuple[list[tweet_model.Tweet], str, str]- A tuple containing a list of bookmarked tweets, the next cursor, and the previous cursor. - Raises: HTTP errors or specific exceptions based on API response.
- Rate Limit: 500 actions per 15 minutes.
-
Parameters:
The FriendshipActions class in PyTweetToolkit handles various actions related to Twitter friendships. This includes following and unfollowing users, as well as managing follow requests, all through Twitter's API. It uses authentication from the base class for API requests.
Rate Limits: These actions adhere to Twitter's standard API rate limits.
Methods:
-
follow_user(self, user_id: str) -> user_model.UserInitiates following a user by their ID and returns details about the followed user.
-
Parameters:
user_id(str) - The ID of the user to follow. -
Returns:
user_model.User- Details of the followed user. - Rate Limit: Subject to Twitter's standard API rate limits.
-
Parameters:
-
unfollow_user(self, user_id: str) -> user_model.UserStops following a user by their ID and returns details about the unfollowed user.
-
Parameters:
user_id(str) - The ID of the user to unfollow. -
Returns:
user_model.User- Details of the unfollowed user. - Rate Limit: Subject to Twitter's standard API rate limits.
-
Parameters:
-
follow_requests(self, user_id: str) -> list[user_model.User]Retrieves a list of users who have requested to follow the authenticated user.
-
Parameters:
user_id(str) - The user ID of the authenticated user. -
Returns:
list[user_model.User]- A list of users who have requested to follow. - Rate Limit: Subject to Twitter's standard API rate limits.
-
Parameters:
-
accept_follow_request(self, user_id: str) -> user_model.UserAccepts a follow request from a specific user by their ID, returning the user's details post-acceptance.
-
Parameters:
user_id(str) - The ID of the user whose follow request is accepted. -
Returns:
user_model.User- The user's details after accepting the follow request. - Rate Limit: Subject to Twitter's standard API rate limits.
-
Parameters:
-
reject_follow_request(self, user_id: str) -> user_model.UserRejects a follow request from a specific user by their ID, returning the user's details post-rejection.
-
Parameters:
user_id(str) - The ID of the user whose follow request is rejected. -
Returns:
user_model.User- The user's details after rejecting the follow request. - Rate Limit: Subject to Twitter's standard API rate limits.
-
Parameters:
The InteractionActions class within PyTweetToolkit facilitates various interactions with tweets, such as liking, unliking, retweeting, deleting retweets, and creating replies. These functions leverage Twitter's API, with authentication inherited from a base class.
Rate Limits:
-
like_tweet: 500 actions per 15-minute window. -
unlike_tweet: 500 actions per 15-minute window. -
create_retweet: Subject to Twitter's standard API rate limits. -
delete_retweet: Subject to Twitter's standard API rate limits. -
create_reply: Subject to Twitter's standard API rate limits.
Methods:
-
like_tweet(self, tweet_id: str) -> strLikes a tweet based on the provided tweet ID.
-
Parameters:
tweet_id(str) - The ID of the tweet to like. -
Returns:
str- 'Success' if liked successfully, 'Failed' otherwise. - Rate Limit: 500 actions per 15 minutes.
-
Parameters:
-
unlike_tweet(self, tweet_id: str) -> strRemoves a like from a tweet based on the provided tweet ID.
-
Parameters:
tweet_id(str) - The ID of the tweet to unlike. -
Returns:
str- 'Success' if unliked successfully, 'Failed' otherwise. - Rate Limit: 500 actions per 15 minutes.
-
Parameters:
-
create_retweet(self, source_tweet_id: str) -> tweet_model.TweetRetweets a tweet given the source tweet's ID.
-
Parameters:
source_tweet_id(str) - The ID of the tweet to retweet. -
Returns:
tweet_model.Tweet- Details of the retweet. - Rate Limit: Subject to Twitter's standard API rate limits.
-
Parameters:
-
delete_retweet(self, source_tweet_id: str) -> tweet_model.TweetDeletes a retweet of the given source tweet ID.
-
Parameters:
source_tweet_id(str) - The ID of the source tweet whose retweet is to be deleted. -
Returns:
tweet_model.Tweet- Details of the original tweet. - Rate Limit: Subject to Twitter's standard API rate limits.
-
Parameters:
-
create_reply(self, reply_to_tweet_id: str, content: str = "", media_ids: list = []) -> tweet_model.TweetCreates a reply to a specified tweet, with optional content and media attachments.
-
Parameters:
-
reply_to_tweet_id(str) - The ID of the tweet to reply to. -
content(str, optional) - The content of the reply. -
media_ids(list, optional) - List of media IDs to attach.
-
-
Returns:
tweet_model.Tweet- Details of the reply tweet. - Rate Limit: Subject to Twitter's standard API rate limits.
-
Parameters: