Skip to main content
This guide walks you through getting Post counts (volume) for the last 7 days.
PrerequisitesBefore you begin, you’ll need:

Get recent Post counts

1

Build a query

Use the same query syntax as recent search. For example, to count Posts from @XDevelopers:
from:XDevelopers
2

Make the request

cURL
curl "https://api.x.com/2/tweets/counts/recent?\
query=from%3AXDevelopers&\
granularity=day" \
  -H "Authorization: Bearer $BEARER_TOKEN"
3

Review the response

{
  "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 options

Control how counts are grouped:
GranularityDescription
minuteCounts per minute
hourCounts per hour (default)
dayCounts per day
cURL
# Get hourly counts
curl "https://api.x.com/2/tweets/counts/recent?\
query=python%20lang%3Aen&\
granularity=hour" \
  -H "Authorization: Bearer $BEARER_TOKEN"

Filter by time range

Limit counts to a specific time period:
cURL
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"

Common parameters

ParameterDescriptionDefault
querySearch query (required)
granularityTime bucket sizehour
start_timeOldest timestamp (ISO 8601)7 days ago
end_timeNewest timestamp (ISO 8601)Now

Next steps