Twitter historical data
Twitter (X) Historical Data: Backfill Tweets Back to 2006
Prices checked:
Quick Answer
Twitter (X) search reaches back to March 2006, so you can pull historical posts by keyword, hashtag or account. On TwexAPI each post costs 5 Credits: about $0.50 per 10,000 posts and $50 per million, against $5.00 per 1,000 on the official X API’s full-archive search (prices as read on November 27, 2026). To avoid gaps, bound each query with since_time: and until_time: in Unix seconds, split the range into one-day or 10-minute windows and follow the cursor inside each one. In our tests, X’s date-only bounds let in posts from the next day, one cursor through three months missed 21% of January’s posts, and two windowed runs merged returned every post. For a busy keyword, search returns only part of the posts once they are about a week old, so collect those as they appear. Likes and profiles come back as they are today, deleted and protected posts are not available, and TwexAPI has no firehose or streaming endpoint.
What historical data you can pull
| Data | Available | Notes |
|---|---|---|
| Public posts by keyword, phrase, hashtag or account | Back to March 2006 | from:jack returned posts from March 21, 2006 |
| Text, time, language, media, links, hashtags, reply and quote IDs | Yes | About 50 fields per post |
| Likes, reposts, replies, quotes and bookmarks | As of when you fetch | Not the counts at the time of posting |
| View counts | Recent years only | All 10 NASA posts from January 1, 2015 returned 0; 7 of 8 from June 2023 had views |
| Author profile | Current profile only | Name, bio and follower count as they are today |
| Follower and following lists | Current list only | No follow dates and no past snapshots |
| Deleted posts, protected and suspended accounts | No | Search does not return them |
| Busy keywords older than about a week | Partly | bitcoin: 346 posts in 10 minutes 7.1 days back, 117 in the same 10 minutes 8.1 days back |
| Firehose or real-time stream | No | Poll with since_id:, or use X’s filtered stream |
Historical data here means search results: the public posts that match a query in a date range, newest first. To track how follower counts or likes change, save snapshots on a schedule from now on; nobody can pull past values from the API afterwards.
What a backfill costs
| Posts | TwexAPI | twitterapi.io | Official X API (full-archive search) |
|---|---|---|---|
| 10,000 | ~$0.50 | $1.50 | $50 |
| 100,000 | ~$5 | $15 | $500 |
| 1,000,000 | ~$50 | $150 | $5,000 |
| 10,000,000 | ~$500 | $1,500 | $50,000, over at least 4 billing cycles |
TwexAPI bills 5 Credits per post returned, at 100,000 Credits per $1. An empty page costs 5 Credits and failed requests are free. Our three-month NASA backfill below saved 1,483 posts in one run and cost about 9,300 Credits, about $0.09, including the empty pages that end each window.
X’s full-archive search is open to pay-per-use accounts, returns up to 500 posts per request and goes back to March 2006, according to X’s search documentation as read on November 28, 2026. Post reads cost $0.005 each, and pay-per-use accounts are capped at 3 million post reads per monthly billing cycle, so 10 million posts take at least four cycles or an Enterprise plan. twitterapi.io charges 15 credits per tweet from search, at 100,000 credits per $1 ($0.08 per 1,000 with its Business subscription). On Apify, the most-used Tweet Scraper V2 charged $0.40 per 1,000 tweets and the cheapest popular Actor $0.14. Third-party prices are from each pricing page, as read on November 27, 2026.
Source: X API pricing (official)
How to avoid gaps in a backfill
| Query | Result |
|---|---|
| from:NASA since:2020-01-07 until:2020-01-08 (dates only) | Posts up to January 9 on the first page; NASA posted 16 times on January 7 |
| from:NASA since:2020-01-07_00:00:00_JST until:2020-01-08_00:00:00_JST | 11 of the 16 posts in that Japanese day; the 5 posted before 9:00 JST were missing |
| from:NASA since_time:1578322800 until_time:1578409200 (the same Japanese day) | All 16 posts, in all three runs |
| from:NASA since:2026-11-25_17:00:00_UTC until:2026-11-25_18:00:00_UTC | Nothing in two of three runs, although NASA posted twice in that hour; since_time: returned both |
| One cursor followed through from:NASA, January to March 2015 | 1,368 posts, including 401 of NASA’s 506 January posts |
| The same range with since_time: and max_id: paging | 1,484 of the 1,492 posts all runs found together |
| The same range in one-day since_time: windows, following the cursor in each (the script below) | 1,483 posts in one run and 1,472 in another; merged, all 1,492 |
| bitcoin, 12:00 to 13:00 on November 20, 2026, with max_id: at 00:06 and again at 14:22 | 1,774 posts, then 42, as the posts went from 7.5 to 8.1 days old |
| bitcoin, 12:00 to 12:10, in 1-minute windows, on November 21 (7.1 days old) and November 20 (8.1 days old) | 346 posts against 117 |
We ran each query above against the live search API on November 28, 2026, repeating the date checks three times. Times are UTC.
- Bound every query with since_time: and until_time: in Unix seconds. Dates with _00:00:00_UTC also stay exact, but other times and time zones do not.
- Split the range into windows, one day for an account or a quiet keyword and 10 minutes for a busy one, and follow next_cursor inside each window. Search pages are not strictly newest-first, so paging back with max_id: skips posts, and one cursor followed for hundreds of pages drops them.
- When a page comes back empty, ask for the same cursor again after 2, 4 and 8 seconds before you treat the window as done. In 1-minute windows of bitcoin, a retry returned more posts in 4 windows of 10.
- Save every page to disk as you go and deduplicate on tweet_id, so a rerun picks up where it stopped.
- If your dataset must be complete, run the range twice into separate files and merge them on tweet_id. On NASA, one run missed 7 posts in a row on January 6 and the other missed two whole days; together they had all 1,492.
- Back up a busy keyword within a week, or collect it as posts appear. Once posts are about a week old, keyword search returns only part of them; account searches such as from:NASA were not affected.
How long a backfill takes
| Plan | Requests per second | Processes at once | Posts an hour (estimate) | Time for 1 million posts |
|---|---|---|---|---|
| Starter (free) | 0.2 | 1 | About 12,000 | The free 20,000 Credits cover 4,000 posts |
| Lite | 3 | 6 | About 180,000 | About 6 hours |
| Pro | 10 | 20 | About 600,000 | Under 2 hours |
| Business | 20 | 40 | About 1,200,000 | Under 1 hour |
One process saved about 18,000 posts an hour on a busy keyword in our runs, at about 2 seconds per request plus the pauses that end each window. To go faster, split the range into months and run one process per month, each writing its own file, up to your plan’s requests-per-second limit; the pauses do not count against it. The table assumes about 17 posts per request at the full limit and is an estimate: we measured single processes. The script waits and retries when it is rate limited.
Source: TwexAPI pricing
Python backfill script
This script saves the posts that match a query between two UTC times to a JSON Lines file, one window at a time, and resumes from the file if you run it again. Pass a window in minutes as a fifth argument for a busy keyword, for example 10. We ran it on from:NASA for January to March 2015 on November 28, 2026: 1,483 posts in 33 minutes, most of it the pauses that end each of the 90 one-day windows. The step-by-step guide on docs.twexapi.io explains each part and how to check an export for gaps.
import json
import os
import sys
import time
from datetime import datetime, timezone
import requests
API = "https://api.twexapi.io/twitter/advanced_search/page"
HEADERS = {"Authorization": f"Bearer {os.environ['TWEXAPI_KEY']}"}
# python backfill.py "from:NASA" 2015-01-01 2015-04-01 nasa.jsonl [window minutes]
# Start and end are UTC (2015-01-01 or 2026-11-20T12:00), end excluded.
# Use short windows (10 to 60 minutes) for busy keywords; the default is one day.
QUERY, START, END, OUT = sys.argv[1:5]
WINDOW = int(sys.argv[5]) * 60 if len(sys.argv) > 5 else 24 * 3600
def unix(moment):
return int(datetime.fromisoformat(moment).replace(tzinfo=timezone.utc).timestamp())
def posted_at(post):
return int(datetime.strptime(post["created_at"], "%a %b %d %H:%M:%S %z %Y").timestamp())
def search(query, cursor):
body = {"searchTerms": [query], "sortBy": "Latest"}
if cursor:
body["next_cursor"] = cursor
for attempt in range(6):
try:
res = requests.post(API, headers=HEADERS, json=body, timeout=60)
if res.status_code != 429 and res.status_code < 500:
res.raise_for_status()
page = res.json()
return [post for post in page.get("data") or [] if post], page.get("next_cursor")
except (requests.ConnectionError, requests.Timeout):
pass
time.sleep(2**attempt) # rate limited, server error or network drop: wait and retry
raise RuntimeError("search kept failing")
first, last = unix(START), unix(END)
# Resume: windows before the newest one with saved posts in this range are done; redo that one.
seen, resume = set(), first
if os.path.exists(OUT):
for line in open(OUT):
post = json.loads(line)
seen.add(post["tweet_id"])
if first <= posted_at(post) < last:
resume = max(resume, first + (posted_at(post) - first) // WINDOW * WINDOW)
with open(OUT, "a") as out:
for since in range(resume, last, WINDOW):
until = min(since + WINDOW, last)
query = f"{QUERY} since_time:{since} until_time:{until}"
cursor, saved = None, 0
while True:
posts, next_cursor = search(query, cursor)
for pause in (2, 4, 8): # an empty page is often a hiccup: ask for the same page again
if posts:
break
time.sleep(pause)
posts, next_cursor = search(query, cursor)
for post in posts:
if post["tweet_id"] not in seen:
seen.add(post["tweet_id"])
out.write(json.dumps(post, ensure_ascii=False) + "\n")
saved += 1
if not posts or not next_cursor:
break
cursor = next_cursor
out.flush()
print(f"{datetime.fromtimestamp(since, timezone.utc):%Y-%m-%d %H:%M}: {saved} new, {len(seen)} saved", flush=True)Keeping the data current: no firehose
TwexAPI has no firehose or streaming endpoint. After a backfill, keep the dataset current by running the same query every few minutes with since_id: set to the newest post you saved; you pay only for new posts, plus 5 Credits for a check that finds nothing.
If you need posts pushed to you as they are published, X’s filtered stream is open to pay-per-use accounts with up to 1,000 rules and one connection, according to X’s documentation as read on November 28, 2026. X’s pricing and filtered-stream pages list no firehose or sample stream for pay-per-use.
FAQ
How far back does Twitter historical data go?
To March 2006. On November 28, 2026, a search for from:jack through TwexAPI returned posts from March 21, 2006, and X documents its full-archive search as going back to March 2006. Deleted posts and posts from protected or suspended accounts are not included.
How much does Twitter historical data cost?
On TwexAPI, 5 Credits per post: about $0.05 per 1,000 posts and $50 per million. The official X API charges $0.005 per post read, $5.00 per 1,000, with a cap of 3 million post reads per monthly billing cycle on pay-per-use. twitterapi.io charges $0.15 per 1,000 tweets from search. Prices as read on November 27, 2026.
Does the official X API include full-archive search?
Yes. X’s documentation, as read on November 28, 2026, lists full-archive search for pay-per-use and Enterprise accounts, with up to 500 posts per request. Each post returned costs $0.005, and recent search covers only the last 7 days.
Why does my date search return posts outside the range?
X applies date-only since: and until: loosely: on November 28, 2026, from:NASA since:2020-01-07 until:2020-01-08 returned posts from January 9. Times with a zone other than UTC were not reliable either. Use since_time: and until_time: with Unix seconds, which were exact on posts from 2006 to 2026 in our tests.
Can I get historical follower counts or past follower lists?
No. Profiles and follower lists come back as they are today, and following lists carry no follow dates. To see change over time, save snapshots on a schedule from now on. Following lists are ordered newest follow first, so the top rows show recent follows.
Can I get every historical tweet for a keyword?
For an account, yes in our tests: two runs over from:NASA, January to March 2015, merged to every post. For a busy keyword, only part of the posts older than about a week: on November 28, 2026, bitcoin returned 346 posts for 10 minutes 7.1 days back and 117 for the same 10 minutes 8.1 days back. Collect busy keywords as posts appear, or back them up within a week.
Are like and view counts historical?
No. Likes, reposts, replies and views are the counts when you fetch the post. Older posts return a view count of 0: all 10 NASA posts from January 1, 2015 did in our test.
Is there a Twitter firehose API?
TwexAPI has none; you poll search with since_id: instead. X offers a filtered stream to pay-per-use accounts, with up to 1,000 rules and one connection, and its pricing and filtered-stream pages list no firehose or sample stream for pay-per-use.
Can I build a Twitter dataset for research or AI training?
Yes. The backfill script writes one post per line as JSON, ready for pandas, DuckDB or a training pipeline, and 1 million posts cost about $50. Check that your use follows the laws and terms that apply to it.
Is TwexAPI affiliated with X?
No. TwexAPI is an independent third-party provider of public social data and is not affiliated with or endorsed by X Corp.
Related Guides
Sources
Prices change. Confirm current rates on each provider’s pricing page before you buy. TwexAPI is an independent provider and is not affiliated with or endorsed by X Corp.