Skip to content

Communities ​

Join, read, search and moderate communities. Timeline methods return a parsed Timeline; pass raw: true for the GraphQL response.

Reading ​

communities.get(communityId) ​

Gets a community by its REST ID.

js
const community = await client.communities.get("1506788955370692608");

communities.about(communityId) ​

Gets a community with its rules.

communities.timeline(communityId, opts?) ​

Gets the latest tweets. rankingMode: "Relevance" reads the ranked timeline instead.

js
const { tweets, nextCursor } = await client.communities.timeline(id, { count: 20 });

communities.top(communityId, opts?) ​

Gets ranked tweets. Takes rankingMode and displayLocation.

communities.media(communityId, opts?) ​

Gets tweets with media.

communities.hashtags(communityId, hashtag, opts?) ​

Gets community tweets that use a hashtag.

communities.searchPosts(communityId, query, opts?) ​

Searches tweets inside one community.

communities.publicTimeline(communityId, opts?) ​

Gets tweets the way logged out visitors see them. Only count is used.

communities.publicRanked(communityId, opts?) ​

Deprecated. The web client dropped this op and there is no replacement, so emusks calls the old op with { legacy: true }. It may stop working.

communities.publicMedia(communityId, opts?) ​

Deprecated. The web client dropped this op and there is no replacement, so emusks calls the old op with { legacy: true }. It may stop working.

communities.members(communityId, opts?) ​

Gets a page of members as { users, cursor, timeline, raw }.

communities.moderators(communityId, opts?) ​

Gets a page of moderators as { users, cursor, timeline, raw }.

communities.memberSearch(communityId, prefix) ​

Searches members by name prefix.

communities.canPost(communityId) ​

Gets your role in the community, which decides whether you can post.

Discovery ​

communities.home(opts?) ​

Gets tweets from the communities you are in.

communities.ranked(opts?) ​

Gets ranked tweets from the communities you are in.

communities.explore(opts?) ​

Gets the explore timeline. Pass topicId to filter it.

communities.exploreTopics() ​

Gets the topics you can pass to explore.

communities.discover(opts?) / communities.browse(opts?) ​

Gets the communities carousel.

communities.search(query) ​

Searches communities by name.

js
const results = await client.communities.search("kpop");

communities.memberships(opts?) ​

Gets the timeline of communities you belong to.

communities.myMemberships() ​

Reports whether you belong to any community.

Membership ​

communities.join(communityId) ​

Joins a community.

communities.leave(communityId) ​

Leaves a community.

communities.requestJoin(communityId, opts?) ​

Requests to join a community that needs approval. Pass answer for its join question.

communities.pin(communityId) / communities.unpin(communityId) ​

Pins a community to your home tabs or removes it.

communities.setNotifications(communityId, settings) ​

Sets your notification settings for a community.

communities.spotlight() ​

Gets your editable profile modules, which include the communities spotlight.

communities.createSpotlight(communityId) ​

Adds a communities spotlight to your profile.

communities.updateSpotlight(moduleId, communityId) ​

Changes the community in your spotlight.

communities.deleteSpotlight(moduleId) ​

Removes the spotlight.

communities.rateBoost(postId, boostId, data) / communities.deleteBoostRating(boostId) ​

Rates a community boost on a post or removes the rating.

Admin ​

communities.create(name, opts?) ​

Deprecated. The web client can no longer create communities, so this calls the old op with { legacy: true }.

communities.remove(communityId, communityName) ​

Deletes a community. The name is the confirmation.

communities.settings(communityId) ​

Gets the admin settings.

communities.tools(communityId) ​

Gets the moderator tools page.

communities.analytics(communityId) ​

Gets community analytics.

communities.editName(communityId, name) ​

Renames a community.

communities.editPurpose(communityId, description) ​

Sets the description.

communities.editQuestion(communityId, question) ​

Sets the join question.

communities.editBanner(communityId, mediaId) / communities.removeBanner(communityId) ​

Sets the banner to an uploaded media ID, or removes it.

communities.setMembership(communityId, { joinPolicy, invitesPolicy }) ​

Sets who can join and who can invite.

js
await client.communities.setMembership(id, {
  joinPolicy: "RestrictedJoinRequestsRequireModeratorApproval",
  invitesPolicy: "ModeratorInvitesAllowed",
});

communities.setNsfw(communityId, isNsfw?) ​

Marks a community as adult content.

communities.setTopic(communityId, topicId) ​

Sets the primary topic.

communities.setHashtags(communityId, hashtags) / communities.setSearchTags(communityId, searchTags) ​

Sets the hashtags or the search tags.

communities.rulesSettings(communityId) ​

Gets the rules settings page.

communities.createRule(communityId, name, opts?) ​

Adds a rule. Pass description in opts.

communities.editRule(communityId, ruleId, name, opts?) ​

Edits a rule.

communities.removeRule(communityId, ruleId) ​

Removes a rule.

communities.reorderRules(communityId, ruleIds) ​

Reorders the rules to match an array of rule IDs.

communities.list(communityId) / communities.setList(communityId, listId) / communities.removeList(communityId) ​

Reads, attaches or detaches the list linked to a community.

Members and invites ​

communities.invite(communityId, userId) ​

Invites a user.

communities.inviteQuota(communityId) ​

Gets how many invites you have left.

communities.userSearch(communityId, prefix) ​

Searches users to invite by name prefix.

communities.updateRole(communityId, userId, role) ​

Sets a member role to "Member", "Moderator" or "Admin".

communities.leaveModeration(communityId, userId?) ​

Leaves the moderation team. Defaults to the logged in user.

communities.joinRequests(communityId, opts?) ​

Gets pending join requests. Pass cursor for the next page.

communities.approveRequest(communityId, userId) / communities.denyRequest(communityId, userId) ​

Approves or denies a join request.

Moderation ​

communities.moderationCases(communityId, opts?) ​

Gets reported tweets. Pass cursor for the next page.

communities.keepTweet(communityId, tweetId) ​

Keeps a reported tweet.

communities.moderationLog(communityId, opts?) ​

Gets the moderation log. type is "posts", "members" or "banned".

communities.reapprove(moderatorLogId) ​

Reverts a denied join request.

communities.reinstate(moderatorLogId) ​

Reverts a member removal.

communities.unhide(moderatorLogId) ​

Reverts a hidden tweet.

communities.pinTweet(tweetId) / communities.unpinTweet(tweetId) ​

Pins a tweet to the top of its community, or unpins it.

communities.spamSettings(communityId) ​

Gets the spam filter and auto moderation settings.

communities.setSpamFilter(communityId, level) ​

Sets the spam filter level, such as "Medium".

communities.setAutoModeration(communityId, settingType, enabled) ​

Turns "AutoSpamDetectorEnabled" or "HideUntilReviewEnabled" on or off.

communities.bannedKeywords(communityId) / communities.setBannedKeywords(communityId, keywords) ​

Reads or replaces the banned keywords.

not affiliated with X Corp.