Likes
Liking Posts is one of the core features people use to engage in the public conversation on X. With endpoints in our Likes lookup endpoint group, you can see a list of accounts that have liked a given Post, or which Posts a given account has liked. You could use these endpoints to understand what kind of content a specified account or group of accounts likes.
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:
-
Apply for a developer account and receive approval.
-
Create a Project and an associated developer App in the developer portal.
-
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:
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.
Key | Value |
id | The 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:
- The additional user.created_at field in the primary user objects.
- The associated pinned Tweets’ object’s default fields for the returned users: id and text.
- 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:
Key | Value | Returned fields |
user.fields | created_at | user.created_at |
expansions | pinned_tweet_id | tweet.id, tweet.text |
tweet.fields | created_at | tweet.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:
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.
Key | Value |
id | The user ID you want to get the liked Tweets of |
max_results | 5 |
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:
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:
-
Apply for a developer account and receive approval.
-
Create a Project and an associated developer App in the developer portal.
-
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:
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:
- Using the user lookup by username endpoint, you can pass a username and receive the id field.
- 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.
Key | Value |
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:
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.
Description | X API v2 |
---|---|
HTTP methods supported | GET |
Host domain | https://api.x.com |
Endpoint path | /2/tweets/:id/liking_users |
Authentication | OAuth 2.0 Bearer Token OAuth 1.0a User Context |
Default request rate limits | 75 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:
Description | Standard v1.1 | X API v2 |
---|---|---|
HTTP methods supported | GET | GET |
Host domain | https://api.x.com | https://api.x.com |
Endpoint path | /1.1/favorites/list.json | /2/users/:id/liked_tweets |
Authentication | OAuth 1.0a User Context | OAuth 2.0 Bearer Token OAuth 1.0a User Context |
Default request rate limits | 75 requests per 15 min | 75 requests per 15 min (per App) 75 requests per 15 min (per user) |
Data formats | Standard v1.1 format | X 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
Description | Standard v1.1 | X API v2 |
---|---|---|
HTTP methods supported | POST | POST |
Host domain | https://api.x.com | https://api.x.com |
Endpoint path | /1.1/favorites/create.json | /2/users/:id/likes |
Authentication | OAuth 1.0a User Context | OAuth 1.0a User Context |
Default request rate limits | 1000 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
Description | Standard v1.1 | X API v2 |
---|---|---|
HTTP methods supported | POST | DELETE |
Host domain | https://api.x.com | https://api.x.com |
Endpoint path | /1.1/favorites/destroy.json | /2/users/:id/likes/:tweet_id |
Authentication | OAuth 1.0a User Context | OAuth 1.0a User Context |
Default request rate limits | 1000 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
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
- Standard v1.1 endpoints:
- GET https://api.x.com/1.1/favorites/list.json (list of Posts which are by the specified user)
- There is no v1.1 equivalent to the v2 liking users endpoint
- X API v2 endpoint:
- GET https://api.x.com/2/users/:id/liked_tweets (list of Posts which are liked by the specified user ID)
- GET https://api.x.com/2/tweets/:id/liking_users (list of users who liked the specified Post ID)
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:
- conversation_id
- Two new Post annotations fields, including context and entities
- Several new metrics fields
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
- Standard v1.1 endpoints:
- POST https://api.x.com/1.1/favorites/create.json (like a Post)
- POST https://api.x.com/1.1/favorites/destroy.json (unlike a Post)
- X API v2 endpoint:
- POST https://api.x.com/2/tweets/:id/likes (like a Post)
- DELETE https://api.x.com/2/tweets/:id/likes/:tweet_id (unlike a Post)
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.1 | X API v2 |
---|---|
id | id |
includes_entities | No 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 Post | GET /2/tweets/:id/liking_users |
Posts liked by a user | GET /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 limit | User 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
Name | Type | Description |
---|---|---|
id Required | string | The 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 | string | The ID of the Tweet that you would like the id to unlike. |
Example requests
Example responses
Response fields
Name | Type | Description |
---|---|---|
liked | boolean | Indicates 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 limit | App 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
Name | Type | Description |
---|---|---|
id Required | string | Tweet ID of the Tweet to request liking users of. |
Query parameters
Name | Type | Description |
---|---|---|
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 | integer | The 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 | string | Used 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
Example responses
Response fields
Name | Type | Description |
---|---|---|
id Default | string | Unique 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 | string | The friendly name of this user, as shown on their profile. |
username Default | string | The Twitter handle (screen name) of this user. |
created_at | date (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_id | string | The 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. |
protected | boolean | Indicates 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. |
withheld | object | Contains withholding details for withheld content. To return this field, add user.fields=withheld in the request’s query parameter. |
withheld.country_codes | array | Provides 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.scope | enum (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. |
location | string | The 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. |
url | string | The URL specified in the user’s profile, if present. To return this field, add user.fields=url in the request’s query parameter. |
description | string | The 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. |
verified | boolean | Indicate if this user is a verified Twitter user. To return this field, add user.fields=verified in the request’s query parameter. |
entities | object | This 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.url | array | Contains details about the user’s profile website. |
entities.url.urls | array | Contains details about the user’s profile website. |
entities.url.urls.start | integer | The start position (zero-based) of the recognized user’s profile website. All start indices are inclusive. |
entities.url.urls.end | integer | The end position (zero-based) of the recognized user’s profile website. This end index is exclusive. |
entities.url.urls.url | string | The URL in the format entered by the user. |
entities.url.urls.expanded_url | string | The fully resolved URL. |
entities.url.urls.display_url | string | The URL as displayed in the user’s profile. |
entities.description | array | Contains details about URLs, Hashtags, Cashtags, or mentions located within a user’s description. |
entities.description.urls | array | Contains details about any URLs included in the user’s description. |
entities.description.urls.start | integer | The start position (zero-based) of the recognized URL in the user’s description. All start indices are inclusive. |
entities.description.urls.end | integer | The end position (zero-based) of the recognized URL in the user’s description. This end index is exclusive. |
entities.description.urls.url | string | The URL in the format entered by the user. |
entities.description.urls.expanded_url | string | The fully resolved URL. |
entities.description.urls.display_url | string | The URL as displayed in the user’s description. |
entities.description.hashtags | array | Contains details about text recognized as a Hashtag. |
entities.description.hashtags.start | integer | The start position (zero-based) of the recognized Hashtag within the Tweet. All start indices are inclusive. |
entities.description.hashtags.end | integer | The end position (zero-based) of the recognized Hashtag within the Tweet. This end index is exclusive. |
entities.description.hashtags.hashtag | string | The text of the Hashtag. |
entities.description.mentions | array | Contains details about text recognized as a user mention. |
entities.description.mentions.start | integer | The start position (zero-based) of the recognized user mention within the Tweet. All start indices are inclusive. |
entities.description.mentions.end | integer | The end position (zero-based) of the recognized user mention within the Tweet. This end index is exclusive. |
entities.description.mentions.username | string | The part of text recognized as a user mention. |
entities.description.cashtags | array | Contains details about text recognized as a Cashtag. |
entities.description.cashtags.start | integer | The start position (zero-based) of the recognized Cashtag within the Tweet. All start indices are inclusive. |
entities.description.cashtags.end | integer | The end position (zero-based) of the recognized Cashtag within the Tweet. This end index is exclusive. |
entities.description.cashtags.cashtag | string | The text of the Cashtag. |
profile_image_url | string | The URL to the profile image for this user, as shown on the user’s profile. |
public_metrics | object | Contains details about activity for this user. |
public_metrics.followers_count | integer | Number of users who follow this user. |
public_metrics.following_count | integer | Number of users this user is following. |
public_metrics.tweet_count | integer | Number of Tweets (including Retweets) posted by this user. |
public_metrics.listed_count | integer | Number of lists that include this user. |
pinned_tweet_id | string | Unique 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.tweets | array | When 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). |
errors | object | Contains 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 limit | App 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
Name | Type | Description |
---|---|---|
id Required | string | User ID of the user to request liked Tweets for. |
Query parameters
Name | Type | Description |
---|---|---|
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 | integer | The 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 | string | Used 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
Example responses
Response fields
Name | Type | Description |
---|---|---|
id Default | string | Unique 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 | string | The content of the Tweet. To return this field, add tweet.fields=text in the request’s query parameter. |
created_at | date (ISO 8601) | Creation time of the Tweet. To return this field, add tweet.fields=created_at in the request’s query parameter. |
author_id | string | Unique 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 | array | Unique 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_controls | object | Indicates 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_id | string | The 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_tweet | object | Information 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_id | string | If 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_tweets | array | A 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.type | enum (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.id | string | The 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. |
attachments | object | Specifies 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_keys | array | List 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_ids | array | List 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. |
geo | object | Contains 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.coordinates | object | Contains 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.type | string | Describes the type of coordinate. The only value supported at present is Point . |
geo.coordinates.coordinates | array | A 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_id | string | The 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_annotations | array | Contains context annotations for the Tweet. To return this field, add tweet.fields=context_annotations in the request’s query parameter. |
context_annotations.domain | object | Contains elements which identify detailed information regarding the domain classification based on Tweet text. |
context_annotations.domain.id | string | Contains the numeric value of the domain. |
context_annotations.domain.name | string | Domain name based on the Tweet text. |
context_annotations.domain.description | string | Long form description of domain classification. |
context_annotations.entity | object | Contains elements which identify detailed information regarding the domain classification bases on Tweet text. |
context_annotations.entity.id | string | Unique value which correlates to an explicitly mentioned Person, Place, Product or Organization |
context_annotations.entity.name | string | Name or reference of entity referenced in the Tweet. |
context_annotations.entity.description | string | Additional information regarding referenced entity. |
entities | object | Contains 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.annotations | array | Contains details about annotations relative to the text within a Tweet. |
entities.annotations.start | integer | The start position (zero-based) of the text used to annotate the Tweet. All start indices are inclusive. |
entities.annotations.end | integer | The 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.probability | number | The confidence score for the annotation as it correlates to the Tweet text. |
entities.annotations.type | string | The description of the type of entity identified when the Tweet text was interpreted. |
entities.annotations.normalized_text | string | The text used to determine the annotation type. |
entities.urls | array | Contains details about text recognized as a URL. |
entities.urls.start | integer | The start position (zero-based) of the recognized URL within the Tweet. All start indices are inclusive. |
entities.urls.end | integer | The end position (zero-based) of the recognized URL within the Tweet. This end index is exclusive. |
entities.urls.url | string | The URL in the format tweeted by the user. |
entities.urls.expanded_url | string | The fully resolved URL. |
entities.urls.display_url | string | The URL as displayed in the Twitter client. |
entities.urls.unwound_url | string | The full destination URL. |
entities.hashtags | array | Contains details about text recognized as a Hashtag. |
entities.hashtags.start | integer | The start position (zero-based) of the recognized Hashtag within the Tweet. All start indices are inclusive. |
entities.hashtags.end | integer | The end position (zero-based) of the recognized Hashtag within the Tweet. This end index is exclusive. |
entities.hashtags.tag | string | The text of the Hashtag. |
entities.mentions | array | Contains details about text recognized as a user mention. |
entities.mentions.start | integer | The start position (zero-based) of the recognized user mention within the Tweet. All start indices are inclusive. |
entities.mentions.end | integer | The end position (zero-based) of the recognized user mention within the Tweet. This end index is exclusive. |
entities.mentions.username | string | The 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.cashtags | array | Contains details about text recognized as a Cashtag. |
entities.cashtags.start | integer | The start position (zero-based) of the recognized Cashtag within the Tweet. All start indices are inclusive. |
entities.cashtags.end | integer | The end position (zero-based) of the recognized Cashtag within the Tweet. This end index is exclusive. |
entities.cashtags.tag | string | The text of the Cashtag. |
withheld | object | Contains withholding details for withheld content. To return this field, add tweet.fields=withheld in the request’s query parameter. |
withheld.copyright | boolean | Indicates if the content is being withheld for on the basis of copyright infringement. |
withheld.country_codes | array | Provides a list of countries where this content is not available. |
withheld.scope | enum (tweet , user ) | Indicates whether the content being withheld is a Tweet or a user. |
note_tweet | object | Information for Tweets longer than 280 characters. To return this field, add tweet.fields=note_tweet in the request’s query parameter. |
note_tweet.text | string | The text for Tweets longer than 280 characters. |
note_tweet.entities | object | Contains details about text that has a special meaning in a Tweet. |
note_tweet.entities.urls | array | Contains details about text recognized as a URL. |
note_tweet.entities.mentions | array | Contains details about text recognized as a user mention. |
note_tweet.entities.hashtags | array | Contains details about text recognized as a Hashtag. |
note_tweet.entities.cashtags | array | Contains details about text recognized as a Cashtag. |
public_metrics | object | Engagement 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_count | integer | Number of times this Tweet has been Retweeted. |
public_metrics.reply_count | integer | Number of Replies of this Tweet. |
public_metrics.like_count | integer | Number of Likes of this Tweet. |
public_metrics.quote_count | integer | Number of times this Tweet has been Retweeted with a comment (also known as Quote). |
public_metrics.impression_count | integer | Number of times this Tweet has been viewed. |
public_metrics.bookmark_count | integer | Number of times this Tweet has been bookmarked. |
non_public_metrics | object | Non-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_count | integer | Number of times the Tweet has been viewed. This requires the use of OAuth 2.0 User Context authentication. |
non_public_metrics.url_link_clicks | integer | Number 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_clicks | integer | Number 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_metrics | object | Organic engagement metrics for the Tweet at the time of the request. Requires user context authentication. |
organic_metrics.impression_count | integer | Number 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_clicks | integer | Number 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_clicks | integer | Number 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_count | integer | Number of times the Tweet has been Retweeted organically. |
organic_metrics.reply_count | integer | Number of replies the Tweet has received organically. |
organic_metrics.like_count | integer | Number of likes the Tweet has received organically. |
promoted_metrics | object | Engagement metrics for the Tweet at the time of the request in a promoted context. Requires user context authentication. |
promoted_metrics.impression_count | integer | Number 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_clicks | integer | Number 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_clicks | integer | Number 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_count | integer | Number of times this Tweet has been Retweeted when that Tweet is being promoted. |
promoted_metrics.reply_count | integer | Number of Replies to this Tweet when that Tweet is being promoted. |
promoted_metrics.like_count | integer | Number of Likes of this Tweet when that Tweet is being promoted. |
possibly_sensitive | boolean | Indicates 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. |
lang | string | Language 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_settings | string | Shows 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. |
source | string | The name of the app the user Tweeted from. To return this field, add tweet.fields=source in the request’s query parameter. |
includes | object | If you include an [expansion](/x-api/x-api-v2/fundamentals/expansions) parameter, the referenced objects will be returned if available. |
includes.tweets | array | When 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.users | array | When 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.places | array | When 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.media | array | When 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.polls | string | When 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). |
errors | object | Contains 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 limit | User 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
Name | Type | Description |
---|---|---|
id Required | string | The 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
Name | Type | Description |
---|---|---|
tweet_id Required | string | The ID of the Tweet that you would like the user id to Like. |
Example code with offical SDKs
Example responses
Response fields
Name | Type | Description |
---|---|---|
liked | boolean | Indicates 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 limit | User 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
Name | Type | Description |
---|---|---|
id Required | string | The 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 | string | The ID of the Tweet that you would like the id to unlike. |
Example code with offical SDKs
Example responses
Response fields
Name | Type | Description |
---|---|---|
liked | boolean | Indicates whether the user is unliking the specified Tweet as a result of this request. The returned value is false for a successful unlike request. |