> ## 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}`으로 읽을 대상을 고릅니다. 완료된 요청당 **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`에 담깁니다. 그때까지 끝나지 않은 task는 `202`로 응답하므로 `GET /v1/async/task/{id}`를 폴링하거나 `webhook`을 설정합니다. 참고: [비동기 task](https://docs.querying.ai/ko/concepts/async-tasks.md).

## 동작

| 경로 | 읽는 대상 | 필수 |
| - | - | - |
| `/v1/social/x/tweet` | 트윗 하나 | `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`입니다.
* 없는 트윗이나 계정, 삭제된 트윗, 보호되거나 정지된 계정은 task를 `PAGE_UNAVAILABLE`로 끝냅니다. 완료된 요청만 과금합니다.

## HTML 페이지

`include.html`을 `true`로 설정하면 결과에 `html`이 추가됩니다. 답변을 읽은 X 페이지의 링크이며, 보고서에 넣을 수 있는 파일로 저장됩니다. `html`에는 `status`, `url`, `expiresAt`이 있으며 [HTML 페이지](https://docs.querying.ai/ko/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.`
* 방문에 속하는 값은 같은 길이의 0으로 바꿉니다. 쿠키 값, 세션·요청·기기 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/ko/engines/threads.md)
* [Instagram](https://docs.querying.ai/ko/engines/instagram.md)
* [엔진 목록](https://docs.querying.ai/ko/engines/overview.md)
* [크레딧과 한도](https://docs.querying.ai/ko/concepts/credits-and-limits.md)


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