# User media

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

Tweets with photos or videos from a profile.

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

## 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.

## Response

Raw JSON of X's UserMedia query.

With `format=simple`: Collection of Tweet objects: {data: [Tweet], nextCursor, previousCursor, hasNextPage}.

## 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/media?count=20' \
  --header 'X-API-KEY: YOUR_API_KEY'
```

Python:

```python
from twittrapi import TwittrAPI

client = TwittrAPI(api_key="YOUR_API_KEY")
data = client.users.media("12", count=20)
```

Node.js:

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

const client = new TwittrAPI({ apiKey: process.env.TWITTRAPI_API_KEY });
const data = await client.users.media({ userId: "12", count: 20 });
```

RapidAPI:

```bash
curl 'https://twitter-aio.p.rapidapi.com/user/12/media?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": {
          "timeline": {
            "instructions": [
              {
                "type": "TimelineClearCache"
              },
              {
                "direction": "Top",
                "type": "TimelineTerminateTimeline"
              },
              {
                "entries": [
                  {
                    "content": {
                      "__typename": "TimelineTimelineModule",
                      "clientEventInfo": {
                        "component": "profile-media"
                      },
                      "displayType": "VerticalGrid",
                      "entryType": "TimelineTimelineModule",
                      "items": [
                        {
                          "entryId": "profile-grid-0-tweet-2107952086193508716",
                          "item": {
                            "itemContent": {
                              "…": "…"
                            }
                          }
                        }
                      ]
                    },
                    "entryId": "profile-grid-0",
                    "sortIndex": "2109014658881945600"
                  },
                  "… 2 more"
                ],
                "type": "TimelineAddEntries"
              }
            ],
            "metadata": {
              "scribeConfig": {
                "page": "media"
              }
            }
          }
        }
      }
    }
  }
}
```

Simple (`format=simple`):

```json
{
  "data": [
    {
      "id": "2107952086193508716",
      "url": "https://x.com/XDevelopers/status/2107952086193508716",
      "text": "The Developer E𝕏hibit just got a major upgrade. 🚀\n\nRebuilt from the ground up to help you showcase your X API app and get discovered:\n\n• All-new UI with more ways to customize your listing\n• Submit …",
      "createdAt": "2026-10-07T21:51:55Z",
      "lang": "en",
      "author": {
        "id": "2244994945",
        "username": "XDevelopers",
        "name": "Developers",
        "description": "The voice of the X Dev team and your official source for updates, news, and events, related to the X API.",
        "location": "127.0.0.1",
        "url": "https://docs.x.com/",
        "createdAt": "2013-12-14T04:35:55Z",
        "avatarUrl": "https://pbs.twimg.com/profile_images/1683501992314798080/xl1POYLw.jpg",
        "bannerUrl": "https://pbs.twimg.com/profile_banners/2244994945/1690213128",
        "verified": true,
        "verifiedType": "Business",
        "protected": false,
        "counts": {
          "followers": 698074,
          "following": 770,
          "tweets": 4376,
          "likes": 2758,
          "media": 832,
          "listed": 2977
        },
        "pinnedTweetIds": [
          "2019881223666233717"
        ],
        "isAutomated": false
      },
      "counts": {
        "likes": 230,
        "retweets": 31,
        "replies": 16,
        "quotes": 4,
        "bookmarks": 76,
        "views": 23589
      },
      "media": [
        {
          "type": "video",
          "url": "https://video.twimg.com/amplify_video/2107951577118171136/vid/avc1/484x270/grINTBwk-Ni0oJL_.mp4?tag=29",
          "previewUrl": "https://pbs.twimg.com/amplify_video_thumb/2107951577118171136/img/DnRVpyjYuF1QWEVz.jpg",
          "width": 2940,
          "height": 1640,
          "altText": null,
          "durationMs": 7133
        }
      ],
      "urls": [
        "https://developer.x.com/exhibit"
      ],
      "hashtags": [],
      "mentions": [],
      "replyTo": null,
      "quoted": null,
      "retweetOf": null,
      "conversationId": "2107952086193508716",
      "isPinned": false,
      "source": null,
      "article": null
    }
  ],
  "nextCursor": "DAABCgABHUS5qIC___0KAAIbOL6IfJeQgwgAAwAAAAIAAA",
  "previousCursor": "DAABCgABHUS5qIDAJxEKAAIbOL6IfJeQgwgAAwAAAAEAAA",
  "hasNextPage": true
}
```
