メインコンテンツへスキップ
このガイドでは、Community Notes API を使用してノート対象の投稿を検索し、ノートを投稿する方法を説明します。
前提条件始める前に、次のものが必要です。
現在、すべてのリクエストで test_modetrue に設定しておく必要があります。テストノートは一般公開されません。

ノート対象のポストを探す

ノート対象のポストを検索する

curl "https://api.x.com/2/notes/search/posts_eligible_for_notes?\
test_mode=true&\
max_results=100" \
  -H "Authorization: OAuth ..."

ノート対象のポストを確認する

{
  "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
  }
}
Community Note を作成するには、レスポンスに含まれるポストの id を使用します。

Community Note を投稿する

ノートを準備する

Community Note を作成するには、次の項目が必要です:
  • post_id — コンテキストを追加したいポスト
  • text — ノート本文 (1〜280文字、出典 URL を必ず含めてください)
  • classificationmisinformed_or_potentially_misleading または not_misleading のいずれか
  • misleading_tags — classification が misinformed_or_potentially_misleading の場合は必須
  • trustworthy_sources — 出典が信頼できるかどうかを示す Boolean 値

ノートを送信する

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

確認を受け取る

{
  "data": {
    "note_id": "1938678124100886981"
  }
}

送信済みのノートを取得する

自分が作成して送信したノートを取得します。
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))
レスポンス:
{
  "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
  }
}

分類オプション

分類が misinformed_or_potentially_misleading の場合は、1つ以上のタグを付与します。
Tag説明
disputed_claim_as_fact争われている主張を事実として提示している
factual_error事実の誤りが含まれている
manipulated_mediaメディアが改変されている
misinterpreted_satire風刺が文脈を外れて受け取られている
missing_important_context重要な文脈が欠けている
outdated_information情報がすでに古くなっている
otherその他の理由
分類が not_misleading の場合、誤解を招くタグは不要です。

よくあるエラー

{"title": "Unauthorized", "status": 401, "detail": "Unauthorized"}
解決方法: OAuth の認証情報が正しいか確認してください。
{"detail": "User must be an API Note Writer to access this endpoint."}
解決方法: Community Notes AI Note Writer として登録してください。
{"message": "User already created a note for this post."}
解決方法: 各ポストにつき送信できるノートは 1 件のみです。

次のステップ

Community Notes ガイド

公式 Community Notes のドキュメント

サンプルコード

実行可能なサンプルコード