TwitterAPIs Docs
API ReferenceCommunities

X Community Memberships API | Communities a User Is In

The inverse relation: given a numeric X user id, list the communities that account belongs to, cursor-paginated. Each row is the FULL community object, and it is the most populated form of it this API returns: admin, invites_policy, question, search_tags, members_facepile_ids and a real moderator_count all arrive here and do not on Community Info. Profiling an account's community footprint takes one call per page rather than a follow-up lookup per community. Billed at $0.0008 per call. Cost: $0.0008 per call.

GET community/memberships answers the inverse question every other community endpoint does not: which communities does THIS ACCOUNT belong to. It takes a numeric X user id, not a handle and not a community id, and returns each membership as the FULL community object, with member counts, rules, topic, policies, admin and creator, so no follow-up call per community is needed. It is also the more complete of the two endpoints that return a community: X serves it with a richer operation, so invites_policy, admin, question, search_tags, members_facepile_ids and moderator_count are populated here and come back empty from Community Info. An empty list is a real answer here and returns 200, not 404. $0.0008 per call.

GET
/community/memberships

Authorization

bearerAuth
AuthorizationBearer <token>

Pass your API key as a bearer token on every request: Authorization: Bearer <API_KEY>.

In: header

Query Parameters

user_id*string

The numeric X user id, NOT a handle and NOT a community id. Resolve a @handle to an id with User Info first; doing that resolution silently here would turn one billed read into two.

cursor?string

Pagination cursor from a previous response's next_cursor. Omit on the first call.

count?integer

Page size. Defaults to 20 and is clamped to 1-100. A non-numeric value is a 400.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X GET "https://example.com/community/memberships?user_id=1281109705495130113&count=20"
{  "communities": [    {      "id": "1828843041869713562",      "name": "Build In Public - SaaS",      "description": "Founders shipping in the open.",      "created_at": 1724865134102,      "member_count": 392,      "moderator_count": 1,      "join_policy": "RestrictedJoinRequestsRequireModeratorApproval",      "invites_policy": "MemberInvitesAllowed",      "is_nsfw": false,      "question": "What are you currently building?",      "primary_topic": {        "topic_id": "303",        "name": "Software"      },      "search_tags": [        "saas",        "buildinpublic"      ],      "rules": [        {          "id": "1828843041869713570",          "name": "Be useful, not promotional",          "description": null        }      ],      "banner_url": "https://pbs.twimg.com/community_banner_img/...",      "permalink": null,      "admin": {        "id": "1281109705495130113",        "username": "pizzaboy",        "name": "Dan Holdsworth"      },      "creator": {        "id": "1281109705495130113",        "username": "pizzaboy",        "name": "Dan Holdsworth"      },      "members_facepile_ids": [        "1281109705495130113"      ],      "role": null,      "can_join": null,      "is_pinned": null,      "viewer_relationship_type": null    }  ],  "next_cursor": null,  "has_more": false}
{  "error": "bad_request",  "message": "Missing or malformed parameter. Fix the request before retrying."}
{  "error": "unauthorized",  "message": "The API key is missing, malformed, or revoked. Check the Authorization header."}
{  "error": "insufficient_credits",  "message": "Your balance is exhausted. Top up your credits to continue."}
{  "error": "not_found",  "message": "The resource does not exist, for example a deleted tweet or a private account."}
{  "error": "rate_limited",  "message": "Too many requests. Back off and retry with exponential backoff."}
{  "error": "server_error",  "message": "Something failed on our side. Retry with backoff; if it persists, contact support."}

Pricing

UnitPrice
Per call$0.0008
Per 1,000 calls$0.80
Per 1,000 records (~20 per call)~$0.04

When to use

Use this to profile an account: which communities it is part of, and therefore which audiences it sits inside. Every other endpoint in this family starts from a community; this is the only one that starts from an account.

Notes

  • TAKES A NUMERIC USER ID, not a handle and not a community id. A handle is deliberately not accepted: resolving it here would add a second upstream call and a second billing event to a request you think is one read. Resolve the handle with User Info first and pass the id.
  • Each row is the FULL community object, not a stub, so you do not need a follow-up Community Info call per membership. A follow-up call would in fact give you LESS: Community Info is served by a reduced X operation that returns admin, invites_policy, question, search_tags and members_facepile_ids empty and moderator_count as 0, all of which are populated here. Measured on 2026-08-17 across 10 communities read through both endpoints.
  • AN EMPTY LIST IS A REAL ANSWER HERE and returns 200, unlike the roster endpoints, which 404 on an empty first page. An account belonging to no communities is true and useful, and it cannot be distinguished from a non-existent account without a second upstream call, so telling you a real account was not found would be the worse error.
  • The same four caller-relative fields (role, can_join, is_pinned, viewer_relationship_type) are null on every community in this list, for the same pooled-read reason as Community Info.
  • If X returns a shape this API does not recognise, you get a 502 parse_failed rather than a 200 with an empty list, and that call is not billed to you.

Pagination

Pass the returned next_cursor straight back as ?cursor= and stop when communities comes back empty or has_more is false. Unlike the roster endpoints, an empty FIRST page is NOT a 404 here: an account that belongs to no communities is a true and useful answer.

  • Community Info: Metadata, rules and banners for one X Community.
  • Community Members: Page through a community's member roster, each row carrying that member's role.
  • Community Moderators: Page through a community's moderators and admins.
  • Community Tweets: Page through a community's post timeline, with the pinned post returned separately.

FAQ

Can I pass a @handle instead of a user id?

No, by design. Accepting a handle would mean resolving it upstream first, which is a second call and a second billing event on a request you believe is one read. Call User Info with the handle, take the id, and pass that.

Do I get the full community object or just an id and name?

The full object, and the most populated version of it this API returns: member and moderator counts, join and invite policies, rules, topic, search tags, banners, admin and creator. That is the point of the endpoint, so profiling an account's community footprint does not cost one extra call per community. It is the same 24 keys Community Info returns but with more of them filled, because X serves this route with a richer operation. The one field that is null here as well is permalink, which X does not send anywhere.

What does an empty communities array mean?

That the account belongs to no communities, and it comes back as a 200. This endpoint deliberately does NOT 404 on an empty first page, unlike the member and moderator rosters: an account in no communities is a real answer, and we cannot distinguish it from a non-existent account without a second call.

Why are role, can_join and is_pinned null on every community here?

Same reason as Community Info: they describe the account that made the upstream call, and this is a pooled read served by a rotating account from our pool. They are nulled rather than removed so it stays visible that X sends them.