Skip to main content
This guide walks you through getting historical Post counts back to March 2006.
Full-archive Post counts requires Self-serve or Enterprise access.
PrerequisitesBefore you begin, you’ll need:

Get full-archive Post counts

1

Build a query

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

Set a time range

Specify start_time and end_time to search specific historical periods:
ParameterFormatExample
start_timeISO 86012020-01-01T00:00:00Z
end_timeISO 86012020-12-31T23:59:59Z
3

Make the request

cURL
curl "https://api.x.com/2/tweets/counts/all?\
query=from%3AXDevelopers&\
start_time=2020-01-01T00%3A00%3A00Z&\
end_time=2020-12-31T23%3A59%3A59Z&\
granularity=day" \
  -H "Authorization: Bearer $BEARER_TOKEN"
4

Review the response

{
  "data": [
    {
      "end": "2020-01-02T00:00:00.000Z",
      "start": "2020-01-01T00:00:00.000Z",
      "tweet_count": 3
    },
    {
      "end": "2020-01-03T00:00:00.000Z",
      "start": "2020-01-02T00:00:00.000Z",
      "tweet_count": 5
    }
  ],
  "meta": {
    "total_tweet_count": 8
  }
}

Granularity options

Control how counts are grouped:
GranularityDescription
minuteCounts per minute
hourCounts per hour (default)
dayCounts per day

Paginate through results

For large time ranges, use the next_token from the response:
cURL
curl "https://api.x.com/2/tweets/counts/all?\
query=from%3AXDevelopers&\
start_time=2015-01-01T00%3A00%3A00Z&\
end_time=2020-12-31T23%3A59%3A59Z&\
granularity=day&\
next_token=abc123" \
  -H "Authorization: Bearer $BEARER_TOKEN"

Key differences from recent counts

FeatureRecent CountsFull-Archive Counts
Time rangeLast 7 daysMarch 2006 to now
Access requiredAll developersPay-per-use, Enterprise
Default time rangeLast 7 daysLast 30 days

Common parameters

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

Next steps