Skip to content

Lists ​

Create, manage, and interact with Twitter lists.

Methods that read one list return a parsed list: { id, name, description, private, member_count, subscriber_count, following, banner, facepile, owner, ... }. Timelines of lists, like discover or listMemberships, put them in lists.

lists.create(name, opts?) ​

Create a new list. Uses the GraphQL ListCreate mutation.

OptionTypeDescription
namestringThe list name
opts.privatebooleanMake the list private (default false)
opts.descriptionstringList description
js
await client.lists.create("Tech News");

// Private list with description
await client.lists.create("My Favorites", {
  private: true,
  description: "People I follow closely",
});

lists.remove(listId) ​

Delete a list you own. Uses the GraphQL listEditSlotDeleteMutation mutation.

js
await client.lists.remove("1234567890");

lists.update(listId, opts?) ​

Update a list's name, description, or visibility. Uses the GraphQL listEditSlotUpdateMutation mutation.

OptionTypeDescription
listIdstringThe list ID
opts.namestringNew name
opts.descriptionstringNew description
opts.privatebooleanChange visibility
js
await client.lists.update("1234567890", {
  name: "Renamed List",
  description: "Updated description",
  private: false,
});

lists.get(listId) ​

Get a list by its REST ID. Uses the GraphQL ListByIdQuery query.

js
const list = await client.lists.get("1234567890");

lists.hoverCard(listId) returns the same shape from listHoverCardBodyQuery, and null instead of throwing.

lists.getBySlug(slug, opts?) ​

Get a list by its slug and owner screen name. Uses the GraphQL listSlugRedirectQuery query. The owner is required now.

OptionTypeDescription
slugstringThe list slug
opts.ownerScreenNamestringThe list owner's username
js
const list = await client.lists.getBySlug("tech-news", {
  ownerScreenName: "elonmusk",
});

lists.addMember(listId, userId) ​

Add a user to a list. Uses the GraphQL ListMemberAdd mutation. Throws with X's reason when the add is refused.

js
await client.lists.addMember("1234567890", "44196397");

You can't add more than 150 users in 24 hours to a list, or else you'll hit an undocumented ratelimit.

lists.removeMember(listId, userId) ​

Remove a user from a list. Uses the GraphQL setListMembershipRemoveMutation mutation.

js
await client.lists.removeMember("1234567890", "44196397");

lists.isMember(listId, userIds) ​

Check whether up to 5 users are members of a list. Uses the GraphQL listMembersSuggestedSlotSearchMembershipQuery query.

js
await client.lists.isMember("1234567890", ["44196397", "12"]);
// { "44196397": true, "12": false }

lists.members(listId, opts?) ​

Get the members of a list. Uses the GraphQL listMembersQuery query.

OptionTypeDescription
opts.countnumberNumber of results (default 20)
opts.cursorstringPagination cursor
opts.variablesobjectAdditional GraphQL variables
js
const members = await client.lists.members("1234567890", { count: 50 });

lists.subscribers(listId, opts?) ​

Get users who have subscribed to a list. Uses the GraphQL listSubscribersQuery query.

OptionTypeDescription
opts.countnumberNumber of results (default 20)
opts.cursorstringPagination cursor
opts.variablesobjectAdditional GraphQL variables
js
const subs = await client.lists.subscribers("1234567890");

lists.subscribe(listId) ​

Subscribe to a list. Uses the GraphQL followListButtonSubscribeMutation mutation.

js
await client.lists.subscribe("1234567890");

lists.unsubscribe(listId) ​

Unsubscribe from a list. Uses the GraphQL followListButtonUnsubscribeMutation mutation.

js
await client.lists.unsubscribe("1234567890");

lists.mute(listId) ​

Mute a list (hide its tweets from your timeline). Uses the legacy GraphQL MuteList mutation, which the web client no longer calls.

js
await client.lists.mute("1234567890");

lists.unmute(listId) ​

Unmute a list. Uses the legacy GraphQL UnmuteList mutation, which the web client no longer calls.

js
await client.lists.unmute("1234567890");

lists.timeline(listId, opts?) ​

Get the latest tweets from a list. Uses the GraphQL ListTimeline query. Ads are left out unless you pass opts.ads.

OptionTypeDescription
opts.countnumberNumber of results (default 20)
opts.cursorstringPagination cursor
opts.variablesobjectAdditional GraphQL variables
js
const { tweets } = await client.lists.timeline("1234567890");

// Paginate
const next = await client.lists.timeline("1234567890", { cursor: "DAABCgAB..." });

lists.ranked(listId, opts?) ​

Get ranked (algorithmic) tweets from a list. Uses the legacy GraphQL ListRankedTweetsTimeline query, which the web client no longer calls.

OptionTypeDescription
opts.countnumberNumber of results (default 20)
opts.cursorstringPagination cursor
opts.variablesobjectAdditional GraphQL variables
js
const ranked = await client.lists.ranked("1234567890");

lists.search(listId, query, opts?) ​

Search tweets within a list. Uses the legacy GraphQL ListSearchTimeline query, which the web client no longer calls.

OptionTypeDescription
listIdstringThe list ID
querystringSearch query
opts.countnumberNumber of results (default 20)
opts.cursorstringPagination cursor
opts.variablesobjectAdditional GraphQL variables
js
const results = await client.lists.search("1234567890", "breaking news");

lists.ownerships(userId?, opts?) ​

Get the lists you own, one slice at a time. Uses the GraphQL listAddMemberSlotQuery query, which only answers for your own account. Returns { lists, cursor, raw }.

OptionTypeDescription
userIdstringYour REST ID (defaults to you)
opts.memberOfstringA user ID, to mark whether they're in each list
opts.cursorstringPagination cursor
js
const { lists } = await client.lists.ownerships();

lists.listMemberships(userId, opts?) ​

Get lists a user is a member of. Uses the GraphQL listsMembershipsQuery query.

OptionTypeDescription
userIdstringThe user's REST ID or screen name
opts.countnumberNumber of results (default 20)
opts.cursorstringPagination cursor
opts.variablesobjectAdditional GraphQL variables
js
const { lists } = await client.lists.listMemberships("44196397");

lists.discover(opts?) ​

Discover suggested lists. Uses the GraphQL ListsDiscovery query.

OptionTypeDescription
opts.countnumberNumber of results (default 20)
opts.cursorstringPagination cursor
opts.variablesobjectAdditional GraphQL variables
js
const suggestions = await client.lists.discover();

lists.combined(opts?) ​

Get the lists a user owns and follows. Uses the GraphQL userListsQuery query. Defaults to you; pass opts.screenName or opts.userId for someone else.

OptionTypeDescription
opts.countnumberNumber of results (default 20)
opts.cursorstringPagination cursor
opts.variablesobjectAdditional GraphQL variables
js
const all = await client.lists.combined();

lists.manage(opts?) ​

Get the list management page timeline. Uses the GraphQL listsManagementQuery query.

OptionTypeDescription
opts.countnumberNumber of results (default 20)
opts.cursorstringPagination cursor
opts.variablesobjectAdditional GraphQL variables
js
const managed = await client.lists.manage();

lists.editBanner(listId, mediaId) ​

Update a list's banner image. Uses the GraphQL listBannerFieldPutMutation mutation.

js
await client.lists.editBanner("1234567890", "9876543210");

lists.deleteBanner(listId) ​

Remove a list's banner image. Uses the GraphQL listEditSlotDeleteBannerMutation mutation.

js
await client.lists.deleteBanner("1234567890");

lists.pinTimeline(listId) ​

Pin a list to your home tabs. Uses the GraphQL pinListButtonPinMutation mutation.

js
await client.lists.pinTimeline("1234567890");

lists.unpinTimeline(listId) ​

Unpin a list from your home tabs. Uses the GraphQL pinListButtonUnpinMutation mutation.

js
await client.lists.unpinTimeline("1234567890");

lists.pinned() ​

Get your pinned list timelines. Uses the GraphQL pinnedTimelinesQuery query.

js
const pinned = await client.lists.pinned();

lists.recommendedUsers(listId, opts?) ​

Get suggested accounts to add to a list you own. Uses the GraphQL listEditRecommendedUsersQuery query, or listCreationRecommendedUsersQuery with opts.creation, which is the screen x.com shows right after you create a list. Twitter returns an empty timeline for lists you don't own.

ParamTypeDescription
listIdstringList ID
opts.creationbooleanUse the creation suggestions
opts.countnumberNumber of results (default 20)
opts.cursorstringPagination cursor
opts.variablesobjectAdditional GraphQL variables
js
const { users } = await client.lists.recommendedUsers("1234567890");

Full example ​

js
// Create a list
await client.lists.create("JavaScript Devs", {
  description: "Great JS developers to follow",
  private: false,
});

// Add members
await client.lists.addMember(listId, "44196397");
await client.lists.addMember(listId, "12");

// Browse the list timeline
const tweets = await client.lists.timeline(listId, { count: 30 });

// Search within the list
const results = await client.lists.search(listId, "React");

// Pin it to home
await client.lists.pinTimeline(`list-${listId}`);

// Check who's subscribed
const subs = await client.lists.subscribers(listId);

// See all your lists
const myLists = await client.lists.ownerships(client.user.id);

// Discover new lists
const suggestions = await client.lists.discover();

// Clean up
await client.lists.removeMember(listId, "12");
await client.lists.remove(listId);

not affiliated with X Corp.