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

> 公開されている X のツイートやプロフィールを JSON で読み取ります。最新のツイートに加え、いいね、リポスト、引用、返信、ブックマーク、閲覧数、公開日時も受け取れます。

公開されている X のデータを `POST /v1/social/x/{action}` で JSON として読み取ります。`{action}` で読み取る対象を選びます。完了したリクエスト 1 件につき **0.5 クレジット**です。

## リクエスト

```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 }'
```

リクエストは結果が出るまで最大 290 秒待機し、`200` で応答します。結果は `response` に入ります。実行中のタスクは `202` で応答するため、`GET /v1/async/task/{id}` をポーリングするか `webhook` を設定します。[非同期タスク](https://docs.querying.ai/ja/concepts/async-tasks.md)を参照してください。

## アクション

| パス | 読み取る内容 | 必須 |
| - | - | - |
| `/v1/social/x/tweet` | ツイート 1 件 | `tweetId` |
| `/v1/social/x/profile` | 公開プロフィールと最新のツイート 5 件前後 | `username` |

`tweetId` には、ツイート ID か `https://x.com/NASA/status/1585341984679469056` のようなツイート URL を指定できます。`postUrl` と `url` にも同じ値を指定できます。`username` には、ユーザー名、`@username`、プロフィール URL を指定でき、`url` にもプロフィール URL を指定できます。

## パラメータ

別のアクションのパラメータ、以下にない値、または必須フィールドの欠けたリクエストは、送信時にそのフィールドを示す `400 VALIDATION_ERROR` で拒否されます。

`profile`:

* `limit`: 任意。1 から 20 の整数で、デフォルトは 20 です。返すツイートの最大数です。X が表示するのはプロフィールの最新ツイート 5 件前後だけなので、プロフィールはその件数を返します。

## レスポンス例

```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
}
```

## 結果フィールド

* すべてのレスポンスは `platform` と `action` をそのまま返します。`profile` には `returnedCount` があります。
* ツイートには `tweetId`、`url`、`text`、`lang`、`createdAt`、`author` (`id`、`handle`、`displayName`、`verified`、`verifiedType`、`avatarUrl`、`followerCount`)、`hashtags`、`mentions`、`links`、`media`、`likeCount`、`retweetCount`、`quoteCount`、`replyCount`、`bookmarkCount` があります。
  * `text` は長いツイートの全文で、短縮リンクは元のアドレスに展開されています。
  * `media` は項目ごとに `type` と、`url`、`previewUrl`、`width`、`height`、動画なら `durationMs`、設定されている場合は `altText` を並べます。動画の `url` は最も高画質のファイルです。
  * `viewCount` は X が表示している場合に現れます。返信には返信先の `handle` と `tweetId` を持つ `inReplyTo` が、引用には `quotedTweet` が付きます。
* `tweet` は `tweet` を返します。
* `profile` は `userId`、`username`、`displayName`、`url`、`bio`、`location`、`website`、`avatarUrl`、`bannerUrl`、`verified`、`verifiedType`、`protected`、`createdAt`、`followerCount`、`followingCount`、`tweetCount`、`mediaCount`、`tweets` を返します。`tweets` の各ツイートには `pinned` があり、プロフィールが固定したツイートでは `true` です。
* 存在しないツイートやアカウント、削除されたツイート、保護または停止されたアカウントは、タスクを `PAGE_UNAVAILABLE` で終了させます。課金されるのは完了したリクエストだけです。

## HTMLページ

`include.html` を `true` にすると、結果に `html` が加わります。回答の読み取り元である X のページへのリンクで、レポートに載せられるファイルとして保存されます。`html` には `status`、`url`、`expiresAt` があり、[HTMLページ](https://docs.querying.ai/ja/engines/html-pages.md) で説明しています。

* `include.html` は `tweet`、`profile` で使えます。
* ファイルは X がそのページに対して送った HTML ドキュメントで、スクリプトが実行される前のものです。先頭にメモのコメントがあります。`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.`
* 訪問に属する値は同じ長さのゼロに置き換えます。Cookie の値、セッション・リクエスト・デバイスの ID、CSRF などのトークン、nonce、メディアアドレスの署名が対象です。これらの署名はマスクされているため、ファイル内の画像と動画のリンクは読み込まれません。メディアアドレスの地域別 CDN ホスト名など、訪問の出どころに依存する内容は X が送ったままです。
* ドキュメントのスクリプトはテキストとしてファイルに残ります。ファイルはスクリプトを一切実行せず外部リソースも読み込まない Content-Security-Policy 付きで配信されます。
* X は主な内容をマークアップとして送るため、開いたファイルを読めます。
* `tweet` は `x.com/<user>/status/<id>` のページを、`profile` は `x.com/<user>` を保存します。
* ページに追加の費用はかかりません。リクエストはこれまでどおり 0.5 クレジットです。
* ページを保存できない場合も回答は返され、`html` は `{ "status": "failed", "error": "EVIDENCE_FAILED" }` になります。やり直すにはタスクを再送信してください。

## 関連

* [Threads](https://docs.querying.ai/ja/engines/threads.md)
* [Instagram](https://docs.querying.ai/ja/engines/instagram.md)
* [エンジン一覧](https://docs.querying.ai/ja/engines/overview.md)
* [クレジットと上限](https://docs.querying.ai/ja/concepts/credits-and-limits.md)


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