# How to Get Historical Tweets With an API

To get historical tweets with an API, use the X API's full-archive search endpoint, which reaches back to March 2006 at $0.005 per post, or a scraper API such as apidojo's Tweet Scraper V2, which searches the same history at $0.40 per 1,000 tweets.

[![apidojo](/blog/authors/apidojo.png)**Apidojo** *15+ years of experience in data retrieval.*](/blog/authors/apidojo/)

**7 October 2026** Published

**4 min** Read

![Cover card reading 'How to Get Historical Tweets With an API'](/blog/covers/historical-tweets.png)

**To get historical tweets with an API, use the X API’s full-archive search endpoint, which reaches back to March 2006 at $0.005 per post, or a scraper API such as apidojo’s Tweet Scraper V2, which searches the same history at $0.40 per 1,000 tweets.** The X API’s recent search endpoint covers only the last 7 days, so it can’t return historical posts.

This guide compares the ways to collect historical tweets, shows the code for each, and explains how to size a job before you pay for it. The overview of both X search endpoints is in the [Twitter search API guide](/blog/twitter-api/search-api/).

## What Are the Ways to Get Historical Tweets With an API?

**There are 3 ways to get historical tweets programmatically: X’s full-archive search, X’s owned-read endpoints for your own account, and a scraper API.** The table compares them.

| Method | History | Cost | Best for |
| --- | --- | --- | --- |
| X API full-archive search (/2/tweets/search/all) | Back to March 2006 | $0.005 per post; 3 million post reads per month cap | Apps that need X’s official API |
| X API owned reads (/2/users/{id}/tweets) | Your own account’s posts | $0.001 per post | Your own history and analytics |
| apidojo Tweet Scraper V2 | Same history as X web search, back to 2006 | $0.40 per 1,000 tweets | Research, datasets, large volumes |

X API prices, the monthly cap and owned-read rates are from X’s pricing documentation ([X API pricing](https://docs.x.com/x-api/getting-started/pricing)); archive coverage from X’s search documentation ([X API docs](https://docs.x.com/x-api/posts/search)).

## How Do You Get Historical Tweets With X’s Full-Archive Search?

**You get historical tweets with X’s full-archive search by calling `GET /2/tweets/search/all` with a query and a `start_time` and `end_time` window.** Without a window the endpoint returns only the last 30 days ([X API quickstart](https://docs.x.com/x-api/posts/search/quickstart/full-archive-search.md)). Full-archive search is available on pay-per-use and Enterprise access, returns up to 500 posts per request, and accepts queries of up to 1,024 characters (X API docs).

```
import os, requests

url = "https://api.x.com/2/tweets/search/all"
headers = {"Authorization": f"Bearer {os.environ['BEARER_TOKEN']}"}
params = {
    "query": "from:NASA pluto -is:retweet",
    "start_time": "2015-07-01T00:00:00Z",
    "end_time": "2015-08-01T00:00:00Z",
    "max_results": 500,
    "tweet.fields": "created_at,public_metrics",
}

posts = []
while True:
    data = requests.get(url, headers=headers, params=params).json()
    posts.extend(data.get("data", []))
    token = data.get("meta", {}).get("next_token")
    if not token:
        break
    params["next_token"] = token

print(len(posts), "posts")
```

Each post returned is billed at $0.005, and the same post requested again within one 24-hour UTC window is charged once (X API pricing).

## How Do You Size a Historical Job Before Paying?

**Size a historical job with X’s counts endpoint first, because a count request is billed per request rather than per post.** Counts: All costs $0.010 per request, while reading the posts costs $0.005 each (X API pricing). A query that matches 400,000 posts would cost $2,000 to read through the X API, so the count tells you which route to take.

## How Do You Get Historical Tweets With apidojo’s Tweet Scraper V2?

**You get historical tweets with Tweet Scraper V2 by writing X web search queries with `since:` and `until:`, one per period, and running them through the Apify API.** Splitting long periods into windows is the approach the actor’s documentation shows ([Apify](https://apify.com/apidojo/tweet-scraper)).

```
from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("apidojo/tweet-scraper").call(run_input={
    "searchTerms": [
        "from:NASA pluto since:2015-01-01 until:2015-07-01",
        "from:NASA pluto since:2015-07-01 until:2016-01-01",
    ],
    "sort": "Latest",
})

posts = {i["id"]: i for i in client.dataset(run.default_dataset_id).iterate_items()}
print(len(posts), "posts")
```

Each query must return at least 50 tweets, and one run batches up to 5 queries. Generating windows for a whole year is shown in [how to scrape tweets by date range](/blog/twitter-scraping/scrape-tweets-by-date/).

## What Does Historical Tweet Data Cost?

**Historical tweet data costs $5 per 1,000 posts through X’s full-archive search and $0.40 per 1,000 through Tweet Scraper V2.** The table shows the difference at common volumes.

| Posts | X API full-archive | Tweet Scraper V2 |
| --- | --- | --- |
| 10,000 | $50 | $4 |
| 100,000 | $500 | $40 |
| 1,000,000 | $5,000 | $400 |
| 3,000,000 | $15,000 (the monthly cap) | $1,200 |

Above 3 million post reads per month, the X API requires an Enterprise plan (X API pricing). The full decision guide is [X API vs Twitter scraper API](/blog/twitter-api/x-api-vs-scraper/).

## Which Historical Tweets Can’t Any API Return?

**No API returns deleted posts, and search-based methods don’t return posts from protected accounts.** Private and suspended accounts are not in X’s search index ([twitter-advanced-search reference](https://github.com/igorbrigadir/twitter-advanced-search)). For your own deleted posts, only an X archive you downloaded before deleting them still holds them; see [how to find deleted tweets](/blog/x-guides/find-deleted-tweets/).

## The scrapers behind this

-   [Tweet Scraper V2 Tweets from searches, profiles, Lists and URLs; 49–64 tweets/sec; minimum 50 per query $0.40 / 1K tweets](/scrapers/twitter-scraper/)

## Questions people ask

### Is there a free API for historical tweets?

No, new X developers pay per use from prepaid credits; full-archive search is on pay-per-use and Enterprise access (X API docs).

### How far back does the X API go?

Full-archive search reaches back to March 2006; recent search covers the last 7 days.

### Can you get your own old tweets more cheaply?

Yes, X bills reads of your own posts at $0.001 each as owned reads, and your X archive download is free; see [how to find old tweets on X](/blog/twitter-search/find-old-tweets/).

### Where do you start?

Start at [how to scrape Twitter data in 2026](/blog/twitter-scraping/how-to-scrape-twitter/) or the [apidojo Twitter Scraper](/scrapers/twitter-scraper/).

## More on the X API

-   [Twitter Search API: Endpoints, Pricing and Examples X API recent and full-archive search explained: limits, operators, $0.005 per post pricing, code, and a cheaper scraper API option.](/blog/twitter-api/search-api/)
-   [How to Get Tweet Data by ID With an API Look up tweets by ID with the X API, 100 at a time, or without a developer account, and see which route is cheaper at each volume.](/blog/twitter-api/tweet-by-id/)
-   [Twitter Recent Search API: The 7-Day Limit Why the X API's recent search returns only 7 days of posts, how to reach older tweets, and what each option costs.](/blog/twitter-api/recent-search-7-days/)
-   [X API vs Twitter Scraper API: Which to Use Compare the X API and a Twitter scraper API on price, history, limits, write access and terms, with a decision table for 7 jobs.](/blog/twitter-api/x-api-vs-scraper/)

![apidojo](/blog/authors/apidojo.png)

## [Apidojo](/blog/authors/apidojo/)

15+ years of experience in data retrieval.

API Dojo is always ready for you. With 15+ years of experience, data acquisition has never been that easy. Cheapest prices with high availability.

-   🏯 15+ years of experience in data retrieval.
-   💰 Cheapest prices, qualified data.
-   ⚙️ High availability, extreme maintenance.
-   🐉 Hyper communicative, excellent support.

-   [apify.com](https://apify.com/apidojo)
-   [x.com](https://x.com/apidojo_)
-   [github.com](https://github.com/apidojo-io)
