Docs
Lists & Communities

Lists & Communities

Access Twitter Lists, Communities, and member information with comprehensive data about members, moderators, and content.

Overview

The Lists & Communities endpoints provide access to Twitter Lists and Communities - two powerful features for organizing and curating content. Lists allow users to create curated timelines of specific accounts, while Communities are topic-based discussion groups with moderation features.

Key Features

Lists:

  • List Management: Get list details, members, and tweets
  • User Lists: Find all lists for a user
  • List Search: Discover public lists
  • Member Access: Get complete member information

Communities:

  • Community Details: Get community information and rules
  • Member Management: Access members, moderators, and admins
  • Community Tweets: Get tweets posted in communities
  • Search: Find communities by topic or name

Lists vs Communities

FeatureListsCommunities
PurposeCurated account timelinesTopic-based discussions
ContentTweets from list membersTweets posted in community
PrivacyCan be public or privateCan be public or invite-only
ModerationNo moderation featuresFull moderation system
MembershipFollow list to see contentJoin community to participate
Use CaseOrganize accounts to followCreate discussion groups

Authentication

All endpoints require authentication via the X-API-KEY header:

X-API-KEY: YOUR_API_KEY

For detailed authentication information, see our Authentication Guide.


Lists

Get List by ID

Retrieves detailed information about a Twitter List, including owner, member count, description, and privacy settings.

Endpoint: GET /list/{list_id}

Path Parameters

NameTypeRequiredDescription
list_idstringYesThe unique List ID

Request Examples

curl --request GET \
  --url 'https://<direct.gateway>/list/1234567890123456789' \
  --header 'X-API-KEY: YOUR_API_KEY'

JavaScript:

const response = await fetch('https://<direct.gateway>/list/1234567890123456789', {
  headers: { 'X-API-KEY': 'YOUR_API_KEY' }
});
const list = await response.json();

Response Example

{
  "id": "1234567890123456789",
  "name": "Tech Leaders",
  "description": "Influential people in tech",
  "created_at": "2020-05-15T10:30:00.000Z",
  "owner": {
    "id": "987654321",
    "username": "tech_curator",
    "name": "Tech Curator",
    "verified": true
  },
  "member_count": 156,
  "follower_count": 5234,
  "private": false,
  "pinned": false
}

Response Fields

FieldTypeDescription
idstringUnique List ID
namestringList name
descriptionstringList description
member_countintegerNumber of accounts in list
follower_countintegerNumber of users following the list
privatebooleanWhether list is private
ownerobjectList owner information

Access Rights

  • Public Lists: Accessible to everyone
  • Private Lists: Only accessible to the owner and accounts with appropriate permissions
  • 403 Forbidden: Returned when accessing private lists without permission

Get List Members

Retrieves all members of a List with their complete user information. Useful for understanding who is included in a curated list.

Endpoint: GET /list/{list_id}/members

Path Parameters

NameTypeRequiredDescription
list_idstringYesThe List ID

Query Parameters

NameTypeRequiredDescription
limitintegerNoNumber of results (Default: 100, Max: 1000)
cursorstringNoPagination cursor

Request Examples

curl --request GET \
  --url 'https://<direct.gateway>/list/1234567890123456789/members?limit=100' \
  --header 'X-API-KEY: YOUR_API_KEY'

JavaScript:

async function getAllListMembers(listId) {
  let allMembers = [];
  let cursor = null;
  
  do {
    const url = `/list/${listId}/members?limit=1000${cursor ? `&cursor=${cursor}` : ''}`;
    const response = await fetch(url, {
      headers: { 'X-API-KEY': API_KEY }
    });
    const data = await response.json();
    
    allMembers = allMembers.concat(data.data);
    cursor = data.meta?.next_cursor || null;
  } while (cursor);
  
  return allMembers;
}

Response Example

{
  "data": [
    {
      "id": "111222333",
      "username": "tech_leader",
      "name": "Tech Leader",
      "verified": true,
      "profile_image_url": "https://pbs.twimg.com/profile_images/...",
      "metrics": {
        "followers_count": 152340,
        "following_count": 523
      },
      "added_at": "2023-06-10T14:20:00.000Z"
    }
  ],
  "meta": {
    "result_count": 100,
    "next_cursor": "eyJpZCI6IjExMTIyMjMzMyJ9"
  }
}

Use Cases

  • List Analysis: Understand the composition of a list
  • Influencer Discovery: Find influential accounts in specific lists
  • Content Curation: Use lists to discover accounts to follow

Get List Tweets

Retrieves tweets from all members of a List. This creates a curated timeline of content from the list members.

Endpoint: GET /list/{list_id}/tweets

Path Parameters

NameTypeRequiredDescription
list_idstringYesThe List ID

Query Parameters

NameTypeRequiredDescription
limitintegerNoNumber of results (Default: 20, Max: 100)
cursorstringNoPagination cursor

Request Example

curl --request GET \
  --url 'https://<direct.gateway>/list/1234567890123456789/tweets?limit=20' \
  --header 'X-API-KEY: YOUR_API_KEY'

Response Example

{
  "data": [
    {
      "id": "1234567890123456789",
      "text": "Tweet from list member",
      "author": {
        "id": "111222333",
        "username": "tech_leader",
        "in_list": true
      },
      "created_at": "2024-10-01T12:00:00.000Z",
      "metrics": {
        "like_count": 523,
        "retweet_count": 87
      }
    }
  ],
  "meta": {
    "result_count": 20,
    "next_cursor": "..."
  }
}

Use Cases

  • Curated Feeds: Create custom feeds from list members
  • Content Aggregation: Aggregate content from specific accounts
  • Topic Monitoring: Monitor tweets from a curated group

Get User Lists

Retrieves all Lists for a user, including lists they own and lists they follow.

Endpoint: GET /user/{user_id}/lists

Path Parameters

NameTypeRequiredDescription
user_idstringYesThe user ID

Query Parameters

NameTypeRequiredDescription
typestringNoFilter: owned, subscribed, all (Default: all)
limitintegerNoNumber of results (Default: 20, Max: 100)

Request Examples

# All lists
curl --request GET \
  --url 'https://<direct.gateway>/user/987654321/lists?type=all&limit=20' \
  --header 'X-API-KEY: YOUR_API_KEY'
 
# Only owned lists
curl --request GET \
  --url 'https://<direct.gateway>/user/987654321/lists?type=owned' \
  --header 'X-API-KEY: YOUR_API_KEY'

Response Example

{
  "owned_lists": [
    {
      "id": "1234567890123456789",
      "name": "My Tech List",
      "member_count": 156,
      "follower_count": 42,
      "private": false
    }
  ],
  "subscribed_lists": [
    {
      "id": "9876543210987654321",
      "name": "News Sources",
      "owner": {
        "username": "curator",
        "name": "News Curator"
      },
      "member_count": 89
    }
  ]
}

Search Lists

Searches for public Lists by name or description. Useful for discovering relevant lists.

Endpoint: GET /lists/search

Query Parameters

NameTypeRequiredDescription
qstringYesSearch term
limitintegerNoNumber of results (Default: 20, Max: 100)

Request Example

curl --request GET \
  --url 'https://<direct.gateway>/lists/search?q=technology&limit=20' \
  --header 'X-API-KEY: YOUR_API_KEY'

Response Example

{
  "data": [
    {
      "id": "1234567890123456789",
      "name": "AI Researchers",
      "description": "Leading AI researchers and scientists",
      "owner": {
        "username": "ai_curator",
        "verified": false
      },
      "member_count": 234,
      "follower_count": 1523
    }
  ],
  "meta": {
    "result_count": 15
  }
}

Communities

Get Community by ID

Retrieves detailed information about a Twitter Community, including description, rules, member count, and moderation settings.

Endpoint: GET /community/{community_id}

Path Parameters

NameTypeRequiredDescription
community_idstringYesThe Community ID

Request Examples

curl --request GET \
  --url 'https://<direct.gateway>/community/1234567890123456789' \
  --header 'X-API-KEY: YOUR_API_KEY'

JavaScript:

const response = await fetch('https://<direct.gateway>/community/1234567890123456789', {
  headers: { 'X-API-KEY': 'YOUR_API_KEY' }
});
const community = await response.json();

Response Example

{
  "id": "1234567890123456789",
  "name": "Tech Enthusiasts",
  "description": "A community for tech lovers",
  "created_at": "2021-09-01T10:00:00.000Z",
  "admin": {
    "id": "987654321",
    "username": "community_admin",
    "name": "Admin User",
    "verified": true
  },
  "member_count": 5234,
  "rules": [
    "Be respectful",
    "No spam",
    "Stay on topic"
  ],
  "theme": {
    "primary_color": "#1DA1F2",
    "banner_url": "https://..."
  },
  "purpose": "general",
  "invite_only": false
}

Response Fields

FieldTypeDescription
idstringUnique Community ID
namestringCommunity name
descriptionstringCommunity description
member_countintegerNumber of members
adminobjectCommunity admin information
rulesarrayCommunity rules
purposestringCommunity purpose/category
invite_onlybooleanWhether community requires invitation

Access Rights

  • Public Communities: Accessible to everyone
  • Invite-Only Communities: Only accessible to members
  • 403 Forbidden: Returned when accessing invite-only communities without membership

Get Community Members

Retrieves members of a Community, with optional filtering by role (admin, moderator, member).

Endpoint: GET /community/{community_id}/members

Path Parameters

NameTypeRequiredDescription
community_idstringYesThe Community ID

Query Parameters

NameTypeRequiredDescription
rolestringNoFilter: admin, moderator, member
limitintegerNoNumber of results (Default: 100, Max: 1000)

Request Examples

# All members
curl --request GET \
  --url 'https://<direct.gateway>/community/1234567890123456789/members?limit=100' \
  --header 'X-API-KEY: YOUR_API_KEY'
 
# Only moderators
curl --request GET \
  --url 'https://<direct.gateway>/community/1234567890123456789/members?role=moderator' \
  --header 'X-API-KEY: YOUR_API_KEY'

Response Example

{
  "data": [
    {
      "id": "111222333",
      "username": "member_user",
      "name": "Member Name",
      "role": "member",
      "joined_at": "2023-03-15T14:20:00.000Z",
      "profile_image_url": "https://pbs.twimg.com/profile_images/..."
    }
  ],
  "meta": {
    "total_members": 5234,
    "admins": 3,
    "moderators": 12,
    "members": 5219
  }
}

Member Roles

  • Admin: Community creators and administrators
  • Moderator: Users with moderation permissions
  • Member: Regular community members

Get Community Tweets

Retrieves tweets posted in a Community. This shows the discussion content within the community.

Endpoint: GET /community/{community_id}/tweets

Path Parameters

NameTypeRequiredDescription
community_idstringYesThe Community ID

Query Parameters

NameTypeRequiredDescription
limitintegerNoNumber of results (Default: 20, Max: 100)
sortstringNoSort order: recent, top (Default: recent)

Request Example

curl --request GET \
  --url 'https://<direct.gateway>/community/1234567890123456789/tweets?limit=20&sort=top' \
  --header 'X-API-KEY: YOUR_API_KEY'

Response Example

{
  "data": [
    {
      "id": "1234567890123456789",
      "text": "Community tweet content",
      "author": {
        "id": "111222333",
        "username": "community_member",
        "community_role": "member"
      },
      "created_at": "2024-10-01T12:00:00.000Z",
      "community": {
        "id": "1234567890123456789",
        "name": "Tech Enthusiasts"
      },
      "metrics": {
        "like_count": 45,
        "retweet_count": 12
      }
    }
  ]
}

Get User Communities

Retrieves all Communities a user belongs to, with their role in each community.

Endpoint: GET /user/{user_id}/communities

Path Parameters

NameTypeRequiredDescription
user_idstringYesThe user ID

Query Parameters

NameTypeRequiredDescription
rolestringNoFilter: admin, moderator, member

Request Example

curl --request GET \
  --url 'https://<direct.gateway>/user/987654321/communities' \
  --header 'X-API-KEY: YOUR_API_KEY'

Response Example

{
  "data": [
    {
      "id": "1234567890123456789",
      "name": "Tech Enthusiasts",
      "user_role": "member",
      "member_count": 5234,
      "joined_at": "2023-03-15T14:20:00.000Z"
    }
  ],
  "meta": {
    "result_count": 3
  }
}

Search Communities

Searches for public Communities by name, description, or topic.

Endpoint: GET /communities/search

Query Parameters

NameTypeRequiredDescription
qstringYesSearch term
categorystringNoCategory filter
limitintegerNoNumber of results (Default: 20, Max: 100)

Request Example

curl --request GET \
  --url 'https://<direct.gateway>/communities/search?q=technology&limit=20' \
  --header 'X-API-KEY: YOUR_API_KEY'

Response Example

{
  "data": [
    {
      "id": "1234567890123456789",
      "name": "AI & Machine Learning",
      "description": "Discuss AI and ML topics",
      "member_count": 12340,
      "purpose": "technology",
      "invite_only": false
    }
  ],
  "meta": {
    "result_count": 8
  }
}

Get Community Rules

Retrieves the rules and moderation policies of a Community.

Endpoint: GET /community/{community_id}/rules

Path Parameters

NameTypeRequiredDescription
community_idstringYesThe Community ID

Request Example

curl --request GET \
  --url 'https://<direct.gateway>/community/1234567890123456789/rules' \
  --header 'X-API-KEY: YOUR_API_KEY'

Response Example

{
  "community_id": "1234567890123456789",
  "rules": [
    {
      "id": "rule_1",
      "title": "Be respectful",
      "description": "Treat all members with respect",
      "priority": 1
    },
    {
      "id": "rule_2",
      "title": "No spam",
      "description": "Do not post spam or self-promotion",
      "priority": 2
    }
  ],
  "enforcement": {
    "warnings_before_ban": 3,
    "moderator_approval_required": false
  }
}

Community Purposes/Categories

Communities can be categorized by purpose:

PurposeDescription
generalGeneral discussions
technologyTechnology & Innovation
gamingGaming & Esports
entertainmentEntertainment & Media
sportsSports & Fitness
educationEducation & Learning
businessBusiness & Career

Best Practices

Lists & Communities-Specific Tips

  • Handle private resources: Always check for 403 errors when accessing lists/communities
  • Use pagination: Lists can have thousands of members - always use cursor-based pagination
  • Cache list data: Lists and communities don't change frequently, cache for 5-10 minutes
  • Distinguish Lists vs Communities: Lists are curated timelines, Communities are discussion groups

For general API best practices including error handling, rate limits, and performance optimization, see our Best Practices Guide.

3. Cache List/Community Data

Cache data to reduce API calls:

const cache = new Map();
const CACHE_TTL = 5 * 60 * 1000; // 5 minutes
 
async function getCachedList(listId) {
  const cached = cache.get(listId);
  if (cached && Date.now() - cached.timestamp < CACHE_TTL) {
    return cached.data;
  }
  
  const response = await fetch(`/list/${listId}`, {
    headers: { 'X-API-KEY': API_KEY }
  });
  const data = await response.json();
  
  cache.set(listId, { data, timestamp: Date.now() });
  return data;
}

For comprehensive error handling and rate limits information, see our guides:

Troubleshooting

IssueSymptomsPossible CausesSolutions
Cannot access private listGetting 403 errors for listsList is private, API credentials don't have accessCheck if list is private, ensure your API credentials have appropriate permissions, use public lists for testing
Incomplete member listsNot getting all membersNot using pagination, hitting rate limits, private members not accessibleImplement proper cursor-based pagination, check rate limit headers, be aware that some members may be private - see Pagination Guide

FAQ

What's the difference between Lists and Communities?

  • Lists: Curated timelines of accounts you want to follow together
  • Communities: Discussion groups with moderation, rules, and topic-based content

Can I create lists or communities via the API?

Currently, the API provides read-only access. Creation and management must be done through Twitter's interface.

How do I find lists for a specific topic?

Use the /lists/search endpoint with relevant keywords.

Are community members public?

Public communities show member lists. Invite-only communities may restrict member visibility.

Can I get tweets from multiple lists at once?

No, you need to make separate requests for each list. Consider caching and batching requests.