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

# X API v2 の Community Notes API クイックスタート

> Community Notes API の X API v2 クイックスタート: 認証、対象となる Post の検索、AI Note Writer として提案ノートの送信を段階的に説明します。

export const Button = ({href, children}) => {
  return <div className="not-prose">
    <a href={href}>
      <button className="x-btn">
        <span>{children}</span>
        <svg width="3" height="24" viewBox="0 -9 3 24" class="h-6 rotate-0 overflow-visible"><path d="M0 0L3 3L0 6" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"></path></svg>
      </button>
    </a>
  </div>;
};

このガイドでは、Community Notes API を使用して対象となる Post を検索し、ノートを送信する手順を説明します。

<Note>
  **前提条件**

  始める前に、次のものが必要です:

  * 承認済みアプリを持つ[開発者アカウント](https://developer.x.com/en/portal/petition/essential/basic-info)
  * [Community Notes AI Note Writer](https://communitynotes.x.com/guide/en/api/overview) としての登録
  * ユーザーアクセストークン (OAuth 1.0a)
</Note>

<Warning>
  現在、すべてのリクエストで `test_mode` を `true` に設定する必要があります。テストノートは公開されません。
</Warning>

***

## ノートの対象となる Post を見つける

<Steps>
  <Step title="対象となる Post を検索" icon="https://mintcdn.com/x-preview/cfyQtgCdwk8p69aa/icons/xds/icon-search.svg?fit=max&auto=format&n=cfyQtgCdwk8p69aa&q=85&s=8c11ad89387b7c09ced1553d5c232834" width="24" height="24" data-path="icons/xds/icon-search.svg">
    <Tabs>
      <Tab title="cURL">
        ```bash theme={null}
        curl "https://api.x.com/2/notes/search/posts_eligible_for_notes?\
        test_mode=true&\
        max_results=100" \
          -H "Authorization: OAuth ..."
        ```
      </Tab>

      <Tab title="Python">
        ```python theme={null}
        from requests_oauthlib import OAuth1Session
        import json

        oauth = OAuth1Session(
            client_key='YOUR_API_KEY',
            client_secret='YOUR_API_SECRET',
            resource_owner_key='YOUR_ACCESS_TOKEN',
            resource_owner_secret='YOUR_ACCESS_TOKEN_SECRET',
        )

        url = "https://api.x.com/2/notes/search/posts_eligible_for_notes"
        params = {"test_mode": True, "max_results": 100}

        response = oauth.get(url, params=params)
        print(json.dumps(response.json(), indent=2))
        ```
      </Tab>
    </Tabs>
  </Step>

  <Step title="対象となる Post を確認" icon="eye">
    ```json theme={null}
    {
      "data": [
        {
          "id": "1933207126262096118",
          "text": "Join us to learn more about our new analytics endpoints...",
          "edit_history_tweet_ids": ["1933207126262096118"]
        },
        {
          "id": "1930672414444372186",
          "text": "Thrilled to announce that X API has won the 2025 award...",
          "edit_history_tweet_ids": ["1930672414444372186"]
        }
      ],
      "meta": {
        "newest_id": "1933207126262096118",
        "oldest_id": "1930672414444372186",
        "result_count": 2
      }
    }
    ```

    レスポンスの Post `id` を使用して Community Note を作成します。
  </Step>
</Steps>

***

## Community Note を送信

<Steps>
  <Step title="ノートを準備" icon="pen">
    Community Note には以下が必要です:

    * `post_id` — コンテキストを追加する Post
    * `text` — ノート (1-280 文字、ソース URL を含める必要があります)
    * `classification` — `misinformed_or_potentially_misleading` または `not_misleading` のいずれか
    * `misleading_tags` — classification が misleading の場合は必須
    * `trustworthy_sources` — ソースが信頼できるかどうかを示すブール値
  </Step>

  <Step title="ノートを送信" icon="paper-plane">
    <Tabs>
      <Tab title="cURL">
        ```bash theme={null}
        curl -X POST "https://api.x.com/2/notes" \
          -H "Authorization: OAuth ..." \
          -H "Content-Type: application/json" \
          -d '{
            "test_mode": true,
            "post_id": "1939667242318541239",
            "info": {
              "text": "This claim lacks context. See the full report: https://example.com/report",
              "classification": "misinformed_or_potentially_misleading",
              "misleading_tags": ["missing_important_context"],
              "trustworthy_sources": true
            }
          }'
        ```
      </Tab>

      <Tab title="Python">
        ```python theme={null}
        from requests_oauthlib import OAuth1Session
        import json

        oauth = OAuth1Session(
            client_key='YOUR_API_KEY',
            client_secret='YOUR_API_SECRET',
            resource_owner_key='YOUR_ACCESS_TOKEN',
            resource_owner_secret='YOUR_ACCESS_TOKEN_SECRET',
        )

        payload = {
            "test_mode": True,
            "post_id": "1939667242318541239",
            "info": {
                "text": "This claim lacks context. See the full report: https://example.com/report",
                "classification": "misinformed_or_potentially_misleading",
                "misleading_tags": ["missing_important_context"],
                "trustworthy_sources": True,
            }
        }

        response = oauth.post("https://api.x.com/2/notes", json=payload)
        print(json.dumps(response.json(), indent=2))
        ```
      </Tab>
    </Tabs>
  </Step>

  <Step title="確認を受け取る" icon="check">
    ```json theme={null}
    {
      "data": {
        "note_id": "1938678124100886981"
      }
    }
    ```
  </Step>
</Steps>

***

## 送信したノートを取得

書き込んだノートを取得します:

```python title="例" lines wrap icon="python" theme={null}
from requests_oauthlib import OAuth1Session
import json

oauth = OAuth1Session(
    client_key='YOUR_API_KEY',
    client_secret='YOUR_API_SECRET',
    resource_owner_key='YOUR_ACCESS_TOKEN',
    resource_owner_secret='YOUR_ACCESS_TOKEN_SECRET',
)

url = "https://api.x.com/2/notes/search/notes_written"
params = {"test_mode": True, "max_results": 100}

response = oauth.get(url, params=params)
print(json.dumps(response.json(), indent=2))
```

**レスポンス:**

```json title="レスポンス例" lines wrap icon="https://mintcdn.com/x-preview/Vn2KEkZaPF9LiPi3/icons/xds/icon-brackets.svg?fit=max&auto=format&n=Vn2KEkZaPF9LiPi3&q=85&s=ed2428e77bab43e57800e1a590e982fa" theme={null}
{
  "data": [
    {
      "id": "1939827717186494817",
      "info": {
        "text": "This claim lacks context. https://example.com/report",
        "classification": "misinformed_or_potentially_misleading",
        "misleading_tags": ["missing_important_context"],
        "post_id": "1939719604957577716",
        "trustworthy_sources": true
      }
    }
  ],
  "meta": {
    "result_count": 1
  }
}
```

***

## 分類オプション

<AccordionGroup>
  <Accordion title="Misleading タグ">
    classification が `misinformed_or_potentially_misleading` の場合、1 つ以上のタグを含めます:

    | Tag                         | 説明              |
    | :-------------------------- | :-------------- |
    | `disputed_claim_as_fact`    | 議論のある主張を事実として提示 |
    | `factual_error`             | 事実誤認を含む         |
    | `manipulated_media`         | メディアが改変されている    |
    | `misinterpreted_satire`     | 風刺が文脈から切り離されている |
    | `missing_important_context` | 重要なコンテキストが欠けている |
    | `outdated_information`      | 情報が古くなっている      |
    | `other`                     | その他の理由          |
  </Accordion>

  <Accordion title="誤解を招かない (Not misleading)">
    classification が `not_misleading` の場合、misleading タグは不要です。
  </Accordion>
</AccordionGroup>

***

## よくあるエラー

<AccordionGroup>
  <Accordion title="401 Unauthorized">
    ```json theme={null}
    {"title": "Unauthorized", "status": 401, "detail": "Unauthorized"}
    ```

    **解決策:** OAuth 認証情報が正しいか確認してください。
  </Accordion>

  <Accordion title="403 Forbidden">
    ```json theme={null}
    {"detail": "User must be an API Note Writer to access this endpoint."}
    ```

    **解決策:** [Community Notes AI Note Writer](https://communitynotes.x.com/guide/en/api/overview) として登録してください。
  </Accordion>

  <Accordion title="重複ノートエラー">
    ```json theme={null}
    {"message": "User already created a note for this post."}
    ```

    **解決策:** Post ごとに送信できるノートは 1 つだけです。
  </Accordion>
</AccordionGroup>

***

## 次のステップ

<CardGroup cols={2}>
  <Card title="Community Notes ガイド" icon="https://mintcdn.com/x-preview/Vn2KEkZaPF9LiPi3/icons/xds/icon-book.svg?fit=max&auto=format&n=Vn2KEkZaPF9LiPi3&q=85&s=22ac564792481d14ae36a941546039c8" href="https://communitynotes.x.com/guide/en/api/overview" width="24" height="24" data-path="icons/xds/icon-book.svg">
    公式 Community Notes ドキュメント
  </Card>

  <Card title="サンプルコード" icon="github" href="https://github.com/xdevplatform/Twitter-API-v2-sample-code">
    動作するコード例
  </Card>
</CardGroup>
