Communities lookup

Introduction

The Communities lookup endpoint helps you lookup Communities by their ID, and enables you to build experiences to display information about Communities that your users are interested in.

Account setup

To access these endpoints, you will need:

Learn more about getting access to the X API v2 endpoints in our getting started guide.

Getting started

Authentication

You can authenticate this endpoint with either OAuth 1.0a User Context, OAuth 2.0 App-Only, or OAuth 2.0 Authorization Code with PKCE.
 

Making a request

You can call the Communities Lookup endpoint by providing an ID as shown below (using the ID 1758747817642700922):

      curl --location 'https://api.x.com/2/communities/1758747817642700922' --header 'Authorization: ••••••'
    

If the request is successful, you should see the JSON response as shown below:

      {
    "data": {
        "access": "Public",
        "description": "Welcome to the Anime Community! Where anime fans gather to share their favorite shows and discuss everything anime-related.",
        "join_policy": "Open",
        "name": "Anime Community"
    }
}
    

Community fields

You can fetch additional data associated with a community by specifying Community Fields.

The following Community Fields are available:

Field value Type Description  

created_at

date (ISO 8601)

Creation time of the Community.

 

id

string

The unique identifier of the Community.  

name

string

The name of the Community.

 
description string The text of the Community’s description, if provided.  

access

string

The access level of the Community.

Can be one of:

  • Public
  • Closed

 

join_policy

string

The join policy for the Community.

Can be one of:

  • Open
  • RestrictedJoinRequestsDisabled
  • RestrictedJoinRequestsRequireAdminApproval
  • RestrictedJoinRequestsRequireModeratorApproval
  • SuperFollowRequired
 

member_count

integer

The number of members that have joined the Community.  

Example Request

You can call the Communities Lookup endpoint with additional community fields as shown below (using the ID 1758747817642700922):

      curl --location 'https://api.x.com/2/communities/1758747817642700922?community.fields=access,created_at,description,id,join_policy,member_count,name' --header 'Authorization: ••••••'
    

Example Response

If the request is successful, you should see the JSON response as shown below:

      {
    "data": {
        "description": "Welcome to the Anime Community! Where anime fans gather to share their favorite shows and discuss everything anime-related.",
        "access": "Public",
        "member_count": 40369,
        "created_at": "2024-02-17T06:58:50.000Z",
        "join_policy": "Open",
        "name": "Anime Community",
        "id": "Q29tbXVuaXR5OjE3NTg3NDc4MTc2NDI3MDA5MjI="
    }
}