Overview
Communities are spaces on Twitter/X where people with shared interests can connect. TheCommunity class provides methods for joining, managing, and retrieving content from communities.
Community Class
Attributes
The ID of the community.
The name of the community.
The count of members in the community.
Indicates if the community is NSFW (Not Safe For Work).
The profile image URLs of members (used for displaying member avatars).
The banner information of the community.
Indicates if the authenticated user is a member of the community.
The role of the authenticated user in the community.
The description of the community.
The creator of the community.
The admin of the community.
The join policy of the community (e.g., ‘Open’, ‘Approval required’).
The timestamp of the community’s creation.
The invites policy of the community.
Indicates if the community is pinned.
The rules of the community.
Methods
get_tweets()
Retrieves tweets from the community.The type of tweets to retrieve.
The number of tweets to retrieve.
The cursor for pagination.
Result[Tweet] - List of retrieved tweets.
join()
Join the community. Returns:Community - Updated community object.
leave()
Leave the community. Returns:Community - Updated community object.
request_to_join()
Request to join the community (for communities requiring approval).Answer to any membership questions.
Community - Updated community object.
get_members()
Retrieves members of the community.The number of members to retrieve.
The cursor for pagination.
Result[CommunityMember] - List of retrieved members.
get_moderators()
Retrieves moderators of the community.The number of moderators to retrieve.
The cursor for pagination.
Result[CommunityMember] - List of retrieved moderators.
search_tweet()
Searches tweets in the community.The search query.
The number of tweets to retrieve.
The cursor for pagination.
Result[Tweet] - List of retrieved tweets.
update()
Updates the community object with fresh data from the API.CommunityMember Class
Represents a member of a community.Attributes
The unique identifier of the member.
The member’s role in the community.
Indicates if super following is enabled.
Indicates if the member is eligible for super follow.
Indicates if super followed by the authenticated user.
Indicates if smart blocking is enabled.
Indicates if the member is blue verified.
The member’s screen name.
The member’s display name.
Indicates if a follow request has been sent.
Indicates if the member’s tweets are protected.
Indicates if the authenticated user is following this member.
Indicates if this member follows the authenticated user.
Indicates if the authenticated user is blocking this member.
The URL of the member’s profile image.
Indicates if the member is verified.
CommunityCreator Class
A named tuple representing basic information about a community creator.Attributes
The ID of the creator.
The screen name of the creator.
Indicates if the creator is verified.
CommunityRule Class
A named tuple representing a community rule.Attributes
The ID of the rule.
The name/text of the rule.
Examples
Browse and Join a Community
Get Community Tweets
View Community Information
Get Community Members
Get Community Moderators
Search Within a Community
Monitor Community Activity
Communities are a great way to engage with focused groups of users who share common interests. Some communities may require approval to join, while others are open to all users.
