このガイドでは、リストタイムラインから投稿を取得する手順を説明します。
リスト ID を見つける
x.com 上でリストを表示しているとき、その URL からリスト ID を確認できます。https://x.com/i/lists/84839422
└── ここがリスト ID です
リストタイムラインをリクエストする
curl "https://api.x.com/2/lists/84839422/tweets?\
tweet.fields=created_at,public_metrics,author_id&\
expansions=author_id&\
user.fields=username,verified&\
max_results=10" \
-H "Authorization: Bearer $BEARER_TOKEN"
レスポンスを確認する
{
"data": [
{
"id": "1458172421115101189",
"text": "最新の発表内容をご覧ください...",
"author_id": "4172587277",
"created_at": "2024-01-15T10:30:00.000Z",
"public_metrics": {
"retweet_count": 42,
"reply_count": 5,
"like_count": 156,
"quote_count": 3
},
"edit_history_tweet_ids": ["1458172421115101189"]
}
],
"includes": {
"users": [
{
"id": "4172587277",
"username": "TechNews",
"verified": true
}
]
},
"meta": {
"result_count": 1,
"next_token": "7140dibdnow9c7btw3z2vwioavpvutgzrzm9icis4ndix"
}
}
結果をページングする
SDK はページネーションを自動的に処理します。cURL を使う場合は、レスポンスに含まれる next_token を指定して、さらに投稿を取得します。curl "https://api.x.com/2/lists/84839422/tweets?\
max_results=10&\
pagination_token=7140dibdnow9c7btw3z2vwioavpvutgzrzm9icis4ndix" \
-H "Authorization: Bearer $BEARER_TOKEN"
このエンドポイントは、指定したリストから最新の投稿を最大 800 件まで返します。
APIリファレンス
エンドポイントの詳細ドキュメント