# X (Twitter) Tweet Scraper - Latest Posts by Profile (`socialscrapers/x-tweet-scraper`) Actor

X (Twitter) tweet scraper: latest tweets of any Twitter profile, one row per post, with text, date, likes, retweets, replies, views, media and author followers. Brand accounts: newest ~800 posts; many personal accounts: ~100 top posts. No search. No login. $0.13 per 1,000 tweets.

- **URL**: https://apify.com/socialscrapers/x-tweet-scraper.md
- **Developed by:** [Social Scrapers](https://apify.com/socialscrapers) (community)
- **Categories:** Social media, Lead generation
- **Features:** Limited permissions
- **Stats:** 4 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.10 / 1,000 post (tweet)s

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

**X (Twitter) Tweet Scraper** extracts the latest public tweets (posts) of any X profile, one row per post: full text, date, likes, retweets, replies, quotes, bookmarks, views, hashtags, mentions, links, photos and video URLs, the reposted or quoted tweet, and the author's handle, name, ID, followers and checkmark. No X account, login, cookies or API key. **$0.13 per 1,000 tweets.**

> 💡 **Need a feature that isn't here? Just ask.** Open an issue on the **Issues** tab and tell us what you need: a new field, filter, input type or output format. We build requested features fast, usually within 24 hours, at no extra cost.

> ⭐ **Found it useful?** A short review on the **Reviews** tab helps other people find this scraper, and tells us what to build next.

### What does X (Twitter) Tweet Scraper do?

Give it X handles or profile URLs and it reads each profile's posts the way a logged-out visitor sees them, then saves every post as its own dataset item you can download as JSON, CSV, Excel or HTML, or read through the Apify API.

- 📝 **Tweets as rows**: one item per post, with the same columns every time, ready for spreadsheets, BI tools and AI pipelines.
- 📊 **Engagement**: likes, retweets (reposts), replies, quotes, bookmarks and views for every post.
- 🖼️ **Media**: photos, videos (MP4 links) and GIFs, with alt text.
- 🔁 **Reposts and quotes**: the original post's author, text, date and counts come with it; turn reposts off to keep only the account's own posts.
- 👤 **Author on every row**: handle, name, numeric ID, followers, checkmark type and profile URL.
- 📅 **Date filter**: keep only posts newer than a date (`2026-01-31`, `31/01/2026`, `Jan 31 2026`) or an age (`7 days`, `2w`, `3 months`, `yesterday`).
- 💸 **Pay only for posts saved**: handles that don't exist or are suspended cost nothing, and a run stops exactly at the maximum cost you set.

### Which tweets can it get?

X shows logged-out visitors different things for different accounts, and this scraper says which one every post came from (`tweetsOrder`):

- **Brand, media and organisation accounts** (NASA, Google, CNN, SpaceX, Nike, WHO, ESPN and most companies): their **newest posts, about 800 back**, newest first (`latest`).
- **Many personal accounts** (often the biggest individual accounts): about **100 of their most popular posts** from across the years instead of the newest (`top`).
- **Not available logged out**: keyword or hashtag search, replies to other accounts, likes, followers lists and protected accounts' posts. The owner's own threads (replies to themselves) are included.

### What data can you extract from X (Twitter)?

| Field | What it is |
|---|---|
| `id`, `url`, `conversationId` | Post ID, link on x.com, ID of the thread's first post |
| `text`, `lang` | Full text (long posts included) with links expanded; language |
| `createdAt` | When it was posted, ISO 8601 (UTC) |
| `likeCount`, `retweetCount`, `replyCount`, `quoteCount`, `bookmarkCount`, `viewCount` | Engagement counts |
| `isPinned`, `isRetweet`, `isQuote`, `isReply`, `inReplyToTweetId`, `inReplyToHandle` | What kind of post it is |
| `hashtags`, `mentions`, `links` | Hashtags, mentioned handles and expanded links |
| `media` | Photos, videos and GIFs: type, image URL, MP4 URL, alt text |
| `retweetedTweet`, `quotedTweet` | The reposted or quoted post: ID, URL, author, text, date and counts |
| `source`, `possiblySensitive` | Posting app (when X says) and the sensitive-media flag |
| `authorHandle`, `authorName`, `authorId`, `authorFollowersCount`, `authorIsBlueVerified`, `authorVerifiedType`, `authorProfileUrl` | The author |
| `tweetsOrder` | `latest` or `top` (see above) |
| `scrapedAt` | When the post was read |

### How to scrape tweets from X (Twitter)

1. Add handles or profile URLs to **X handles or profile URLs**, one per line.
2. Set **Max posts per profile** (for example `100`; `0` saves every post X shows).
3. Optional: set **Only posts newer than** (for example `30 days`) and turn **Include reposts** off for original posts only.
4. Click **Start**. Posts appear in the **Output** tab as they are read.
5. Export the dataset as JSON, CSV, Excel or HTML, or fetch it with the Apify API.

### How much does it cost to scrape tweets?

| What | Price per 1,000 | Silver plan | Gold plan |
|---|---|---|---|
| Tweet (post) | **$0.13** | $0.117 | $0.104 |

- **10,000 tweets** cost **$1.30**.
- **The latest 200 posts of 50 brand accounts** (10,000 posts) cost **$1.30**.

Each run also has a $0.001 start fee.

Platform usage and proxies are included. Handles that don't exist or are suspended are free. Set a **maximum cost per run** when you start the Actor: it stops cleanly before the first post it could not pay for, and keeps everything saved so far. Apify's free plan includes monthly platform credit, enough to try it on tens of thousands of tweets.

### Input example

```json
{
  "handles": ["NASA", "@Google", "https://x.com/SpaceX"],
  "maxTweetsPerProfile": 100,
  "onlyTweetsNewerThan": "30 days",
  "includeRetweets": false,
  "proxyConfiguration": { "useApifyProxy": true, "apifyProxyGroups": ["RESIDENTIAL"] }
}
```

### Output example

```json
{
  "id": "2119136607009734978",
  "url": "https://x.com/NASA/status/2119136607009734978",
  "text": "Do you want to be an astronaut?\n\nApplications are now open to join NASA's astronaut corps. Join us as we expand the frontiers of discovery in low Earth orbit, on the Moon, and beyond — apply by Dec. 3: https://go.nasa.gov/4iGqLqu",
  "createdAt": "2026-11-07T18:35:13.000Z",
  "lang": "en",
  "likeCount": 3137,
  "retweetCount": 623,
  "replyCount": 286,
  "quoteCount": 169,
  "bookmarkCount": 422,
  "viewCount": 582988,
  "isPinned": false,
  "isRetweet": false,
  "isQuote": false,
  "isReply": false,
  "inReplyToTweetId": null,
  "inReplyToHandle": null,
  "conversationId": "2119136607009734978",
  "hashtags": [],
  "mentions": [],
  "links": ["https://go.nasa.gov/4iGqLqu"],
  "media": [
    {
      "type": "video",
      "url": "https://pbs.twimg.com/media/HWivgtWW8AEKfEF.jpg",
      "videoUrl": "https://video.twimg.com/amplify_video/2119136507600531456/vid/avc1/1080x1920/kYn5lFx09UoeDMkc.mp4?tag=16",
      "altText": null
    }
  ],
  "retweetedTweet": null,
  "quotedTweet": null,
  "source": null,
  "possiblySensitive": false,
  "authorHandle": "NASA",
  "authorName": "NASA",
  "authorId": "11348282",
  "authorFollowersCount": 92271708,
  "authorIsBlueVerified": true,
  "authorVerifiedType": "Government",
  "authorProfileUrl": "https://x.com/NASA",
  "tweetsOrder": "latest",
  "scrapedAt": "2026-11-08T11:52:23.023Z"
}
```

### Use cases

- **Brand and competitor monitoring**: collect what brands, publishers and organisations post, with engagement, on a daily schedule.
- **Social listening and sentiment**: feed recent posts of chosen accounts into sentiment analysis, summaries or alerts.
- **Content research**: find which posts, formats and topics get the most views, likes and reposts.
- **Influencer and creator analysis**: compare engagement across accounts you choose.
- **AI and RAG datasets**: build clean text datasets of public posts with dates, authors and counts.

### Use it via API, Python, JavaScript and integrations

Run the X (Twitter) Tweet Scraper from your own code with the [Apify API](https://docs.apify.com/api/v2):

```bash
curl -X POST "https://api.apify.com/v2/acts/socialscrapers~x-tweet-scraper/run-sync-get-dataset-items?token=<YOUR_API_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{"handles": ["NASA"], "maxTweetsPerProfile": 50}'
```

Python, with the `apify-client` package:

```python
from apify_client import ApifyClient

client = ApifyClient("<YOUR_API_TOKEN>")
run = client.actor("socialscrapers/x-tweet-scraper").call(run_input={"handles": ["NASA", "Google"], "maxTweetsPerProfile": 50})
for post in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(post["authorHandle"], post["createdAt"], post["likeCount"], post["text"][:80])
```

JavaScript, with the `apify-client` package:

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

const client = new ApifyClient({ token: '<YOUR_API_TOKEN>' });
const run = await client.actor('socialscrapers/x-tweet-scraper').call({ handles: ['NASA'], maxTweetsPerProfile: 50 });
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items.length, 'tweets');
```

It also works without code: connect it to **Make**, **Zapier**, **n8n**, **Google Sheets**, Slack or webhooks from the **Integrations** tab, run it on a **schedule**, and let AI agents call it through the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp).

### Limits

- **Public posts only, no login.** The scraper sees what X shows a logged-out visitor.
- **About 800 newest posts** for most brand and organisation accounts; **about 100 popular posts** for many personal accounts (see above). `tweetsOrder` says which.
- **No keyword or hashtag search, no replies to other accounts, no likes or followers lists**: X shows them only to logged-in users.
- **Protected accounts** give no posts.
- **Datacenter proxy choices fall back to residential.** If you pick Apify Proxy without the RESIDENTIAL group, the first session X refuses moves the run to RESIDENTIAL, in the same country. Custom HTTP(S) proxy URLs are used as given; a proxy choice that can't be used at all (SOCKS URLs, a country Apify Proxy doesn't offer) falls back to RESIDENTIAL, with a warning in the log.
- **Share and short links work.** `t.co/…` links are followed to the profile or post they lead to, a post link without a handle (`x.com/i/web/status/…`) reads its author's profile, and `mobile.twitter.com`, `twitter.com`, `fxtwitter.com`, `nitter.net` and `xcancel.com` links name their profile directly. Following a link is never charged.
- **A run with 0 results still succeeds when your input was fine.** When a handle does not exist, is suspended or withheld, or a link leads nowhere, the run ends as Succeeded with a status message naming each input and why, and nothing is charged.
- **Input that can't be used doesn't fail the run either.** When no entry holds a handle or link, a date lies in the future, or the proxy you chose can't be set up, the run ends as Succeeded with a status message starting "Nothing to scrape:" that says why and how to fix the input, and no results are charged. A run fails only on an internal error, or when X refuses every one of 3 or more inputs and also a known public profile, which the Actor then reads once.

### FAQ

**Is it legal to scrape X (Twitter)?**
The X (Twitter) Tweet Scraper only reads posts X shows publicly to anyone without an account. Whether you may use them depends on your purpose and jurisdiction (for example personal-data rules such as the GDPR), so check before you store or publish personal data.

**Do I need an X account, cookies or an API key?**
No. You only need a list of handles or profile URLs.

**Why are some accounts' tweets years old?**
For many personal accounts X shows logged-out visitors a selection of about 100 popular posts rather than the latest ones. Those posts have `tweetsOrder` set to `top`.

**Why did I get fewer tweets than I asked for?**
The account has fewer posts, the date limit was reached, the account is protected or shows its top posts, X stopped showing older posts, or the run hit its maximum cost. The run's `SUMMARY` record says which, per profile.

**How do I collect only new tweets every day?**
Schedule the Actor daily with **Only posts newer than** set to `1 day` (or `25 hours` for some overlap).

**Do I need profile data too?**
Use the [X (Twitter) Profile Scraper](https://apify.com/socialscrapers/x-profile-scraper) for followers, bio, links, verification and affiliation, with the latest posts nested in each profile.

### Other scrapers by Social Scrapers

| Scraper | What it gets |
| --- | --- |
| [TikTok API](https://apify.com/socialscrapers/tiktok-api) | Profiles, Videos and Comments |
| [TikTok Comments Scraper](https://apify.com/socialscrapers/tiktok-comments-scraper) | Comments, Replies and Likes |
| [TikTok Hashtag Scraper](https://apify.com/socialscrapers/tiktok-hashtag-scraper) | Top Videos, Views and Likes |
| [TikTok Profile Scraper](https://apify.com/socialscrapers/tiktok-profile-scraper) | Followers, Bio, Stats and Videos |
| [TikTok Scraper](https://apify.com/socialscrapers/tiktok-scraper) | Videos, Profiles, Hashtags and Comments |
| [TikTok Sound Scraper](https://apify.com/socialscrapers/tiktok-sound-scraper) | Videos Using a Sound and Music Info |
| [TikTok Video Scraper](https://apify.com/socialscrapers/tiktok-video-scraper) | Views, Likes, Captions and Comments |
| [Instagram API](https://apify.com/socialscrapers/instagram-api) | Profiles, Posts, Reels, Comments and Hashtags |
| [Instagram Comments Scraper](https://apify.com/socialscrapers/instagram-comments-scraper) | Comments, Likes and Reply Counts |
| [Instagram Hashtag Scraper](https://apify.com/socialscrapers/instagram-hashtag-scraper) | Reels and Keyword Search |
| [Instagram Post Details Scraper](https://apify.com/socialscrapers/instagram-post-details-scraper) | Likes, Comments, Views and Media |
| [Instagram Post Scraper](https://apify.com/socialscrapers/instagram-post-scraper) | Posts, Reels and Comments |
| [Instagram Profile Scraper](https://apify.com/socialscrapers/instagram-profile-scraper) | Followers, Bio, Posts and Reels |
| [Instagram Reels Scraper](https://apify.com/socialscrapers/instagram-reels-scraper) | Reels, Plays, Likes and Comments |
| [Instagram Reels Transcript Scraper](https://apify.com/socialscrapers/instagram-reels-transcript-scraper) | Speech to Text and Captions |
| [Instagram Scraper](https://apify.com/socialscrapers/instagram-scraper) | Posts, Profiles, Reels, Comments and Hashtags |
| [YouTube API](https://apify.com/socialscrapers/youtube-api) | Videos, Transcripts, Search, Channels and Comments |
| [YouTube Channel Scraper](https://apify.com/socialscrapers/youtube-channel-scraper) | Videos, Shorts, Subscribers and About |
| [YouTube Comments Scraper](https://apify.com/socialscrapers/youtube-comments-scraper) | Comments, Replies and Likes |
| [YouTube Scraper](https://apify.com/socialscrapers/youtube-scraper) | Videos, Shorts, Channels and Comments |
| [YouTube Search Scraper](https://apify.com/socialscrapers/youtube-search-scraper) | Videos, Channels, Views and Filters |
| [YouTube Shorts Scraper](https://apify.com/socialscrapers/youtube-shorts-scraper) | Shorts, Views, Likes and Search |
| [YouTube Transcript Scraper](https://apify.com/socialscrapers/youtube-transcript-scraper) | Subtitles, Captions and SRT |
| [YouTube Video Details Scraper](https://apify.com/socialscrapers/youtube-video-details-scraper) | Stats, Subtitles and Comments |
| [Facebook Ads Library Scraper](https://apify.com/socialscrapers/facebook-ads-library-scraper) | Meta Ad Library and Spend |
| [Facebook Comments Scraper](https://apify.com/socialscrapers/facebook-comments-scraper) | Posts, Reels, Videos and Replies |
| [Facebook Groups Scraper](https://apify.com/socialscrapers/facebook-groups-scraper) | Public Group Posts and Reactions |
| [Facebook Marketplace Scraper](https://apify.com/socialscrapers/facebook-marketplace-scraper) | Prices, Locations and Sellers |
| [Facebook Page Contact Info Scraper](https://apify.com/socialscrapers/facebook-page-contact-scraper) | Email, Phone and WhatsApp |
| [Facebook Posts Scraper](https://apify.com/socialscrapers/facebook-profile-posts-scraper) | Pages, Profiles and Timelines |
| [Facebook Pages Scraper](https://apify.com/socialscrapers/facebook-profile-scraper) | Profiles, Contact Info and Reviews |
| [Facebook Reels Scraper](https://apify.com/socialscrapers/facebook-reels-scraper) | Reels, Videos, Plays and Captions |
| [X (Twitter) Profile Scraper](https://apify.com/socialscrapers/x-profile-scraper) | Followers, Bio and Tweets |
| [Threads Profile Scraper](https://apify.com/socialscrapers/threads-profile-scraper) | Followers, Bio, Links and Posts |
| [Threads Replies Scraper](https://apify.com/socialscrapers/threads-replies-scraper) | Comments, Authors, Likes and Media |
| [Threads Scraper](https://apify.com/socialscrapers/threads-scraper) | Posts, Profiles, Replies and Search |
| [Threads Search Scraper](https://apify.com/socialscrapers/threads-search-scraper) | Keywords, Hashtags, Top and Recent Posts |
| [Reddit Comments Scraper](https://apify.com/socialscrapers/reddit-comments-scraper) | Threads, Replies, Votes and Authors |
| [Reddit Scraper](https://apify.com/socialscrapers/reddit-scraper) | Posts, Comments, Subreddits, Users and Search |
| [Reddit Search Scraper](https://apify.com/socialscrapers/reddit-search-scraper) | Posts by Keyword, Subreddit and Date |
| [Reddit User Scraper](https://apify.com/socialscrapers/reddit-user-scraper) | Profiles, Karma, Posts and Comments |
| [Subreddit Scraper](https://apify.com/socialscrapers/subreddit-scraper) | Hot, New and Top Posts with Comments |
| [Quora Scraper](https://apify.com/socialscrapers/quora-scraper) | Answers, Questions, Profiles and Topic Search |
| [LinkedIn Ad Library Scraper](https://apify.com/socialscrapers/linkedin-ad-library-scraper) | Ads, Advertisers and Impressions |
| [LinkedIn Job Search Scraper](https://apify.com/socialscrapers/linkedin-job-search-scraper) | Filters, Salaries and New Jobs |
| [LinkedIn Jobs Scraper](https://apify.com/socialscrapers/linkedin-jobs-scraper) | Job Listings, Salaries and Companies |
| [Google Maps Email Extractor](https://apify.com/socialscrapers/google-maps-email-extractor) | Emails, Phones and Social Links |
| [Google Maps Scraper](https://apify.com/socialscrapers/google-maps-scraper) | Places, Phones, Websites, Ratings and Hours |
| [Google News Scraper](https://apify.com/socialscrapers/google-news-scraper) | Headlines, Articles and Search |
| [Google Ads Transparency Scraper](https://apify.com/socialscrapers/google-ads-transparency-scraper) | Ad Creatives and Advertisers |
| [Amazon Product Scraper](https://apify.com/socialscrapers/amazon-product-scraper) | Search Results, Prices, Ratings, ASINs |
| [Indeed Jobs Scraper](https://apify.com/socialscrapers/indeed-jobs-scraper) | Salaries, Full Descriptions, Company Data |
| [Contact Details Scraper](https://apify.com/socialscrapers/contact-details-scraper) | Emails, Phones and Social Links |
| [Telegram Channel Scraper](https://apify.com/socialscrapers/telegram-channel-scraper) | Posts, Views and Media |
| [Doximity Scraper](https://apify.com/socialscrapers/doximity-physician-scraper) | Physician Profiles and Doctor Directory |
| [KevinMD Scraper](https://apify.com/socialscrapers/kevinmd-articles-scraper) | Physician Articles and Author Specialties |
| [Op-Med Scraper](https://apify.com/socialscrapers/opmed-articles-scraper) | Physician Essays and Doctor Profiles |
| [Career Site Jobs Scraper](https://apify.com/socialscrapers/career-site-jobs-scraper) | Greenhouse, Lever, Ashby and Workday |
| [Google Trends Scraper](https://apify.com/socialscrapers/google-trends-scraper) | Interest Over Time, Regions and Queries |

# Actor input Schema

## `handles` (type: `array`):

One per line: a handle (NASA or @NASA) or a profile URL (https://x.com/NASA, https://twitter.com/NASA). A post link reads its author, and t.co short links are followed to the profile or post they lead to. Duplicates are read once. Example: NASA

## `maxTweetsPerProfile` (type: `integer`):

How many posts to save from each profile, newest first. 0 saves every post X shows a logged-out visitor (about 800 for most brand and organisation accounts; see the README). Example: 100

## `onlyTweetsNewerThan` (type: `string`):

Keep only posts from this date on, and stop reading a profile there. Pick a date or an age, or type one: a date (2026-01-31, 31/01/2026, Jan 31 2026; a UTC day), a date-time through the API (2026-01-31T18:00:00Z) or an age (7 days, 2w, 3 months, yesterday). Leave empty for no date limit.

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

Keep reposts (retweets). Turn off for the account's own posts only; they still count toward Max posts per profile.

## `tweetsAsItems` (type: `boolean`):

Fixed for this Actor: every post is its own dataset item.

## `proxyConfiguration` (type: `object`):

Residential proxies give the most reliable results and are the default.

## Actor input object example

```json
{
  "handles": [
    "NASA"
  ],
  "maxTweetsPerProfile": 10,
  "includeRetweets": true,
  "tweetsAsItems": true,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# Actor output Schema

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

No description

# 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 = {
    "handles": [
        "NASA"
    ],
    "maxTweetsPerProfile": 10,
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ]
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("socialscrapers/x-tweet-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 = {
    "handles": ["NASA"],
    "maxTweetsPerProfile": 10,
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
    },
}

# Run the Actor and wait for it to finish
run = client.actor("socialscrapers/x-tweet-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 '{
  "handles": [
    "NASA"
  ],
  "maxTweetsPerProfile": 10,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}' |
apify call socialscrapers/x-tweet-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,socialscrapers/x-tweet-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/HzwvRaat1LocLIX2z/builds/MtsUnIBCe2S1eWXVY/openapi.json
