> ## Documentation Index
> Fetch the complete documentation index at: https://docs.querying.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# X API

> Read a public X tweet or profile as JSON, with the latest tweets, likes, reposts, quotes, replies, bookmarks, views and publish times.

Read public X data as JSON with `POST /v1/social/x/{action}`. `{action}` picks what to read. A completed request costs **0.5 credits**.

## Request

```bash theme={"theme":"css-variables"}
curl -X POST https://api.querying.ai/v1/social/x/profile \
  -H "Authorization: Bearer $QUERYING_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "username": "NASA", "limit": 1 }'
```

The request waits for the result, up to 290 seconds, and answers `200` with the result in `response`. A task still running answers `202`; poll `GET /v1/async/task/{id}` or set `webhook`. See [Async tasks](https://docs.querying.ai/concepts/async-tasks.md).

## Actions

| Path | Reads | Required |
| - | - | - |
| `/v1/social/x/tweet` | One tweet | `tweetId` |
| `/v1/social/x/profile` | A public profile and its most recent tweets, about 5 | `username` |

`tweetId` takes a tweet ID or a tweet URL, such as `https://x.com/NASA/status/1585341984679469056`. `postUrl` and `url` take the same values. `username` takes a username, an `@username` or a profile URL, which `url` also takes.

## Parameters

A request with a parameter of another action, a value outside the ones listed below, or a missing required field is refused when you submit it, with `400 VALIDATION_ERROR` naming the field.

`profile`:

* `limit`: Optional integer from 1 to 20, default 20, the most tweets to return. X shows a profile's newest tweets, about 5, so a profile returns that many.

## Response example

```json theme={"theme":"css-variables"}
{
  "platform": "x",
  "action": "profile",
  "bio": "Making the seemingly impossible, possible. ✨",
  "url": "https://x.com/NASA",
  "tweets": [
    {
      "url": "https://x.com/NASA/status/2123820070803542306",
      "lang": "en",
      "text": "LIVE: Watch as an uncrewed SpaceX Dragon spacecraft undocks from the @space_station and begins its journey to bring research samples and hardware back to Earth. https://x.com/i/broadcasts/2evOEzWEYBkWyn",
      "links": ["https://x.com/i/broadcasts/2evOEzWEYBkWyn"],
      "media": [],
      "author": {
        "id": "11348282",
        "handle": "NASA",
        "verified": true,
        "displayName": "NASA",
        "verifiedType": "Government",
        "followerCount": 92143728
      },
      "pinned": false,
      "tweetId": "2123820070803542306",
      "hashtags": [],
      "mentions": ["Space_Station"],
      "createdAt": "2026-11-20T16:45:38.000Z",
      "likeCount": 2518,
      "viewCount": 960912,
      "quoteCount": 26,
      "replyCount": 163,
      "retweetCount": 383,
      "bookmarkCount": 101
    }
  ],
  "userId": "11348282",
  "website": "http://www.nasa.gov/",
  "location": "Pale Blue Dot",
  "username": "NASA",
  "verified": true,
  "createdAt": "2007-12-19T20:20:32.000Z",
  "protected": false,
  "mediaCount": 28260,
  "tweetCount": 74572,
  "displayName": "NASA",
  "verifiedType": "Government",
  "followerCount": 92143728,
  "returnedCount": 1,
  "followingCount": 115
}
```

## Result fields

* Every response echoes `platform` and `action`. `profile` carries `returnedCount`.
* A tweet has `tweetId`, `url`, `text`, `lang`, `createdAt`, `author` (`id`, `handle`, `displayName`, `verified`, `verifiedType`, `avatarUrl`, `followerCount`), `hashtags`, `mentions`, `links`, `media`, `likeCount`, `retweetCount`, `quoteCount`, `replyCount` and `bookmarkCount`.
  * `text` is the full text of a long tweet, with short links opened to their addresses.
  * `media` lists each `type` with its `url`, `previewUrl`, `width`, `height`, `durationMs` for a video and `altText` when set. A video's `url` is its highest quality file.
  * `viewCount` appears when X shows it. A reply adds `inReplyTo` with the `handle` and `tweetId` it answers, and a quote adds `quotedTweet`.
* `tweet` returns `tweet`.
* `profile` returns `userId`, `username`, `displayName`, `url`, `bio`, `location`, `website`, `avatarUrl`, `bannerUrl`, `verified`, `verifiedType`, `protected`, `createdAt`, `followerCount`, `followingCount`, `tweetCount`, `mediaCount` and `tweets`. Each tweet in `tweets` carries `pinned`, `true` for the tweet the profile pinned.
* A tweet or account that does not exist, a deleted tweet, and a protected or suspended account end the task with `PAGE_UNAVAILABLE`. Only completed requests are charged.

## HTML page

Set `include.html` to `true` and the result gains `html`, a link to the X page the answer was read from, saved as a file you can put in a report. `html` has `status`, `url` and `expiresAt`, described in [HTML pages](https://docs.querying.ai/engines/html-pages.md).

* `include.html` works on `tweet` and `profile`.
* The file is the HTML document X sent for the page, before any script ran. It starts with a note comment, `Saved by querying.ai: the page X served for task <id> at <UTC time>, the page as X sent it, before any script ran, the address of the visit and its session ids masked.`
* Values that belong to the visit are replaced with zeros of the same length: cookie values, session, request and device ids, CSRF and other tokens, nonces and the signatures in media addresses. Because those signatures are masked, the image and video links in the file do not load. Content that depends on where the visit came from, such as the regional CDN host names in media addresses, stays as X sent it.
* The document's scripts are kept as text. The file is served with a Content-Security-Policy that runs no script and loads no outside resource.
* X sends the main content as markup, so the opened file is readable.
* `tweet` keeps the page at `x.com/<user>/status/<id>`, and `profile` keeps `x.com/<user>`.
* The page costs nothing extra: the request is still 0.5 credits.
* When the page cannot be kept, the answer is still returned and `html` is `{ "status": "failed", "error": "EVIDENCE_FAILED" }`. Resubmit the task to try again.

## Related

* [Threads](https://docs.querying.ai/engines/threads.md)
* [Instagram](https://docs.querying.ai/engines/instagram.md)
* [Engine overview](https://docs.querying.ai/engines/overview.md)
* [Credits and limits](https://docs.querying.ai/concepts/credits-and-limits.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.