-
Notifications
You must be signed in to change notification settings - Fork 4
5. Models
In the models section of the PyTweetToolkit documentation, you'll find comprehensive details on the structure and usage of various data models representing Twitter entities like tweets, users, and media. These models are crucial for interacting with Twitter's API, encapsulating data in a structured manner.
The List
model in PyTweetToolkit represents a Twitter List, providing a structured encapsulation of the list's details and metrics as returned by the Twitter API. This model is crucial for applications that interact with Twitter Lists, enabling easy access to their properties and associated metadata.
-
created_at
(str): The creation timestamp of the list. -
custom_banner_media_url
(str): URL for the custom banner image of the list, if available. -
default_banner_media_url
(str): URL for the default banner image. -
description
(str): Description of the list. -
facepile_urls
(list): Profile image URLs for users featured in the list. -
is_following
(bool): Indicates if the authenticated user follows this list. -
id
(int): Unique identifier of the list on Twitter. -
rest_id
(str): String representation of the list's ID. -
is_member
(bool): Indicates if the authenticated user is a member of this list. -
member_count
(int): Number of members in the list. -
mode
(str): Visibility mode of the list (e.g., "public" or "private"). -
muting
(bool): Indicates if the list is muted. -
name
(str): Name of the list. -
pinning
(bool): Indicates if the list is pinned. -
subscriber_count
(int): Number of subscribers to the list. -
owner
(user_model.User): The owner of the list.
-
__str__() -> str
Provides a human-readable string representation of the list, including key details such as ID, name, description, owner, and counts of members and subscribers. -
to_dict() -> dict
Converts the list model to a dictionary, facilitating serialization and API response generation. This method ensures that all list attributes are represented in a format suitable for data exchange or storage.
The Notification
model within PyTweetToolkit provides a robust structure for representing Twitter notifications. It encapsulates the essential elements and contexts of notifications received from Twitter, such as mentions, follows, likes, retweets, and more. This model plays a vital role in processing and organizing notification data, making it accessible for applications to display or analyze notification events effectively.
-
id
(str): A unique identifier for the notification. -
timestamp_ms
(str): The time when the notification was created, represented in milliseconds. -
icon
(str): An identifier for the icon associated with the specific type of notification. -
message
(str): The textual content of the notification message. -
tweet_ids
(dict): Identifiers of tweets related to the notification. -
user_ids
(dict): Identifiers of users involved in the notification event. -
additional_info
(dict): Extra contextual information related to the notification. -
tweet_details
(list[tweet_model.Tweet]): A list containingTweet
objects that are associated with the notification, providing detailed context.
-
__str__() -> str
Offers a human-readable summary of the notification, including its ID, message, and associated tweet details. This method is particularly useful for logging or debugging purposes. -
to_dict() -> dict
Transforms the notification into a dictionary format, facilitating easy serialization or API response generation. This method ensures that the notification's properties, along with the detailed tweet contexts, are systematically represented for further processing or storage.
The Tweet
model in PyTweetToolkit serves as a comprehensive representation of a Twitter post. It encapsulates all relevant data about a tweet, including content, authorship, interaction metrics, media attachments, and the context of replies, quotes, and retweets. This model facilitates the manipulation and display of tweet data, making it essential for applications integrating Twitter functionality.
-
rest_id
: Unique identifier for the tweet. -
user
: The author of the tweet, represented as auser_model.User
instance. -
edit_tweet_ids
: IDs of the tweet's edit history. -
editable_until_msecs
: Timestamp until the tweet is editable. -
is_edit_eligible
: Eligibility of the tweet for editing. -
edits_remaining
: Number of remaining edits for the tweet. -
is_translatable
: Whether the tweet can be translated. -
views
: View count of the tweet. -
quoted_tweet
: The tweet being quoted, if applicable. -
bookmark_count
: Number of bookmarks for the tweet. -
bookmarked
: Whether the tweet is bookmarked by the current user. -
created_at
: Creation time of the tweet. -
hashtags
: Hashtags mentioned in the tweet. -
symbols
: Symbols (e.g., stock tickers) mentioned. -
timestamps
: Timestamps mentioned in the tweet. -
urls
: URLs included in the tweet. -
user_mentions
: User mentions in the tweet. -
media
: Media items attached to the tweet. -
favorite_count
: Number of likes for the tweet. -
favorited
: Whether the tweet is liked by the current user. -
full_text
: The full text of the tweet. -
in_reply_to_screen_name
: The screen name to whom the tweet replies. -
in_reply_to_tweet_id_str
: The tweet ID to which this tweet replies. -
in_reply_to_user_id_str
: The user ID to whom the tweet replies. -
is_reply
: Indicates if the tweet is a reply. -
is_quote_tweet
: Indicates if the tweet is a quote. -
quoted_tweet_id_str
: ID of the quoted tweet. -
quoted_tweet_permalink
: Permalink of the quoted tweet. -
lang
: Language code of the tweet. -
possibly_sensitive
: If the tweet may contain sensitive content. -
possibly_sensitive_editable
: If the tweet's sensitivity label can be edited. -
quote_count
: Number of quotes of the tweet. -
reply_count
: Number of replies to the tweet. -
retweet_count
: Number of retweets. -
retweeted
: Whether the tweet is retweeted by the current user. -
retweeted_tweet
: The original tweet if this is a retweet.
-
__str__() -> str
Returns a string representation of the tweet, summarizing essential details such as the author, content, and interaction metrics. -
to_dict() -> dict
Converts the tweet and its associated data into a dictionary format. This includes transforming nested objects like the author (user
), quoted tweet (quoted_tweet
), and retweeted tweet (retweeted_tweet
) into dictionaries, facilitating integration with APIs or data storage solutions.
The User
model in PyTweetToolkit encapsulates comprehensive information about a Twitter user's profile. This model serves as a detailed representation of a user's identity on Twitter, including both personal attributes and engagement metrics. It covers a wide array of information, from basic profile details such as name and description to intricate metrics like follower counts and tweet engagement. This model is essential for applications that require a deep understanding of user profiles on Twitter.
-
id
andrest_id
: Unique identifiers for the user, facilitating API interactions. -
is_blue_verified
: Verification status of the user, indicating a verified blue checkmark. -
profile_image_shape
: Shape of the profile image, enhancing UI/UX design. -
can_dm
andcan_media_tag
: Permissions for direct messaging and media tagging. -
created_at
: Account creation timestamp, useful for age analysis. -
default_profile
anddefault_profile_image
: Indicators for default settings usage. -
description
: Self-description, providing insight into personal or professional interests. -
fast_followers_count
andnormal_followers_count
: Follower metrics for engagement analysis. -
favourites_count
,followers_count
,friends_count
, andlisted_count
: Engagement and network size indicators. -
has_custom_timelines
andis_translator
: Special roles and capabilities of the user. -
location
,media_count
, andstatuses_count
: Geographical, media, and activity metrics. -
name
andscreen_name
: Basic identity markers. -
pinned_tweet_ids_str
: Highlighted content, indicating user priorities or interests. -
possibly_sensitive
: Content sensitivity flag, impacting visibility and reach. -
profile_banner_url
andprofile_image_url_https
: Visual elements of the profile. -
verified
: Overall verification status. -
withheld_in_countries
: Content restriction metrics. -
professional_rest_id
,professional_type
, andprofessional_category
: Professional identity indicators. -
verified_phone_status
: Phone verification status, enhancing account security. -
legacy_extended_profile
: Additional profile details for legacy support. -
is_profile_translatable
: Translation capability, expanding global reach. -
has_hidden_likes_on_profile
andhas_hidden_subscriptions_on_profile
: Privacy settings. -
is_identity_verified
andcan_highlight_tweets
: Identity verification and content highlighting capabilities. -
highlighted_tweets
: Specific content highlighted by the user.
-
__str__() -> str
Returns a concise, human-readable summary of the user profile, including key identifiers, profile details, and selected metrics. This is useful for logging, debugging, and user-friendly displays. -
to_dict() -> dict
Transforms theUser
instance into a dictionary format. This method is particularly useful for serializing the user data for storage, network transmission, or integration with other systems. It ensures all user attributes are organized and accessible in a structured format.