# X (Twitter) Historical Tweets Scraper - Any Date Range (`seemuapps/x-historical-tweets-scraper`) Actor

Scrape every tweet an X (Twitter) account posted between any two dates - full text, engagement metrics, media and links - going back years, with keyword, language and reply filters.

- **URL**: https://apify.com/seemuapps/x-historical-tweets-scraper.md
- **Developed by:** [Andrew](https://apify.com/seemuapps) (community)
- **Stats:** 2 total users, 1 monthly users, 95.5% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 tweet scrapeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## X (Twitter) Historical Tweets Scraper - Any Date Range

Get every tweet an X (Twitter) account posted between any two dates - last month, a specific quarter, or all of 2019 - with full text, likes, reposts, replies, views, bookmarks, media links, hashtags, mentions and URLs. No login, no cookies, no API keys, and no 3,200-tweet timeline limit: the actor walks the date range window by window so years-old posts stay reachable.

Enter usernames and a start and end date, and export the results to JSON, CSV, Excel or Google Sheets.

### What you get

One row per tweet, newest first:

- **username**, **tweetId**, **url**, **text**, **createdAt**, **lang**, **source** (the app used to post)
- **likeCount**, **retweetCount**, **replyCount**, **quoteCount**, **viewCount**, **bookmarkCount**
- **isReply**, **inReplyToId**, **inReplyToUsername**, **conversationId**
- **isQuote**, **quotedTweetUrl**, **isRetweet**, **retweetedTweetUrl**
- **hashtags**, **mentions**, **links** (expanded URLs), **mediaUrls** (best-quality MP4 or image), **mediaTypes**
- **authorUserId**, **authorName**, **authorIsBlueVerified**, **authorFollowersCount**

### Use cases

- **Archive an account's history** - export everything a brand, politician or creator posted in a given year
- **Campaign and PR analysis** - measure engagement on every post published during a launch window
- **Research and journalism** - pull what an account said about a topic between two dates with the **Keywords** filter
- **Competitor benchmarking** - compare posting volume and engagement across accounts, quarter by quarter
- **Model training and NLP** - build dated, labelled corpora from specific accounts
- **Compliance and monitoring** - keep a dated record of official communications

### How to use

1. Enter one or more **Usernames** (with or without @).
2. Set **Start date** and **End date** in `YYYY-MM-DD` format. Leave the end date empty for today.
3. Optionally add **Keywords** (standard X search syntax: `launch OR rocket`, `"exact phrase"`, `#tag`, `-word`) or a **Language**.
4. Choose whether to **Include replies** (on by default) and **Include reposts** (off by default).
5. Set **Max tweets per account** (default 1,000, `0` for everything in the range) and run.

Results stream into the **Dataset** tab as each window completes.

### Output format

Each dataset record:

```json
{
  "username": "NASA",
  "tweetId": "1625974393166856219",
  "url": "https://x.com/NASA/status/1625974393166856219",
  "text": "Have humans ever visited Mars?\n\nNot yet, but our rovers have...",
  "createdAt": "2023-02-15T21:44:39.000Z",
  "lang": "en",
  "source": "Sprinklr",
  "retweetCount": 412,
  "replyCount": 233,
  "likeCount": 2003,
  "quoteCount": 41,
  "viewCount": 1431121,
  "bookmarkCount": 57,
  "isReply": false,
  "inReplyToId": null,
  "inReplyToUsername": null,
  "conversationId": "1625974393166856219",
  "isQuote": false,
  "quotedTweetUrl": null,
  "isRetweet": false,
  "retweetedTweetUrl": null,
  "hashtags": [],
  "mentions": ["NASAPersevere"],
  "links": ["https://go.nasa.gov/3xyz"],
  "mediaUrls": ["https://video.twimg.com/amplify_video/.../1280x720/abc.mp4"],
  "mediaTypes": ["video"],
  "authorUserId": "11348282",
  "authorName": "NASA",
  "authorIsBlueVerified": true,
  "authorFollowersCount": 88231000
}
```

### Pricing

You pay a small fixed amount per tweet returned. Date windows that contain no tweets are free, and reply/repost filters are applied before fetching so you never pay for tweets you filtered out.

### Tips

- For very active accounts (hundreds of posts a day) lower **Search window (days)** to 7 so each window stays fully paginated.
- Combine a wide date range with **Keywords** to answer questions like "everything @brand said about pricing in 2024".
- Turn **Include replies** off for a cleaner feed of original posts only.
- Run several accounts in one go - the **username** column lets you split them afterwards.

### FAQ

**How far back can it go?**
As far as X's search index reaches - in practice back to the account's first tweets.

**Are deleted tweets included?**
No. Only tweets that are still publicly visible on X can be returned.

**Why did I get fewer tweets than expected?**
Reply and repost filters remove rows, and X's search occasionally omits a small number of posts. Try a smaller window if an account is extremely active.

# Actor input Schema

## `usernames` (type: `array`):

X / Twitter handles to scrape (with or without @), one per line. Profile URLs are also accepted.

## `startDate` (type: `string`):

First day to include, in YYYY-MM-DD format (UTC). Can be years in the past.

## `endDate` (type: `string`):

Last day to include, in YYYY-MM-DD format (UTC). Leave empty for today.

## `keywords` (type: `string`):

Only return tweets matching these words. Standard X search syntax works, e.g. `launch OR rocket`, `"exact phrase"`, `#hashtag`, `-exclude`.

## `includeReplies` (type: `boolean`):

Keep the account's replies to other people. Turn off for original posts only.

## `includeRetweets` (type: `boolean`):

Also return posts the account reposted. Off by default.

## `language` (type: `string`):

Optional two-letter language code (en, es, de, ...) to keep only tweets in that language.

## `maxTweetsPerUser` (type: `integer`):

Stop after this many tweets for each account, newest first. 0 = everything in the date range.

## `windowDays` (type: `integer`):

Advanced. The date range is walked backwards in windows of this many days so very active accounts stay fully reachable. 0 = automatic (30 days).

## Actor input object example

```json
{
  "usernames": [
    "NASA"
  ],
  "startDate": "2023-01-01",
  "endDate": "2023-01-31",
  "includeReplies": true,
  "includeRetweets": false,
  "maxTweetsPerUser": 1000,
  "windowDays": 0
}
```

# Actor output Schema

## `results` (type: `string`):

One record per tweet: username, tweetId, url, text, createdAt, lang, source, retweetCount, replyCount, likeCount, quoteCount, viewCount, bookmarkCount, isReply, inReplyToId, inReplyToUsername, conversationId, isQuote, quotedTweetUrl, isRetweet, retweetedTweetUrl, hashtags, mentions, links, mediaUrls, mediaTypes, author fields.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "usernames": [
        "NASA"
    ],
    "startDate": "2023-01-01",
    "endDate": "2023-01-31"
};

// Run the Actor and wait for it to finish
const run = await client.actor("seemuapps/x-historical-tweets-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "usernames": ["NASA"],
    "startDate": "2023-01-01",
    "endDate": "2023-01-31",
}

# Run the Actor and wait for it to finish
run = client.actor("seemuapps/x-historical-tweets-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "usernames": [
    "NASA"
  ],
  "startDate": "2023-01-01",
  "endDate": "2023-01-31"
}' |
apify call seemuapps/x-historical-tweets-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,seemuapps/x-historical-tweets-scraper"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/klvcNA3x5bsJtDoI6/builds/RjU5y13XlWsApH1PJ/openapi.json
