Introduction

Likes lookup

With endpoints in the Likes lookup group, you can retrieve a list of accounts that have liked a Post, or a list of Posts that an account has liked. These endpoints include:

  • Posts liked by a user - GET /2/users/:id/liked_tweets
  • Users who have liked a Post - GET /2/tweets/:id/liking_users

You can authenticate these endpoints with either OAuth 1.0a User Context or OAuth 2.0 Bearer Token. For the liked Posts endpoints, pagination tokens will be provided for paging through large sets of results.

The liking users endpoint limits you to a total of 100 liking accounts per post for all time.  Additionally, the liked Posts endpoint is also subject to the monthly Post cap applied at the Project level.  

Manage Likes

The manage Likes endpoints enable you to like or unlike a specified Post on behalf of an authenticated account. For this endpoint group, there are two methods available POST and DELETE. The POST method allows you to like a Post, and the DELETE method will enable you to unlike a Post.

Since you are making requests on behalf of a user, you must authenticate these endpoints with OAuth 1.0a User Context and use the Access Tokens associated with the user, which can be generated using the 3-legged OAuth flow/obtaining-user-access-tokens). You can like a Post from your account or an account of an authenticated user. With both endpoints, there is a user rate limit of 50 requests per 15 minutes per endpoint.   

To access these endpoint, you must have an approved developer account. When authenticating, you must use keys and tokens from a developer App that is located within a Project

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

Quick Start

Getting started with the Likes lookup endpoint

This quick start guide will help you make your first request to the Likes lookup endpoint using Postman.

If you would like to see sample code in different languages, please visit our Twitter API v2 sample code GitHub repository.  

Prerequisites

For you to be able to complete this guide, you will have need to have a set of keys and tokens, which you can generate by following these steps:

  1. Apply for a developer account and receive approval.

  2. Create a Project and an associated developer App in the developer portal.

  3. Navigate to your app’s “Keys and tokens” page, and save your API Keys, Access Tokens, and Bearer Token to your password manager.

Steps to build a Likes lookup request

Step one: Start with a tool or library

There are several different tools, code examples, and libraries that you can use to make a request to this endpoint, but we will use the Postman tool here to simplify the process.

To load the Twitter API v2 Postman collection into your environment, please click on the following button:


Add Twitter API v2 to Postman

Once you have the Twitter API v2 collection loaded in Postman, navigate to the “Likes” folder and select “Liking users.”   

Step two: Authenticate your request

To make a successful request to this endpoint, you will need to use either OAuth 1.0a User Context or OAuth 2.0 Bearer Token authentication. To do this, you must add the following keys and tokens to Postman by selecting the environment named “Twitter API v2”, and adding the following variables to the Initial value and Current value fields:

  • consumer_key with your API Key
  • consumer_secret with your API Key Secret
  • access_token with your Access Token
  • token_secret with your Access Token Secret  

Step three: Specify a Tweet

With this endpoint, you must specify the Tweet ID that you want to get liking users for. You can find the ID of a Tweet by navigating to that Tweet on Twitter and pulling the numerical code at the end of the URL. For example, the following URL’s Tweet ID is 1354143047324299264.

https://twitter.com/TwitterDev/status/1354143047324299264

In Postman, navigate to the “Params” tab and enter this username into the “Value” column of the tweet_id path variable (at the bottom of the section), making sure to not include any spaces before or after usernames. 

KeyValue
idThe Tweet ID you want to get the liking users of

Step four: Identify and specify which fields you would like to retrieve

If you click the “Send” button after step three, you will receive the default user object fields in your response: id, name, and username.

If you would like to receive additional fields beyond id, name, and username, you will have to specify those fields in your request with the fields and/or expansions parameters.

For this exercise, we will request three additional sets of fields from different objects:

  1. The additional user.created_at field in the primary user objects.
  2. The associated pinned Tweets’ object’s default fields for the returned users: id and text.
  3. The additional  tweet.created_at field in the associated Tweet objects.

In Postman, navigate to the “Params” tab and add the following key:value pair to the “Query Params” table:

KeyValueReturned fields
user.fieldscreated_atuser.created_at
expansionspinned_tweet_idtweet.id, tweet.text
tweet.fieldscreated_attweet.created_at

You should now see the following URL next to the “Send” button:

https://api.x.com/2/tweets/1354143047324299264/liking_users?user.fields=created_at&expansions=pinned_tweet_id&tweet.fields=created_at

Step five: Make your request and review your response

Once you have everything set up, hit the “Send” button and you will receive a similar response to the following example response:

{
  "data": [
    {
      "created_at": "2008-12-04T18:51:57.000Z",
      "id": "17874544",
      "username": "TwitterSupport",
      "name": "Twitter Support"
    },
    {
      "created_at": "2007-02-20T14:35:54.000Z",
      "id": "783214",
      "username": "Twitter",
      "name": "Twitter"
    },
    {
      "pinned_tweet_id": "1389270063807598594",
      "created_at": "2018-11-21T14:24:58.000Z",
      "id": "1065249714214457345",
      "username": "TwitterSpaces",
      "name": "Spaces"
    },
    {
      "pinned_tweet_id": "1293595870563381249",
      "created_at": "2007-05-23T06:01:13.000Z",
      "id": "6253282",
      "username": "TwitterAPI",
      "name": "Twitter API"
    }
  ],
  "includes": {
    "tweets": [
      {
        "created_at": "2021-05-03T17:26:09.000Z",
        "id": "1389270063807598594",
        "text": "now, everyone with 600 or more followers can host a Space.\n\nbased on what we've learned, these accounts are likely to have a good experience hosting because of their existing audience. before bringing the ability to create a Space to everyone, we’re focused on a few things. 🧵"
      },
      {
        "created_at": "2020-08-12T17:11:04.000Z",
        "id": "1293595870563381249",
        "text": "Twitter API v2: Early Access released\n\nToday we announced Early Access to the first endpoints of the new Twitter API!\n\n#TwitterAPI #EarlyAccess #VersionBump https://t.co/g7v3aeIbtQ"
      }
    ]
  }
}

Step six: Get a user’s liked Tweets

You might also want to make a request to get a user’s liked Tweets as well. With the Likes lookup endpoint, you can get information about a user’s liked Tweets. To do this navigate to the “Likes” folder and select “Liked Tweets”. 

With this endpoint, you must specify the User ID that you want to get liking users for. You can use the user lookup endpoint to get this information.

In Postman, navigate to the “Params” tab and enter this username into the “Value” column of the id path variable (at the bottom of the section), making sure to not include any spaces before or after usernames. 

KeyValue
idThe user ID you want to get the liked Tweets of
max_results5

You can now see a similar URL with your ID instead of TwitterDev’s next to the “Send” button:  

https://api.x.com/2/users/2244994945/liked_tweets?max_results=5

Once you have everything set up, hit the “Send” button and you will receive a similar response to the following example response:

{
  "data": [
    {
      "id": "1362449997430542337",
      "text": "Honored to be the first developer to be featured in @TwitterDev's love fest 🥰♥️😍 https://t.co/g8TsPoZsij"
    },
    {
      "id": "1365416026435854338",
      "text": "We're so happy for our Official Partner @Brandwatch and their big news. https://t.co/3DwWBNSq0o https://t.co/bDUGbgPkKO"
    },
    {
      "id": "1296487407475462144",
      "text": "Check out this feature on @TwitterDev to learn more about how we're mining social media data to make sense of this evolving #publichealth crisis https://t.co/sIFLXRSvEX."
    },
    {
      "id": "1294346980072624128",
      "text": "I awake from five years of slumber https://t.co/OEPVyAFcfB"
    },
    {
      "id": "1283153843367206912",
      "text": "@wongmjane Wish we could tell you more, but I’m only a teapot 👀"
    }
  ],
  "meta": {
        "next_token": "7140dibdnow9c7btw4539n0vybdnx19ylpayqf16fjt4l",
    	  "result_count": 5
  }
}

Getting started with the manage Likes endpoints

This quick start guide will help you make your first request to the manage Likes endpoints using Postman.

If you would like to see sample code in different languages, please visit our X API v2 sample code GitHub repository. 

Prerequisites

For you to be able to complete this guide, you will have need to have a set of keys and tokens, which you can generate by following these steps:

  1. Apply for a developer account and receive approval.

  2. Create a Project and an associated developer App in the developer portal.

  3. Navigate to your app’s “Keys and tokens” page, and save your API Keys, Access Tokens, and Bearer Token to your password manager.

Steps to build a manage Likes request

Step one: Start with a tool or library

There are several different tools, code examples, and libraries that you can use to make a request to this endpoint, but we are going to use the Postman tool here to simplify the process.

To load the X API v2 Postman collection into your environment, please click on the following button:


Add X API v2 to Postman

Once you have the X API v2 collection loaded in Postman, navigate to the “Likes” folder, and select “Like a Post”.

Step two: Authenticate your request

To make a successful request to this endpoint, you will need to use OAuth 1.0a User Context. To do this, you must add the following keys and tokens to Postman by selecting the environment named “X API v2”, and adding the following variables to the initial value and current value fields:

  • consumer_key with your API Key
  • consumer_secret with your API Key Secret
  • access_token with your Access Token
  • token_secret with your Access Token Secret  

Step three: Specify which Post you are going to like

Manage Likes endpoints require two IDs: one for the user (the user who wishes to like a Post), and the other representing the  Post ID that the user is trying to like or unlike. 

The user’s ID must correspond to the authenticating user’s ID, meaning that you must pass the Access Tokens associated with the user ID when authenticating your request.  In this case, you can specify the ID belonging to your own user. You can find your ID in two ways:

  1. Using the user lookup by username endpoint, you can pass a username and receive the id field. 
  2. Looking at your Access Token, you will find that the numeric part is your user ID.  

You also must specify a Post that you want to like. You can find the Post ID by navigating to x.com and clicking on a Post and then looking in the URL. For example, the following URL’s Post ID is 1228393702244134912.

https://twitter.com/TwitterDev/status/1228393702244134912

In Postman, navigate to the “Params” tab, and enter your ID into the “Value” column of the id path variable. Navigate to the “Body” tab and ID of the Post you wish to like as the value for the tweet_id parameter. Be sure not to include any spaces before or after any ID.

KeyValue
id(your user ID)
tweet_id(the ID of the Post you want to like)

If you click the “Send” button, you will receive a response object containing the status of the relationship:

  • If you receive a “liked”: true, then the id is successfully liking the tweet_id.  

Step four: Make your request and review your response

Once you have everything set up, hit the “Send” button and you will receive the following response:

{
    "data": {
        "liked": true
    }
}

If you wish to unlike the same Post you can use the request entitled “Unlike a Post”, which is also found in the “Likes” folder of the X API v2 collection in Postman. The id and tweet_id should be used in the same way as the previous example.  To unlike a Post, you will not have to add this as a JSON body so you will want to make sure that you add in the requisite query params for id and tweet_id.

Comparing X API’s Likes endpoints

These guides will focus on the following areas:

  • API request parameters - The X API v2 endpoint introduces a new set of request parameters. While some parameters will be familiar, especially for those integrating with Labs, there are many important differences such as the introduction of the fields and expansions parameters.

  • App and Project requirements - To access the X API v2, you will need to use credentials from a developer App that is associated with a Project

Likes lookup

Users who have liked a Post

The liked users endpoint is new functionality for v2, allowing you to get information about a Post’s liking users.

DescriptionX API v2
HTTP methods supportedGET
Host domainhttps://api.x.com
Endpoint path/2/tweets/:id/liking_users
AuthenticationOAuth 2.0 Bearer Token

OAuth 1.0a User Context
Default request rate limits75 requests per 15 min (per App)

75 requests per 15 min (per user)

Posts liked by a user

The following tables compare the standard v1.1 GET favorites/list endpoint and the X API v2 liked Posts endpoints:

DescriptionStandard v1.1X API v2
HTTP methods supportedGETGET
Host domainhttps://api.x.comhttps://api.x.com
Endpoint path/1.1/favorites/list.json/2/users/:id/liked_tweets
AuthenticationOAuth 1.0a User ContextOAuth 2.0 Bearer Token

OAuth 1.0a User Context
Default request rate limits75 requests per 15 min75 requests per 15 min (per App)

75 requests per 15 min (per user)
Data formatsStandard v1.1 formatX API v2 format (determined by fields and expansions request parameters, not backward-compatible with v1.1 formats)

To learn more about how to migrate from the Standard v1.1 format to the X API v2 format, please visit our data formats migration guide.

Manage Likes

The v2 manage Likes endpoints replace the v1.1 POST favorites/create and POST favorites/destroy endpoints.

The following tables compare the standard v1.1 and X API v2 manage Like endpoints:

Like a Post

DescriptionStandard v1.1X API v2
HTTP methods supportedPOSTPOST
Host domainhttps://api.x.comhttps://api.x.com
Endpoint path/1.1/favorites/create.json/2/users/:id/likes
AuthenticationOAuth 1.0a User ContextOAuth 1.0a User Context
Default request rate limits1000 requests per 24 hours (per user)

1000 requests per 24 hours (per App)
50 requests per 15 min (per user)

1000 requests per 24 hours (per user, shared with DELETE)

Unlike a Post

DescriptionStandard v1.1X API v2
HTTP methods supportedPOSTDELETE
Host domainhttps://api.x.comhttps://api.x.com
Endpoint path/1.1/favorites/destroy.json/2/users/:id/likes/:tweet_id
AuthenticationOAuth 1.0a User ContextOAuth 1.0a User Context
Default request rate limits1000 requests per 24 hours (per user)

1000 requests per 24 hours (per App)
50 requests per 15 min (per user)

1000 requests per 24 hours (per user, shared with POST)

Other migration resources

Likes lookup: Standard v1.1 to X API v2

Manage Likes: Standard v1.1 to X API v2

X API migration hub

Likes lookup: Standard v1.1 compared to X API v2

If you have been working with the standard v1.1 GET favorites/list endpoint, the goal of this guide is to help you understand the similarities and differences between the standard v1.1 and X API v2 Likes lookup endpoints.

With v2, we’ve also introduced a new liked users endpoint which allows you to get information about a Post’s liking users.

  • Similarities
    • Authentiation
    • Rate limits
  • Differences
    • Endpoint URLs

    • Request limitations

    • App and Project requirements

    • Request parameters

    • New JSON format

Similarities

Authentication

Both the standard v1.1 and X API v2 Likes lookup endpoints use OAuth 1.0a User Context or OAuth 2.0 Bearer Token. Therefore, if you were previously using the GET favorites/list endpoints standard v1.1 endpoints, you can continue using the same authentication method if you migrate to the X API v2 version if you wish. 

Depending on your authentication library/package of choice, Bearer Token authentication is probably the easiest way to get started and can be set with a simple request header. To learn how to generate a Bearer Token, see this OAuth 2.0 Bearer Token guide.   

Rate limits

The standard v1.1 GET favorites/list endpoint has a 75 requests per 15 minutes per user rate limit. The corresponding liked Posts endpoint in v2 also has this same rate limit. However, this v2 endpoint also has an additional rate limit of 75 requests per 15 minutes per App.

Differences

Endpoint URLs

Request limitations

The v2 liked Posts endpoint allows you to request 5 to 100 Posts per request, but you can request all likes of a Post using pagination tokens. The v1.1 GET favorites/list endpoint also allows you to pull all likes of Posts, but you can pull from 20 to 200 Posts per request.

For the v2 liking users endpoint, you are limited to 100 liking users per Post.   

App and Project requirements

The X API v2 endpoints require that you use credentials from a developer App that is associated with a Project when authenticating your requests. All X API v1.1 endpoints can use credentials from standalone Apps or Apps associated with a project.

Request parameters

The following standard v1.1 request parameters accepted two request query parameters (user_id or screen_name). The X API v2 only accepts the numerical user ID, and it must be passed as part of the endpoint path.

One of the biggest differences between standard v1.1 and X API v2 endpoint versions is how you select which fields return in your payload. For the standard endpoints, there are several parameters that you could use to identify which fields or sets of fields would return in the payload, while the X API v2 version simplifies these different parameters into fields and expansions.   

New JSON format

X API v2 is introducing new JSON designs for the objects returned by the APIs, including Post and user objects.

  • At the JSON root level, the standard endpoints return user objects in a statuses array, while X API v2 returns a data array. 
  • Instead of referring to Retweeted and Quoted “statuses”, X API v2 JSON refers to Retweeted and Quoted Tweets. Many legacy and deprecated fields, such as contributors and user.translator_type are being removed. 
  • Instead of using both favorites (in Post object) and favourites (in user object), X API v2 uses the term like. 
  • X is adopting the convention that JSON values with no value (for example, null) are not written to the payload. Post and user attributes are only included if they have non-null values.  

In addition to the changes that we made to our new JSON format, we also introduced a new set of fields to the Post object including the following:

Manage Likes: Standard v1.1 compared to X API v2

If you have been working with the standard v1.1 POST favorites/create and POST favorites/destroy endpoints, the goal of this guide is to help you understand the similarities and differences between the standard v1.1 and X API v2 manage Likes endpoints.

  • Similarities
    • OAuth 1.0a User Context
  • Differences
    • Endpoint URLs and HTTP methods
    • App and Project requirements
    • Request parameters

Similarities

OAuth 1.0a User Context authentication method

Both the endpoint versions support OAuth 1.0a User Context. Therefore, if you were previously using one of the standard v1.1 manage favorites endpoints, you can continue using the same authentication method if you migrate to the X API v2 version.

Differences

Endpoint URLs and HTTP methods

App and Project requirements

The X API v2 endpoints require that you use credentials from a developer App that is associated to a Project when authenticating your requests. All X API v1.1 endpoints can use credentials from standalone Apps or Apps associated with a Project.

Request parameters

The following standard v1.1 request parameters have equivalents in X API v2:

Standard v1.1X API v2
idid
includes_entitiesNo equivalent

Please note that the Standard v1.1 parameters are passed as query parameters, whereas the X API v2 parameters are passed as body parameters for the POST endpoint or path parameters for the DELETE endpoint.

Also, an id of the user liking a Post is not required when using the standard v1.1 endpoints since the Access Tokens passed with OAuth 1.0a User Context infer which user is initiating the like/unlike. 

API reference index

For the complete API reference, select an endpoint from the list:  

Likes lookup

Users who have liked a PostGET /2/tweets/:id/liking_users
Posts liked by a userGET /2/users/:id/liked_tweets

Manage Likes

Allows a user ID to like a Post[POST /2/users/:id/likes](/x-api/x-api-v2/tweets/likes#api-reference-index/post-users-id-likes)
Allows a user ID to unlike a Post[DELETE /2/users/:id/likes/:tweet_id](/x-api/x-api-v2/tweets/likes#api-reference-index/delete-users-id-likes-tweet_id)

DELETE /2/users/:id/likes/:tweet_id

Allows a user or authenticated user ID to unlike a Tweet.

The request succeeds with no action when the user sends a request to a user they’re not liking the Tweet or have already unliked the Tweet.

Endpoint URL

https://api.x.com/2/users/:id/likes/:tweet_id

Authentication and rate limits

Authentication methods
supported by this endpoint
OAuth 1.0a User context
Rate limitUser rate limit: 50 requests per 15-minute window

User rate limit: 1000 requests per 24-hour window
(Shared with POST /2/users/:id/likes)

Path parameters

NameTypeDescription
id
 Required
stringThe user ID who you are removing a Like of a Tweet on behalf of. It must match your own user ID or that of an authenticating user, meaning that you must pass the Access Tokens associated with the user ID when authenticating your request.
tweet_id
 Required
stringThe ID of the Tweet that you would like the id to unlike.

Example requests

curl -X DELETE https://api.x.com/2/users/2244994945/likes/1228393702244134912 -H "Authorization: OAuth $OAUTH_SIGNATURE"

Example responses

{
  "data": {
    "liked": false
  }
}

Response fields

NameTypeDescription
likedbooleanIndicates whether the user is unliking the specified Tweet as a result of this request. The returned value is false for a successful unlike request.

GET /2/tweets/:id/liking_users

Allows you to get information about a Tweet’s liking users.

Endpoint URL

https://api.x.com/2/tweets/:id/liking_users

Authentication and rate limits

Authentication methods
supported by this endpoint
OAuth 2.0 App-only

OAuth 1.0a is also available for this endpoint.

OAuth 2.0 Authorization Code with PKCE
Rate limitApp rate limit (Application-only): 75 requests per 15-minute window shared among all users of your app

User rate limit (User context): 75 requests per 15-minute window per each authenticated user

OAuth 2.0 scopes required by this endpoint

tweet.read

users.read

like.read
Learn more about OAuth 2.0 Authorization Code with PKCE

Path parameters

NameTypeDescription
id
 Required
stringTweet ID of the Tweet to request liking users of.

Query parameters

NameTypeDescription
expansions
 Optional
enum (pinned_tweet_id)Expansions enable you to request additional data objects that relate to the originally returned users. The ID that represents the expanded data object will be included directly in the user data object, but the expanded object metadata will be returned within the includes response object, and will also include the ID so that you can match this data object to the original Tweet object. At this time, the only expansion available to endpoints that primarily return user objects is expansions=pinned_tweet_id. You will find the expanded Tweet data object living in the includes response object.
max_results
 Optional
integerThe maximum number of results to be returned per page. This can be a number between 1 and 100. By default, each page will return 100 results.
pagination_token
 Optional
stringUsed to request the next page of results if all results weren’t returned with the latest request, or to go back to the previous page of results. To return the next page, pass the next_token returned in your previous response. To go back one page, pass the previous_token returned in your previous response.
tweet.fields
 Optional
enum (attachments, author_id, context_annotations, conversation_id, created_at, entities, geo, id, in_reply_to_user_id, lang, non_public_metrics, public_metrics, organic_metrics, promoted_metrics, possibly_sensitive, referenced_tweets, reply_settings, source, text, withheld)This fields parameter enables you to select which specific Tweet fields will deliver in each returned pinned Tweet. Specify the desired fields in a comma-separated list without spaces between commas and fields. The Tweet fields will only return if the user has a pinned Tweet and if you’ve also included the expansions=pinned_tweet_id query parameter in your request. While the referenced Tweet ID will be located in the original Tweet object, you will find this ID and all additional Tweet fields in the includes data object.
user.fields
 Optional
enum (created_at, description, entities, id, location, most_recent_tweet_id, name, pinned_tweet_id, profile_image_url, protected, public_metrics, url, username, verified, verified_type, withheld)This fields parameter enables you to select which specific user fields will deliver with each returned users objects. Specify the desired fields in a comma-separated list without spaces between commas and fields. These specified user fields will display directly in the user data objects.

Example code with offical SDKs

(async () => {
  try {
    const likingUsers = await twitterClient.users.tweetsIdLikingUsers(
      // Tweet ID of the Tweet to request liking users of
      "1354143047324299264"
    );
    console.dir(likingUsers, {
      depth: null,
    });
  } catch (error) {
    console.log(error);
  }
})();

Example responses

{
  "data": [
    {
      "id": "1065249714214457345",
      "name": "Spaces",
      "username": "TwitterSpaces"
    },
    {
      "id": "783214",
      "name": "Twitter",
      "username": "Twitter"
    },
    {
      "id": "1526228120",
      "name": "Twitter Data",
      "username": "TwitterData"
    },
    {
      "id": "2244994945",
      "name": "Twitter Dev",
      "username": "TwitterDev"
    },
    {
      "id": "6253282",
      "name": "Twitter API",
      "username": "TwitterAPI"
    }
  ]
}

Response fields

NameTypeDescription
id
 Default
stringUnique identifier of this user. This is returned as a string in order to avoid complications with languages and tools that cannot handle large integers.
name
 Default
stringThe friendly name of this user, as shown on their profile.
username
 Default
stringThe Twitter handle (screen name) of this user.
created_atdate (ISO 8601)Creation time of this account.

To return this field, add user.fields=created_at in the request’s query parameter.
most_recent_tweet_idstringThe ID of the User’s most recent Tweet

To return this field, add user.fields=most_recent_tweet_id in the request’s query parameter.
protectedbooleanIndicates if this user has chosen to protect their Tweets (in other words, if this user’s Tweets are private).

To return this field, add user.fields=protected in the request’s query parameter.
withheldobjectContains withholding details for withheld content.

To return this field, add user.fields=withheld in the request’s query parameter.
withheld.country_codesarrayProvides a list of countries where this user is not available.

To return this field, add user.fields=withheld.country_codes in the request’s query parameter.
withheld.scopeenum (tweet, user)Indicates whether the content being withheld is a Tweet or a user (this API will return user).

To return this field, add user.fields=withheld.scope in the request’s query parameter.
locationstringThe location specified in the user’s profile, if the user provided one. As this is a freeform value, it may not indicate a valid location, but it may be fuzzily evaluated when performing searches with location queries.

To return this field, add user.fields=location in the request’s query parameter.
urlstringThe URL specified in the user’s profile, if present.

To return this field, add user.fields=url in the request’s query parameter.
descriptionstringThe text of this user’s profile description (also known as bio), if the user provided one.

To return this field, add user.fields=description in the request’s query parameter.
verifiedbooleanIndicate if this user is a verified Twitter user.

To return this field, add user.fields=verified in the request’s query parameter.
entitiesobjectThis object and its children fields contain details about text that has a special meaning in the user’s description.

To return this field, add user.fields=entities in the request’s query parameter.
entities.urlarrayContains details about the user’s profile website.
entities.url.urlsarrayContains details about the user’s profile website.
entities.url.urls.startintegerThe start position (zero-based) of the recognized user’s profile website. All start indices are inclusive.
entities.url.urls.endintegerThe end position (zero-based) of the recognized user’s profile website. This end index is exclusive.
entities.url.urls.urlstringThe URL in the format entered by the user.
entities.url.urls.expanded_urlstringThe fully resolved URL.
entities.url.urls.display_urlstringThe URL as displayed in the user’s profile.
entities.descriptionarrayContains details about URLs, Hashtags, Cashtags, or mentions located within a user’s description.
entities.description.urlsarrayContains details about any URLs included in the user’s description.
entities.description.urls.startintegerThe start position (zero-based) of the recognized URL in the user’s description. All start indices are inclusive.
entities.description.urls.endintegerThe end position (zero-based) of the recognized URL in the user’s description. This end index is exclusive.
entities.description.urls.urlstringThe URL in the format entered by the user.
entities.description.urls.expanded_urlstringThe fully resolved URL.
entities.description.urls.display_urlstringThe URL as displayed in the user’s description.
entities.description.hashtagsarrayContains details about text recognized as a Hashtag.
entities.description.hashtags.startintegerThe start position (zero-based) of the recognized Hashtag within the Tweet. All start indices are inclusive.
entities.description.hashtags.endintegerThe end position (zero-based) of the recognized Hashtag within the Tweet. This end index is exclusive.
entities.description.hashtags.hashtagstringThe text of the Hashtag.
entities.description.mentionsarrayContains details about text recognized as a user mention.
entities.description.mentions.startintegerThe start position (zero-based) of the recognized user mention within the Tweet. All start indices are inclusive.
entities.description.mentions.endintegerThe end position (zero-based) of the recognized user mention within the Tweet. This end index is exclusive.
entities.description.mentions.usernamestringThe part of text recognized as a user mention.
entities.description.cashtagsarrayContains details about text recognized as a Cashtag.
entities.description.cashtags.startintegerThe start position (zero-based) of the recognized Cashtag within the Tweet. All start indices are inclusive.
entities.description.cashtags.endintegerThe end position (zero-based) of the recognized Cashtag within the Tweet. This end index is exclusive.
entities.description.cashtags.cashtagstringThe text of the Cashtag.
profile_image_urlstringThe URL to the profile image for this user, as shown on the user’s profile.
public_metricsobjectContains details about activity for this user.
public_metrics.followers_countintegerNumber of users who follow this user.
public_metrics.following_countintegerNumber of users this user is following.
public_metrics.tweet_countintegerNumber of Tweets (including Retweets) posted by this user.
public_metrics.listed_countintegerNumber of lists that include this user.
pinned_tweet_idstringUnique identifier of this user’s pinned Tweet.

You can obtain the expanded object in includes.tweets by adding expansions=pinned_tweet_id in the request’s query parameter.
includes.tweetsarrayWhen including the expansions=pinned_tweet_id parameter, this includes the pinned Tweets attached to the returned users’ profiles in the form of Tweet objects with their default fields and any additional fields requested using the tweet.fields parameter, assuming there is a referenced Tweet present in the returned Tweet(s).
errorsobjectContains details about errors that affected any of the requested users. See Status codes and error messages for more details.

GET /2/users/:id/liked_tweets

Allows you to get information about a user’s liked Tweets.

The Tweets returned by this endpoint count towards the Project-level Tweet cap.

Endpoint URL

https://api.x.com/2/users/:id/liked_tweets

Authentication and rate limits

Authentication methods
supported by this endpoint
OAuth 2.0 App-only

OAuth 1.0a is also available for this endpoint.

OAuth 2.0 Authorization Code with PKCE
Rate limitApp rate limit (Application-only): 75 requests per 15-minute window shared among all users of your app

User rate limit (User context): 75 requests per 15-minute window per each authenticated user

OAuth 2.0 scopes required by this endpoint

tweet.read

users.read

like.read
Learn more about OAuth 2.0 Authorization Code with PKCE

Path parameters

NameTypeDescription
id
 Required
stringUser ID of the user to request liked Tweets for.

Query parameters

NameTypeDescription
expansions
 Optional
enum (attachments.poll_ids, attachments.media_keys, author_id, edit_history_tweet_ids, entities.mentions.username, geo.place_id, in_reply_to_user_id, referenced_tweets.id, referenced_tweets.id.author_id)Expansions enable you to request additional data objects that relate to the originally returned Tweets. Submit a list of desired expansions in a comma-separated list without spaces. The ID that represents the expanded data object will be included directly in the Tweet data object, but the expanded object metadata will be returned within the includes response object, and will also include the ID so that you can match this data object to the original Tweet object.

The following data objects can be expanded using this parameter:

* The Tweet author’s user object
* The user object of the Tweet’s author that the original Tweet is responding to
* Any mentioned users’ object
* Any referenced Tweets’ author’s user object
* Attached media’s object
* Attached poll’s object
* Attached place’s object
* Any referenced Tweets’ object (this includes Tweet objects for previous versions of an edited Tweet)
max_results
 Optional
integerThe maximum number of results to be returned per page. This can be a number between 10 and 100. By default, each page will return 100 results.
media.fields
 Optional
enum (duration_ms, height, media_key, preview_image_url, type, url, width, public_metrics, non_public_metrics, organic_metrics, promoted_metrics, alt_text, variants)This fields parameter enables you to select which specific media fields will deliver in each returned Tweet. Specify the desired fields in a comma-separated list without spaces between commas and fields. The Tweet will only return media fields if the Tweet contains media and if you’ve also included the expansions=attachments.media_keys query parameter in your request. While the media ID will be located in the Tweet object, you will find this ID and all additional media fields in the includes data object.
pagination_token
 Optional
stringUsed to request the next page of results if all results weren’t returned with the latest request, or to go back to the previous page of results. To return the next page, pass the next_token returned in your previous response. To go back one page, pass the previous_token returned in your previous response.
place.fields
 Optional
enum (contained_within, country, country_code, full_name, geo, id, name, place_type)This fields parameter enables you to select which specific place fields will deliver in each returned Tweet. Specify the desired fields in a comma-separated list without spaces between commas and fields. The Tweet will only return place fields if the Tweet contains a place and if you’ve also included the expansions=geo.place_id query parameter in your request. While the place ID will be located in the Tweet object, you will find this ID and all additional place fields in the includes data object.
poll.fields
 Optional
enum (duration_minutes, end_datetime, id, options, voting_status)This fields parameter enables you to select which specific poll fields will deliver in each returned Tweet. Specify the desired fields in a comma-separated list without spaces between commas and fields. The Tweet will only return poll fields if the Tweet contains a poll and if you’ve also included the expansions=attachments.poll_ids query parameter in your request. While the poll ID will be located in the Tweet object, you will find this ID and all additional poll fields in the includes data object.
tweet.fields
 Optional
enum (attachments, author_id, context_annotations, conversation_id, created_at, edit_controls, entities, geo, id, in_reply_to_user_id, lang, non_public_metrics, public_metrics, organic_metrics, promoted_metrics, possibly_sensitive, referenced_tweets, reply_settings, source, text, withheld)This fields parameter enables you to select which specific Tweet fields will deliver in each returned Tweet object. Specify the desired fields in a comma-separated list without spaces between commas and fields. You can also pass the expansions=referenced_tweets.id expansion to return the specified fields for both the original Tweet and any included referenced Tweets. The requested Tweet fields will display in both the original Tweet data object, as well as in the referenced Tweet expanded data object that will be located in the includes data object.
user.fields
 Optional
enum (created_at, description, entities, id, location, most_recent_tweet_id, name, pinned_tweet_id, profile_image_url, protected, public_metrics, url, username, verified, verified_type, withheld)This fields parameter enables you to select which specific user fields will deliver in each returned Tweet. Specify the desired fields in a comma-separated list without spaces between commas and fields. While the user ID will be located in the original Tweet object, you will find this ID and all additional user fields in the includes data object.

You must also pass one of the user expansions to return the desired user fields:

* expansions=author_id
* expansions=entities.mentions.username
* expansions=in_reply_to_user_id
* expansions=referenced_tweets.id.author_id

Example code with offical SDKs

(async () => {
  try {
    const usersLikedTweets = await twitterClient.tweets.usersIdLikedTweets(
      // The ID of the User to list the liked Tweets of
      "2244994945"
    );
    console.dir(usersLikedTweets, {
      depth: null,
    });
  } catch (error) {
    console.log(error);
  }
})();

Example responses

{
  "data": [
    {
      "id": "1362449997430542337",
      "edit_history_tweet_ids": [
        "1362449997430542337"
      ],
      "text": "Honored to be the first developer to be featured in @TwitterDev's love fest 🥰♥️😍 https://t.co/g8TsPoZsij"
    },
    {
      "id": "1365416026435854338",
      "edit_history_tweet_ids": [
        "1365416026435854338"
      ],
      "text": "We're so happy for our Official Partner @Brandwatch and their big news. https://t.co/3DwWBNSq0o https://t.co/bDUGbgPkKO"
    },
    {
      "id": "1296487407475462144",
      "edit_history_tweet_ids": [
        "1296487407475462144"
      ],
      "text": "Check out this feature on @TwitterDev to learn more about how we're mining social media data to make sense of this evolving #publichealth crisis https://t.co/sIFLXRSvEX."
    },
    {
      "id": "1294346980072624128",
      "edit_history_tweet_ids": [
        "1294346980072624128"
      ],
      "text": "I awake from five years of slumber https://t.co/OEPVyAFcfB"
    },
    {
      "id": "1283153843367206912",
      "edit_history_tweet_ids": [
        "1283153843367206912"
      ],
      "text": "@wongmjane Wish we could tell you more, but I’m only a teapot 👀"
    }
  ]
}

Response fields

NameTypeDescription
id
 Default
stringUnique identifier of this Tweet. This is returned as a string in order to avoid complications with languages and tools that cannot handle large integers.
text
 Default
stringThe content of the Tweet.

To return this field, add tweet.fields=text in the request’s query parameter.
created_atdate (ISO 8601)Creation time of the Tweet.

To return this field, add tweet.fields=created_at in the request’s query parameter.
author_idstringUnique identifier of this user. This is returned as a string in order to avoid complications with languages and tools that cannot handle large integers.

You can obtain the expanded object in includes.users by adding expansions=author_id in the request’s query parameter.
edit_history_tweet_ids
 Default
arrayUnique identifiers indicating all versions of an edited Tweet. For Tweets with no edits, there will be one ID. For Tweets with an edit history, there will be multiple IDs, arranged in ascending order reflecting the order of edit, with the most recent version in the last position of the array.
edit_controlsobjectIndicates if a Tweet is eligible for edit, how long it is editable for, and the number of remaining edits.

The is_edit_eligible field indicates if a Tweet was eligible for edit when published. This field is not dynamic and won’t toggle from True to False when a Tweet reaches its editable time limit, or maximum number of edits. The following Tweet features will cause this field to be false:

* Tweet is promoted
* Tweet has a poll
* Tweet is a non-self-thread reply
* Tweet is a Retweet (note that Quote Tweets are eligible for edit)
* Tweet is nullcast
* Community Tweet
* Superfollow Tweet
* Collaborative Tweet

{ <br/>  "edit_controls": { <br/>   "is_edit_eligible": true, <br/>   "editable_until": "2022-08-21 09:35:20.311", <br/>   "edits_remaining": 4 <br/> } <br/>} <br/>Editable Tweets can be edited for the first 30 minutes after creation and can be edited up to five times.

To return this field, add tweet.fields=edit_controls in the request’s query parameter.
conversation_idstringThe Tweet ID of the original Tweet of the conversation (which includes direct replies, replies of replies).

To return this field, add tweet.fields=conversation_id in the request’s query parameter.
note_tweetobjectInformation about Tweets with more than 280 characters.

To return this field, add tweet.fields=note_tweet in the request’s query parameter.
in_reply_to_user_idstringIf this Tweet is a Reply, indicates the user ID of the parent Tweet’s author. This is returned as a string in order to avoid complications with languages and tools that cannot handle large integers.

You can obtain the expanded object in includes.users by adding expansions=in_reply_to_user_id in the request’s query parameter.
referenced_tweetsarrayA list of Tweets this Tweet refers to. For example, if the parent Tweet is a Retweet, a Retweet with comment (also known as Quoted Tweet) or a Reply, it will include the related Tweet referenced to by its parent.

To return this field, add tweet.fields=referenced_tweets in the request’s query parameter.
referenced_tweets.typeenum (retweeted, quoted, replied_to)Indicates the type of relationship between this Tweet and the Tweet returned in the response: retweeted (this Tweet is a Retweet), quoted (a Retweet with comment, also known as Quoted Tweet), or replied_to (this Tweet is a reply).
referenced_tweets.idstringThe unique identifier of the referenced Tweet.

You can obtain the expanded object in includes.tweets by adding expansions=referenced_tweets.id in the request’s query parameter.
attachmentsobjectSpecifies the type of attachments (if any) present in this Tweet.

To return this field, add tweet.fields=attachments in the request’s query parameter.
attachments.media_keysarrayList of unique identifiers of media attached to this Tweet. These identifiers use the same media key format as those returned by the Media Library.

You can obtain the expanded object in includes.media by adding expansions=attachments.media_keys in the request’s query parameter.
attachments.poll_idsarrayList of unique identifiers of polls present in the Tweets returned. These are returned as a string in order to avoid complications with languages and tools that cannot handle large integers.

You can obtain the expanded object in includes.polls by adding expansions=attachments.polls_ids in the request’s query parameter.
geoobjectContains details about the location tagged by the user in this Tweet, if they specified one.

To return this field, add tweet.fields=geo in the request’s query parameter.
geo.coordinatesobjectContains details about the coordinates of the location tagged by the user in this Tweet, if they specified one.

To return this field, add tweet.fields=geo.coordinates in the request’s query parameter.
geo.coordinates.typestringDescribes the type of coordinate. The only value supported at present is Point.
geo.coordinates.coordinatesarrayA pair of decimal values representing the precise location of the user (latitude, longitude). This value be null unless the user explicitly shared their precise location.
geo.place_idstringThe unique identifier of the place, if this is a point of interest tagged in the Tweet.

You can obtain the expanded object in includes.places by adding expansions=geo.place_id in the request’s query parameter.
context_annotationsarrayContains context annotations for the Tweet.

To return this field, add tweet.fields=context_annotations in the request’s query parameter.
context_annotations.domainobjectContains elements which identify detailed information regarding the domain classification based on Tweet text.
context_annotations.domain.idstringContains the numeric value of the domain.
context_annotations.domain.namestringDomain name based on the Tweet text.
context_annotations.domain.descriptionstringLong form description of domain classification.
context_annotations.entityobjectContains elements which identify detailed information regarding the domain classification bases on Tweet text.
context_annotations.entity.idstringUnique value which correlates to an explicitly mentioned Person, Place, Product or Organization
context_annotations.entity.namestringName or reference of entity referenced in the Tweet.
context_annotations.entity.descriptionstringAdditional information regarding referenced entity.
entitiesobjectContains details about text that has a special meaning in a Tweet.

To return this field, add tweet.fields=entities in the request’s query parameter.
entities.annotationsarrayContains details about annotations relative to the text within a Tweet.
entities.annotations.startintegerThe start position (zero-based) of the text used to annotate the Tweet. All start indices are inclusive.
entities.annotations.endintegerThe end position (zero based) of the text used to annotate the Tweet. While all other end indices are exclusive, this one is inclusive.
entities.annotations.probabilitynumberThe confidence score for the annotation as it correlates to the Tweet text.
entities.annotations.typestringThe description of the type of entity identified when the Tweet text was interpreted.
entities.annotations.normalized_textstringThe text used to determine the annotation type.
entities.urlsarrayContains details about text recognized as a URL.
entities.urls.startintegerThe start position (zero-based) of the recognized URL within the Tweet. All start indices are inclusive.
entities.urls.endintegerThe end position (zero-based) of the recognized URL within the Tweet. This end index is exclusive.
entities.urls.urlstringThe URL in the format tweeted by the user.
entities.urls.expanded_urlstringThe fully resolved URL.
entities.urls.display_urlstringThe URL as displayed in the Twitter client.
entities.urls.unwound_urlstringThe full destination URL.
entities.hashtagsarrayContains details about text recognized as a Hashtag.
entities.hashtags.startintegerThe start position (zero-based) of the recognized Hashtag within the Tweet. All start indices are inclusive.
entities.hashtags.endintegerThe end position (zero-based) of the recognized Hashtag within the Tweet. This end index is exclusive.
entities.hashtags.tagstringThe text of the Hashtag.
entities.mentionsarrayContains details about text recognized as a user mention.
entities.mentions.startintegerThe start position (zero-based) of the recognized user mention within the Tweet. All start indices are inclusive.
entities.mentions.endintegerThe end position (zero-based) of the recognized user mention within the Tweet. This end index is exclusive.
entities.mentions.usernamestringThe part of text recognized as a user mention.

You can obtain the expanded object in includes.users by adding expansions=entities.mentions.username in the request’s query parameter.
entities.cashtagsarrayContains details about text recognized as a Cashtag.
entities.cashtags.startintegerThe start position (zero-based) of the recognized Cashtag within the Tweet. All start indices are inclusive.
entities.cashtags.endintegerThe end position (zero-based) of the recognized Cashtag within the Tweet. This end index is exclusive.
entities.cashtags.tagstringThe text of the Cashtag.
withheldobjectContains withholding details for withheld content.

To return this field, add tweet.fields=withheld in the request’s query parameter.
withheld.copyrightbooleanIndicates if the content is being withheld for on the basis of copyright infringement.
withheld.country_codesarrayProvides a list of countries where this content is not available.
withheld.scopeenum (tweet, user)Indicates whether the content being withheld is a Tweet or a user.
note_tweetobjectInformation for Tweets longer than 280 characters.

To return this field, add tweet.fields=note_tweet in the request’s query parameter.
note_tweet.textstringThe text for Tweets longer than 280 characters.
note_tweet.entitiesobjectContains details about text that has a special meaning in a Tweet.
note_tweet.entities.urlsarrayContains details about text recognized as a URL.
note_tweet.entities.mentionsarrayContains details about text recognized as a user mention.
note_tweet.entities.hashtagsarrayContains details about text recognized as a Hashtag.
note_tweet.entities.cashtagsarrayContains details about text recognized as a Cashtag.
public_metricsobjectEngagement metrics for the Tweet at the time of the request.

To return this field, add tweet.fields=public_metrics in the request’s query parameter.
public_metrics.retweet_countintegerNumber of times this Tweet has been Retweeted.
public_metrics.reply_countintegerNumber of Replies of this Tweet.
public_metrics.like_countintegerNumber of Likes of this Tweet.
public_metrics.quote_countintegerNumber of times this Tweet has been Retweeted with a comment (also known as Quote).
public_metrics.impression_countintegerNumber of times this Tweet has been viewed.
public_metrics.bookmark_countintegerNumber of times this Tweet has been bookmarked.
non_public_metricsobjectNon-public engagement metrics for the Tweet at the time of the request. This is a private metric, and requires the use of OAuth 2.0 User Context authentication.

To return this field, add tweet.fields=non_public_metrics in the request’s query parameter.
non_public_metrics.impression_countintegerNumber of times the Tweet has been viewed. This requires the use of OAuth 2.0 User Context authentication.
non_public_metrics.url_link_clicksintegerNumber of times a user clicks on a URL link or URL preview card in a Tweet. This is a private metric, and requires the use of OAuth 2.0 User Context authentication.
non_public_metrics.user_profile_clicksintegerNumber of times a user clicks the following portions of a Tweet - display name, user name, profile picture. This is a private metric, and requires the use of OAuth 2.0 User Context authentication.
organic_metricsobjectOrganic engagement metrics for the Tweet at the time of the request. Requires user context authentication.
organic_metrics.impression_countintegerNumber of times the Tweet has been viewed organically. This is a private metric, and requires the use of OAuth 2.0 User Context authentication.
organic_metrics.url_link_clicksintegerNumber of times a user clicks on a URL link or URL preview card in a Tweet organically. This is a private metric, and requires the use of OAuth 2.0 User Context authentication.
organic_metrics.user_profile_clicksintegerNumber of times a user clicks the following portions of a Tweet organically - display name, user name, profile picture. This is a private metric, and requires the use of OAuth 2.0 User Context authentication.
organic_metrics.retweet_countintegerNumber of times the Tweet has been Retweeted organically.
organic_metrics.reply_countintegerNumber of replies the Tweet has received organically.
organic_metrics.like_countintegerNumber of likes the Tweet has received organically.
promoted_metricsobjectEngagement metrics for the Tweet at the time of the request in a promoted context. Requires user context authentication.
promoted_metrics.impression_countintegerNumber of times the Tweet has been viewed when that Tweet is being promoted. This is a private metric, and requires the use of OAuth 2.0 User Context authentication.
promoted_metrics.url_link_clicksintegerNumber of times a user clicks on a URL link or URL preview card in a Tweet when it is being promoted. This is a private metric, and requires the use of OAuth 2.0 User Context authentication.
promoted_metrics.user_profile_clicksintegerNumber of times a user clicks the following portions of a Tweet when it is being promoted - display name, user name, profile picture. This is a private metric, and requires the use of OAuth 2.0 User Context authentication.
promoted_metrics.retweet_countintegerNumber of times this Tweet has been Retweeted when that Tweet is being promoted.
promoted_metrics.reply_countintegerNumber of Replies to this Tweet when that Tweet is being promoted.
promoted_metrics.like_countintegerNumber of Likes of this Tweet when that Tweet is being promoted.
possibly_sensitivebooleanIndicates if this Tweet contains URLs marked as sensitive, for example content suitable for mature audiences.

To return this field, add tweet.fields=possibly_sensitive in the request’s query parameter.
langstringLanguage of the Tweet, if detected by Twitter. Returned as a BCP47 language tag.

To return this field, add tweet.fields=lang in the request’s query parameter.
reply_settingsstringShows who can reply to this Tweet. Fields returned are everyone, mentionedUsers, and following.

To return this field, add tweet.fields=reply_settings in the request’s query parameter.
sourcestringThe name of the app the user Tweeted from.

To return this field, add tweet.fields=source in the request’s query parameter.
includesobjectIf you include an [expansion](/x-api/x-api-v2/fundamentals/expansions) parameter, the referenced objects will be returned if available.
includes.tweetsarrayWhen including the expansions=referenced_tweets.id parameter, this includes a list of referenced Retweets, Quoted Tweets, or replies in the form of Tweet objects with their default fields and any additional fields requested using the tweet.fields parameter, assuming there is a referenced Tweet present in the returned Tweet(s). Similarly, when including the expansions=edit_history_tweet_ids parameter, a Tweet’s edit history will be referenced in the form of Tweet objects.
includes.usersarrayWhen including the expansions=author_id parameter, this includes a list of referenced Tweet authors in the form of user objects with their default fields and any additional fields requested using the user.fields parameter.
includes.placesarrayWhen including the expansions=geo.place_id parameter, this includes a list of referenced places in Tweets in the form of place objects with their default fields and any additional fields requested using the place.fields parameter, assuming there is a place present in the returned Tweet(s).
includes.mediaarrayWhen including the expansions=attachments.media_keys parameter, this includes a list of images, videos, and GIFs included in Tweets in the form of media objects with their default fields and any additional fields requested using the media.fields parameter, assuming there is a media attachment present in the returned Tweet(s).
includes.pollsstringWhen including the expansions=attachments.poll_ids parameter, this includes a list of polls that are attached to Tweets in the form of poll objects with their default fields and any additional fields requested using the poll.fields parameter, assuming there is a poll present in the returned Tweet(s).
errorsobjectContains details about errors that affected any of the requested Tweets. See Status codes and error messages for more details.

POST /2/users/:id/likes

Causes the user ID identified in the path parameter to Like the target Tweet.

Endpoint URL

https://api.x.com/2/users/:id/likes

Authentication and rate limits

Authentication methods
supported by this endpoint
OAuth 2.0 Authorization Code with PKCE

OAuth 1.0a is also available for this endpoint.
Rate limitUser rate limit (User context): 50 requests per 15-minute window per each authenticated user

OAuth 2.0 scopes required by this endpoint

tweet.read

users.read

like.write
Learn more about OAuth 2.0 Authorization Code with PKCE

Path parameters

NameTypeDescription
id
 Required
stringThe user ID who you are liking a Tweet on behalf of. It must match your own user ID or that of an authenticating user, meaning that you must pass the Access Tokens associated with the user ID when authenticating your request.

JSON body parameters

NameTypeDescription
tweet_id
 Required
stringThe ID of the Tweet that you would like the user id to Like.

Example code with offical SDKs

(async () => {
  try {
    const likeTweet = await twitterClient.tweets.usersIdLike(
      // The ID of the user that is requesting to like the tweet
      "1324848235714736129",

      {
        // The ID of the tweet that the user is requesting to like
        tweet_id: "1521887626935947265",
      }
    );
    console.dir(likeTweet, {
      depth: null,
    });
  } catch (error) {
    console.log(error);
  }
})();

Example responses

{
  "data": {
    "liked": true
  }
}

Response fields

NameTypeDescription
likedbooleanIndicates whether the user likes the specified Tweet as a result of this request.

DELETE /2/users/:id/likes/:tweet_id

Allows a user or authenticated user ID to unlike a Tweet.

The request succeeds with no action when the user sends a request to a user they’re not liking the Tweet or have already unliked the Tweet.

Endpoint URL

https://api.x.com/2/users/:id/likes/:tweet_id

Authentication and rate limits

Authentication methods
supported by this endpoint
OAuth 2.0 Authorization Code with PKCE

OAuth 1.0a is also available for this endpoint.
Rate limitUser rate limit (User context): 50 requests per 15-minute window per each authenticated user

OAuth 2.0 scopes required by this endpoint

tweet.read

users.read

like.write
Learn more about OAuth 2.0 Authorization Code with PKCE

Path parameters

NameTypeDescription
id
 Required
stringThe user ID who you are removing a Like of a Tweet on behalf of. It must match your own user ID or that of an authenticating user, meaning that you must pass the Access Tokens) associated with the user ID when authenticating your request.
tweet_id
 Required
stringThe ID of the Tweet that you would like the id to unlike.

Example code with offical SDKs

(async () => {
  try {
    const unlikeTweet = await twitterClient.tweets.usersIdUnlike(
      // The ID of the user that is requesting to unlike the tweet
      "2244994945",

      // The ID of the tweet that the user is requesting to unlike
      "1228393702244134912"
    );
    console.dir(unlikeTweet, {
      depth: null,
    });
  } catch (error) {
    console.log(error);
  }
})();

Example responses

{
  "data": {
    "liked": false
  }
}

Response fields

NameTypeDescription
likedbooleanIndicates whether the user is unliking the specified Tweet as a result of this request. The returned value is false for a successful unlike request.