Skip to main content
Client for users operations This client provides methods for interacting with the users endpoints of the X API. It handles authentication, request formatting, and response parsing for all users related operations.

Constructors

constructor

new UsersClient(client): UsersClient Creates a new users client instance

Parameters

NameTypeDescription
clientClientThe main X API client instance

Returns

UsersClient

Defined in

users/client.ts:720

Methods

getMentions

getMentions(id, options?): Promise<Get2UsersIdMentionsResponse> Get mentions Retrieves a list of Posts that mention a specific User by their ID.

Parameters

NameTypeDescription
idstringThe ID of the User to lookup.
optionsGetMentionsOptions-

Returns

Promise<Get2UsersIdMentionsResponse> Promise resolving to the API response

Defined in

users/client.ts:737

getRepostsOfMe

getRepostsOfMe(options?): Promise<Get2UsersRepostsOfMeResponse> Get Reposts of me Retrieves a list of Posts that repost content from the authenticated user.

Parameters

NameType
optionsGetRepostsOfMeOptions

Returns

Promise<Get2UsersRepostsOfMeResponse> Promise resolving to the API response

Defined in

users/client.ts:849

getBookmarks

getBookmarks(id, options?): Promise<Get2UsersIdBookmarksResponse> Get Bookmarks Retrieves a list of Posts bookmarked by the authenticated user.

Parameters

NameTypeDescription
idstringThe ID of the authenticated source User for whom to return results.
optionsGetBookmarksOptions-

Returns

Promise<Get2UsersIdBookmarksResponse> Promise resolving to the API response

Defined in

users/client.ts:938

createBookmark

createBookmark(id, body): Promise<BookmarkMutationResponse> Create Bookmark Adds a post to the authenticated user’s bookmarks.

Parameters

NameTypeDescription
idstringThe ID of the authenticated source User for whom to add bookmarks.
bodyBookmarkAddRequestRequest body

Returns

Promise<BookmarkMutationResponse> Promise resolving to the API response

Defined in

users/client.ts:1032

getBlocking

getBlocking(id, options?): Promise<Get2UsersIdBlockingResponse> Get blocking Retrieves a list of Users blocked by the specified User ID.

Parameters

NameTypeDescription
idstringThe ID of the authenticated source User for whom to return results.
optionsGetBlockingOptions-

Returns

Promise<Get2UsersIdBlockingResponse> Promise resolving to the API response

Defined in

users/client.ts:1075

getBookmarksByFolderId

getBookmarksByFolderId(id, folderId): Promise<BookmarkFolderPostsResponse> Get Bookmarks by folder ID Retrieves Posts in a specific Bookmark folder by its ID for the authenticated user.

Parameters

NameTypeDescription
idstringThe ID of the authenticated source User for whom to return results.
folderIdstringThe ID of the Bookmark Folder that the authenticated User is trying to fetch Posts for.

Returns

Promise<BookmarkFolderPostsResponse> Promise resolving to the API response

Defined in

users/client.ts:1153

getById

getById(id, options?): Promise<Get2UsersIdResponse> Get User by ID Retrieves details of a specific User by their ID.

Parameters

NameTypeDescription
idstringThe ID of the User to lookup.
optionsGetByIdOptions-

Returns

Promise<Get2UsersIdResponse> Promise resolving to the API response

Defined in

users/client.ts:1196

unrepostPost

unrepostPost(id, sourceTweetId): Promise<UsersRetweetsDeleteResponse> Unrepost Post Causes the authenticated user to unrepost a specific Post by its ID.

Parameters

NameTypeDescription
idstringThe ID of the authenticated source User that is requesting to repost the Post.
sourceTweetIdstringThe ID of the Post that the User is requesting to unretweet.

Returns

Promise<UsersRetweetsDeleteResponse> Promise resolving to the API response

Defined in

users/client.ts:1262

getFollowers

getFollowers(id, options?): Promise<Get2UsersIdFollowersResponse> Get followers Retrieves a list of Users who follow a specific User by their ID.

Parameters

NameTypeDescription
idstringThe ID of the User to lookup.
optionsGetFollowersOptions-

Returns

Promise<Get2UsersIdFollowersResponse> Promise resolving to the API response

Defined in

users/client.ts:1308

likePost

likePost(id, options?): Promise<UsersLikesCreateResponse> Like Post Causes the authenticated user to Like a specific Post by its ID.

Parameters

NameTypeDescription
idstringThe ID of the authenticated source User that is requesting to like the Post.
optionsLikePostOptions-

Returns

Promise<UsersLikesCreateResponse> Promise resolving to the API response

Defined in

users/client.ts:1382

unlikePost

unlikePost(id, tweetId): Promise<UsersLikesDeleteResponse> Unlike Post Causes the authenticated user to Unlike a specific Post by its ID.

Parameters

NameTypeDescription
idstringThe ID of the authenticated source User that is requesting to unlike the Post.
tweetIdstringThe ID of the Post that the User is requesting to unlike.

Returns

Promise<UsersLikesDeleteResponse> Promise resolving to the API response

Defined in

users/client.ts:1434

unfollowList

unfollowList(id, listId): Promise<ListFollowedResponse> Unfollow List Causes the authenticated user to unfollow a specific List by its ID.

Parameters

NameTypeDescription
idstringThe ID of the authenticated source User that will unfollow the List.
listIdstringThe ID of the List to unfollow.

Returns

Promise<ListFollowedResponse> Promise resolving to the API response

Defined in

users/client.ts:1478

getFollowing

getFollowing(id, options?): Promise<Get2UsersIdFollowingResponse> Get following Retrieves a list of Users followed by a specific User by their ID.

Parameters

NameTypeDescription
idstringThe ID of the User to lookup.
optionsGetFollowingOptions-

Returns

Promise<Get2UsersIdFollowingResponse> Promise resolving to the API response

Defined in

users/client.ts:1521

followUser

followUser(id, options?): Promise<UsersFollowingCreateResponse> Follow User Causes the authenticated user to follow a specific user by their ID.

Parameters

NameTypeDescription
idstringThe ID of the authenticated source User that is requesting to follow the target User.
optionsFollowUserOptions-

Returns

Promise<UsersFollowingCreateResponse> Promise resolving to the API response

Defined in

users/client.ts:1595

getLikedPosts

getLikedPosts(id, options?): Promise<Get2UsersIdLikedTweetsResponse> Get liked Posts Retrieves a list of Posts liked by a specific User by their ID.

Parameters

NameTypeDescription
idstringThe ID of the User to lookup.
optionsGetLikedPostsOptions-

Returns

Promise<Get2UsersIdLikedTweetsResponse> Promise resolving to the API response

Defined in

users/client.ts:1643

unfollowUser

unfollowUser(sourceUserId, targetUserId): Promise<UsersFollowingDeleteResponse> Unfollow User Causes the authenticated user to unfollow a specific user by their ID.

Parameters

NameTypeDescription
sourceUserIdstringThe ID of the authenticated source User that is requesting to unfollow the target User.
targetUserIdstringThe ID of the User that the source User is requesting to unfollow.

Returns

Promise<UsersFollowingDeleteResponse> Promise resolving to the API response

Defined in

users/client.ts:1739

unpinList

unpinList(id, listId): Promise<ListUnpinResponse> Unpin List Causes the authenticated user to unpin a specific List by its ID.

Parameters

NameTypeDescription
idstringThe ID of the authenticated source User for whom to return results.
listIdstringThe ID of the List to unpin.

Returns

Promise<ListUnpinResponse> Promise resolving to the API response

Defined in

users/client.ts:1792

repostPost

repostPost(id, options?): Promise<UsersRetweetsCreateResponse> Repost Post Causes the authenticated user to repost a specific Post by its ID.

Parameters

NameTypeDescription
idstringThe ID of the authenticated source User that is requesting to repost the Post.
optionsRepostPostOptions-

Returns

Promise<UsersRetweetsCreateResponse> Promise resolving to the API response

Defined in

users/client.ts:1832

getPinnedLists

getPinnedLists(id, options?): Promise<Get2UsersIdPinnedListsResponse> Get pinned Lists Retrieves a list of Lists pinned by the authenticated user.

Parameters

NameTypeDescription
idstringThe ID of the authenticated source User for whom to return results.
optionsGetPinnedListsOptions-

Returns

Promise<Get2UsersIdPinnedListsResponse> Promise resolving to the API response

Defined in

users/client.ts:1880

pinList

pinList(id, body): Promise<ListPinnedResponse> Pin List Causes the authenticated user to pin a specific List by its ID.

Parameters

NameTypeDescription
idstringThe ID of the authenticated source User that will pin the List.
bodyListPinnedRequestRequest body

Returns

Promise<ListPinnedResponse> Promise resolving to the API response

Defined in

users/client.ts:1944

getListMemberships

getListMemberships(id, options?): Promise<Get2UsersIdListMembershipsResponse> Get List memberships Retrieves a list of Lists that a specific User is a member of by their ID.

Parameters

NameTypeDescription
idstringThe ID of the User to lookup.
optionsGetListMembershipsOptions-

Returns

Promise<Get2UsersIdListMembershipsResponse> Promise resolving to the API response

Defined in

users/client.ts:1984

unmuteUser

unmuteUser(sourceUserId, targetUserId): Promise<MuteUserMutationResponse> Unmute User Causes the authenticated user to unmute a specific user by their ID.

Parameters

NameTypeDescription
sourceUserIdstringThe ID of the authenticated source User that is requesting to unmute the target User.
targetUserIdstringThe ID of the User that the source User is requesting to unmute.

Returns

Promise<MuteUserMutationResponse> Promise resolving to the API response

Defined in

users/client.ts:2062

blockDms

blockDms(id): Promise<UsersDMBlockCreateResponse> Block DMs Blocks direct messages to or from a specific User by their ID for the authenticated user.

Parameters

NameTypeDescription
idstringThe ID of the target User that the authenticated user requesting to block dms for.

Returns

Promise<UsersDMBlockCreateResponse> Promise resolving to the API response

Defined in

users/client.ts:2111

getFollowedLists

getFollowedLists(id, options?): Promise<Get2UsersIdFollowedListsResponse> Get followed Lists Retrieves a list of Lists followed by a specific User by their ID.

Parameters

NameTypeDescription
idstringThe ID of the User to lookup.
optionsGetFollowedListsOptions-

Returns

Promise<Get2UsersIdFollowedListsResponse> Promise resolving to the API response

Defined in

users/client.ts:2149

followList

followList(id, options?): Promise<ListFollowedResponse> Follow List Causes the authenticated user to follow a specific List by its ID.

Parameters

NameTypeDescription
idstringThe ID of the authenticated source User that will follow the List.
optionsFollowListOptions-

Returns

Promise<ListFollowedResponse> Promise resolving to the API response

Defined in

users/client.ts:2223

getByIds

getByIds(ids, options?): Promise<Get2UsersResponse> Get Users by IDs Retrieves details of multiple Users by their IDs.

Parameters

NameTypeDescription
idsany[]A list of User IDs, comma-separated. You can specify up to 100 IDs.
optionsGetByIdsOptions-

Returns

Promise<Get2UsersResponse> Promise resolving to the API response

Defined in

users/client.ts:2271

getMe

getMe(options?): Promise<Get2UsersMeResponse> Get my User Retrieves details of the authenticated user.

Parameters

NameType
optionsGetMeOptions

Returns

Promise<Get2UsersMeResponse> Promise resolving to the API response

Defined in

users/client.ts:2331

unblockDms

unblockDms(id): Promise<UsersDMUnBlockCreateResponse> Unblock DMs Unblocks direct messages to or from a specific User by their ID for the authenticated user.

Parameters

NameTypeDescription
idstringThe ID of the target User that the authenticated user requesting to unblock dms for.

Returns

Promise<UsersDMUnBlockCreateResponse> Promise resolving to the API response

Defined in

users/client.ts:2388

getMuting

getMuting(id, options?): Promise<Get2UsersIdMutingResponse> Get muting Retrieves a list of Users muted by the authenticated user.

Parameters

NameTypeDescription
idstringThe ID of the authenticated source User for whom to return results.
optionsGetMutingOptions-

Returns

Promise<Get2UsersIdMutingResponse> Promise resolving to the API response

Defined in

users/client.ts:2426

muteUser

muteUser(id, options?): Promise<MuteUserMutationResponse> Mute User Causes the authenticated user to mute a specific User by their ID.

Parameters

NameTypeDescription
idstringThe ID of the authenticated source User that is requesting to mute the target User.
optionsMuteUserOptions-

Returns

Promise<MuteUserMutationResponse> Promise resolving to the API response

Defined in

users/client.ts:2500

getPosts

getPosts(id, options?): Promise<Get2UsersIdTweetsResponse> Get Posts Retrieves a list of posts authored by a specific User by their ID.

Parameters

NameTypeDescription
idstringThe ID of the User to lookup.
optionsGetPostsOptions-

Returns

Promise<Get2UsersIdTweetsResponse> Promise resolving to the API response

Defined in

users/client.ts:2548

deleteBookmark

deleteBookmark(id, tweetId): Promise<BookmarkMutationResponse> Delete Bookmark Removes a Post from the authenticated user’s Bookmarks by its ID.

Parameters

NameTypeDescription
idstringThe ID of the authenticated source User whose bookmark is to be removed.
tweetIdstringThe ID of the Post that the source User is removing from bookmarks.

Returns

Promise<BookmarkMutationResponse> Promise resolving to the API response

Defined in

users/client.ts:2674

getByUsernames

getByUsernames(usernames, options?): Promise<Get2UsersByResponse> Get Users by usernames Retrieves details of multiple Users by their usernames.

Parameters

NameTypeDescription
usernamesany[]A list of usernames, comma-separated.
optionsGetByUsernamesOptions-

Returns

Promise<Get2UsersByResponse> Promise resolving to the API response

Defined in

users/client.ts:2717

getByUsername

getByUsername(username, options?): Promise<Get2UsersByUsernameUsernameResponse> Get User by username Retrieves details of a specific User by their username.

Parameters

NameTypeDescription
usernamestringA username.
optionsGetByUsernameOptions-

Returns

Promise<Get2UsersByUsernameUsernameResponse> Promise resolving to the API response

Defined in

users/client.ts:2781

getBookmarkFolders

getBookmarkFolders(id, options?): Promise<BookmarkFoldersResponse> Get Bookmark folders Retrieves a list of Bookmark folders created by the authenticated user.

Parameters

NameTypeDescription
idstringThe ID of the authenticated source User for whom to return results.
optionsGetBookmarkFoldersOptions-

Returns

Promise<BookmarkFoldersResponse> Promise resolving to the API response

Defined in

users/client.ts:2843
search(query, options?): Promise<Get2UsersSearchResponse> Search Users Retrieves a list of Users matching a search query.

Parameters

NameTypeDescription
queryanyTThe the query string by which to query for users.
optionsSearchOptions-

Returns

Promise<Get2UsersSearchResponse> Promise resolving to the API response

Defined in

users/client.ts:2899

getTimeline

getTimeline(id, options?): Promise<Get2UsersIdTimelinesReverseChronologicalResponse> Get Timeline Retrieves a reverse chronological list of Posts in the authenticated User’s Timeline.

Parameters

NameTypeDescription
idstringThe ID of the authenticated source User to list Reverse Chronological Timeline Posts of.
optionsGetTimelineOptions-

Returns

Promise<Get2UsersIdTimelinesReverseChronologicalResponse> Promise resolving to the API response

Defined in

users/client.ts:2975

getOwnedLists

getOwnedLists(id, options?): Promise<Get2UsersIdOwnedListsResponse> Get owned Lists Retrieves a list of Lists owned by a specific User by their ID.

Parameters

NameTypeDescription
idstringThe ID of the User to lookup.
optionsGetOwnedListsOptions-

Returns

Promise<Get2UsersIdOwnedListsResponse> Promise resolving to the API response

Defined in

users/client.ts:3097