Documentation Index
Fetch the complete documentation index at: https://generaltranslation.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
このガイドでは、過去7日間のポスト数 (投稿ボリューム) を取得する方法を説明します。
クエリを作成する
recent search と同じクエリ構文を使用します。たとえば、@XDevelopers からのポスト数をカウントするには次のように指定します。 リクエストを送信する
curl "https://api.x.com/2/tweets/counts/recent?\
query=from%3AXDevelopers&\
granularity=day" \
-H "Authorization: Bearer $BEARER_TOKEN"
レスポンスを確認する
{
"data": [
{
"end": "2024-01-16T00:00:00.000Z",
"start": "2024-01-15T00:00:00.000Z",
"tweet_count": 5
},
{
"end": "2024-01-17T00:00:00.000Z",
"start": "2024-01-16T00:00:00.000Z",
"tweet_count": 3
},
{
"end": "2024-01-18T00:00:00.000Z",
"start": "2024-01-17T00:00:00.000Z",
"tweet_count": 8
}
],
"meta": {
"total_tweet_count": 16
}
}
カウントの集計単位を指定できます。
| Granularity | 説明 |
|---|
minute | 1分ごとのカウント数 |
hour | 1時間ごとのカウント数 (デフォルト) |
day | 1日ごとのカウント数 |
# 1時間ごとのカウント数を取得
curl "https://api.x.com/2/tweets/counts/recent?\
query=python%20lang%3Aen&\
granularity=hour" \
-H "Authorization: Bearer $BEARER_TOKEN"
カウントを特定の期間に限定します:
curl "https://api.x.com/2/tweets/counts/recent?\
query=from%3AXDevelopers&\
start_time=2024-01-10T00%3A00%3A00Z&\
end_time=2024-01-15T00%3A00%3A00Z&\
granularity=day" \
-H "Authorization: Bearer $BEARER_TOKEN"
| パラメータ | 説明 | デフォルト |
|---|
query | 検索クエリ (必須) | — |
granularity | 時間バケットの粒度 | hour |
start_time | 最古のタイムスタンプ (ISO 8601) | 7日前 |
end_time | 最新のタイムスタンプ (ISO 8601) | 現在 |
APIリファレンス
エンドポイントの詳細ドキュメント