# User likes

`GET https://api.twittrapi.com/user/{userId}/likes`

Tweets a user has liked.

HTML page: https://www.twittrapi.com/docs/reference/user-userid-likes

## Parameters

| Name | In | Type | Required | Default | Description |
| --- | --- | --- | --- | --- | --- |
| `userId` | path | string | yes |  | Numeric user ID (digits only, up to 30). To pass a handle instead, use -1 here and set username. |
| `username` | query | string | no |  | Handle, with or without @. When set, it is used instead of userId: the API looks up the ID first, which makes the call a little slower. Still one billed call. |
| `count` | query | integer | no | 20 | Number of items to ask X for. Sent to X as is; X treats it as a hint and decides how many it returns (follower and following pages often hold 50 to 70 users for count=20). A value that is not a number falls back to 20. |
| `cursor` | query | string | no |  | Bottom cursor from the previous page. Leave it out for the first page. See Pagination. |

Every read endpoint also accepts `format=simple` (or the header `X-Response-Format: simple`) for compact, flat JSON with a fixed schema. Same price.

Paginated: pass the bottom cursor of one page as `cursor` to get the next. Each page is one billed call.

## Notes

- X made likes private in June 2024 and shows them only to the account owner. The API does not read as the owner, so the result is empty: {"data": {"user": {"result": {"__typename": "User", "timeline": {}}}}}, without instructions or cursor.

## Response

Raw JSON of X's Likes query.

With `format=simple`: Collection of Tweet objects: {data: [Tweet], nextCursor, previousCursor, hasNextPage}. Empty since X made likes private: {data: [], nextCursor: null}.

## Errors

| Status | When |
| --- | --- |
| 422 | userId is not numeric, or the username lookup failed. |
| 400 | userId is -1 and username is missing, the username contains characters X blocks, or the user could not be found. |

Shared errors (401 missing key, 402 no balance, 429 rate limit, 5xx) are listed on https://www.twittrapi.com/docs/helpful-infos/error-handling. Calls that fail with 400, 408, 409 or a 5xx error are refunded.

## Example request

curl:

```bash
curl 'https://api.twittrapi.com/user/12/likes?count=20' \
  --header 'X-API-KEY: YOUR_API_KEY'
```

Python:

```python
import httpx

# No SDK method for this endpoint yet, so this is a plain HTTP call.
resp = httpx.get(
    "https://api.twittrapi.com/user/12/likes",
    headers={"X-API-KEY": "YOUR_API_KEY"},
    params={
        "count": "20",
    },
    timeout=60,
)
data = resp.json()
```

Node.js:

```js
import { TwittrAPI } from "twittrapi";

const client = new TwittrAPI({ apiKey: process.env.TWITTRAPI_API_KEY });
// No wrapper method for this endpoint yet; client.get() sends the same authenticated GET.
const data = await client.get({
  path: "/user/12/likes",
  query: {
    count: "20",
  },
});
```

RapidAPI:

```bash
curl 'https://twitter-aio.p.rapidapi.com/user/12/likes?count=20' \
  --header 'x-rapidapi-key: YOUR_RAPIDAPI_KEY' \
  --header 'x-rapidapi-host: twitter-aio.p.rapidapi.com'
```

## Example response

Shortened: arrays keep their first items and long strings are cut.

Raw (default):

```json
{
  "data": {
    "user": {
      "result": {
        "__typename": "User",
        "timeline": {}
      }
    }
  }
}
```

Simple (`format=simple`):

```json
{
  "data": [],
  "nextCursor": null,
  "previousCursor": null,
  "hasNextPage": false
}
```
