# X (Twitter) Sentiment Analysis (`lofomachines/x-twitter-sentiment-analysis`) Actor

Collect public X (Twitter) posts in bulk with advanced search queries, handle lists, date ranges, language targeting and optional AI sentiment tagging. No login required.

- **URL**: https://apify.com/lofomachines/x-twitter-sentiment-analysis.md
- **Developed by:** [Lofomachines](https://apify.com/lofomachines) (community)
- **Categories:** Social media, News, AI
- **Stats:** 2 total users, 2 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.50 / 1,000 tweets

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/platform/actors/running/actors-in-store#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) Scraper — Posts, Profiles & AI Sentiment | No Login Required

**Collect public X (Twitter) posts in bulk — by keyword, hashtag, advanced search query or username — with built-in AI sentiment analysis. No X account, no API key, no rate-limit headaches.**

Search X the way you actually think about it: give the Actor a list of topics and a list of handles, choose your date range and language, and get back a clean, analysis-ready dataset of posts with full engagement metrics, author profiles, media links and sentiment labels.

***

### ✨ Why people use this Actor

- 🔓 **No login, no X API, no developer account.** Skip the paid X API tiers entirely.
- 🔍 **Bulk search.** Dozens of keywords and handles in a single run.
- 🧠 **AI sentiment built in.** Every post tagged positive / negative / neutral / mixed, with a confidence score and emotional tone. *(Paid Apify plans only.)*
- 🗓 **Precise date filtering.** Pull a specific week, month, quarter or campaign window.
- 🌍 **32 languages.** Target Italian, English, Spanish, French, German, Japanese, Arabic and more.
- 📊 **Rich output — 55+ fields per post.** Engagement, author authority, hashtags, mentions, links, media, threading.
- 🔁 **Latest, Top, or both.** Chronological monitoring or highest-impact posts.
- ⚡ **Fast and predictable.** Built for large jobs that finish.

***

### 💡 What you can do with it

#### 📈 Brand monitoring & reputation tracking

Track every mention of your brand, product or executives. Sentiment tagging tells you *how* people feel — not just how often you're mentioned. Catch a PR problem while it's still small.

#### 🥊 Competitor intelligence

Monitor competitor handles and branded keywords. See what they announce, how audiences react, which posts land and which fall flat.

#### 🗳 Market & opinion research

Sample public opinion on a policy, product category, election or trend across a defined time window and language. Perfect for researchers, analysts and journalists.

#### 🚀 Campaign & launch measurement

Set a start and end date around your launch and measure share of voice, engagement volume and sentiment shift before vs. after.

#### 💰 Crypto, finance & stock signals

Follow cashtags, project hashtags and key influencer accounts. Turn social chatter into a sentiment time series you can chart.

#### 🎯 Lead generation & social selling

Find people publicly expressing intent — asking for recommendations, complaining about a competitor, or looking for a solution you sell.

#### 📰 News monitoring & OSINT

Track breaking topics, verify what accounts said and when, and archive public posts around an event with full timestamps.

#### 🎨 Influencer & creator discovery

Search a niche, sort by Top, and surface the accounts driving real engagement — with follower counts and authority signals attached.

#### 🤖 AI / LLM training & RAG datasets

Build clean, labelled, language-filtered text corpora with engagement signals for fine-tuning or retrieval.

#### 📅 Content research

See which angles, formats and hooks perform in your niche before you write a single post.

***

### 🚀 Input

Everything is optional except: give it **at least one search term or one handle**.

| Field | What it does |
|---|---|
| **Search terms** | Keywords, phrases, hashtags or full X queries — one per line |
| **X (Twitter) handles** | Usernames whose posts you want — with or without `@` |
| **Maximum posts per search** | Limit applied to *each* term and *each* handle |
| **Sort by** | `Latest`, `Top`, or `Latest + Top` |
| **Language** | Any of 32 languages, or Any |
| **Posted after / Posted before** | Date range — absolute (`2024-01-01`) or relative (`7 days`) |
| **Add AI sentiment analysis** | Toggle sentiment, score, confidence and tone — **paid plans only** |

#### Example input

```json
{
  "searchTerms": [
    "artificial intelligence",
    "#Bitcoin",
    "\"black friday\" sale",
    "tesla OR rivian"
  ],
  "twitterHandles": ["elonmusk", "NASA", "@OpenAI"],
  "maxItems": 500,
  "sortBy": "latest_and_top",
  "language": "en",
  "startDate": "2024-11-01",
  "endDate": "2024-12-01",
  "sentimentAnalysis": true
}
```

> 💡 **Tip — advanced search:** Search terms accept standard X search syntax. Try `from:nike -filter:replies`, `"climate change" min_faves:100`, `#SEO filter:media`, or `(iphone OR pixel) lang:it`. The Actor merges your UI filters in automatically without conflicting with operators you write yourself.

***

### 📤 Output

One row per post, flat and consistent — ready for Excel, Google Sheets, BI tools or a database.

#### Example output

```json
{
  "postId": "1861234567890123456",
  "url": "https://x.com/NASA/status/1861234567890123456",
  "createdAt": "2024-11-18T14:32:11.000Z",
  "text": "Our Webb telescope just revealed something remarkable about this distant galaxy. 🔭",
  "language": "en",
  "postType": "original",

  "authorUsername": "NASA",
  "authorName": "NASA",
  "authorVerified": true,
  "authorFollowers": 74800521,
  "authorBio": "Explore the universe and discover our home planet.",
  "authorLocation": "Pale Blue Dot",
  "authorUrl": "https://x.com/NASA",

  "likeCount": 48213,
  "retweetCount": 7104,
  "replyCount": 892,
  "viewCount": 3120455,
  "engagementTotal": 56209,
  "engagementRate": 1.8014,

  "hashtags": ["Webb"],
  "mentions": [],
  "externalLinks": ["https://nasa.gov/webb"],
  "mediaType": "photo",
  "mediaUrls": ["https://pbs.twimg.com/media/Gc7xY2aXwAA1234.jpg"],

  "sentiment": "positive",
  "sentimentScore": 0.78,
  "sentimentConfidence": 0.93,
  "emotionalTone": "excited",

  "searchTerm": "@NASA",
  "matchedBy": "handle",
  "sortMode": "latest",
  "scrapedAt": "2024-11-19T09:14:52.881Z"
}
```

#### Field groups

| Group | Fields |
|---|---|
| **Identity** | `postId`, `url`, `createdAt`, `createdAtTimestamp` |
| **Content** | `text`, `textLength`, `language`, `postType`, `isReply`, `isRepost`, `isQuote` |
| **Author** | `authorUsername`, `authorName`, `authorId`, `authorVerified`, `authorBio`, `authorLocation`, `authorFollowers`, `authorFollowing`, `authorPostCount`, `authorWebsite`, `authorProfileImage`, `authorBannerImage`, `authorJoined`, `authorIsPrivate`, `authorUrl` |
| **Engagement** | `likeCount`, `retweetCount`, `replyCount`, `viewCount`, `engagementTotal`, `engagementRate` |
| **Entities** | `hashtags`, `hashtagCount`, `mentions`, `mentionCount`, `externalLinks`, `hasLinks` |
| **Media** | `mediaType`, `mediaCount`, `mediaUrls`, `mediaThumbnails`, `hasMedia` |
| **Threading** | `inReplyToPostId`, `inReplyToUsername`, `quotedPostId`, `quotedText`, `quotedAuthor`, `quotedUrl` |
| **AI sentiment** | `sentiment`, `sentimentScore`, `sentimentConfidence`, `emotionalTone` |
| **Provenance** | `searchTerm`, `matchedBy`, `sortMode`, `scrapedAt` |

Export as **JSON, CSV, Excel, XML or RSS** — or pull straight from the Apify API.

***

### 🔌 Integrations & automation

This Actor plugs into your existing stack with no code:

- **🟠 Make (Integromat)** — schedule daily brand scans and route negative-sentiment posts into a "needs response" queue.
- **🟣 n8n** — run a workflow that collects posts, filters `sentiment = negative` and `authorFollowers > 10000`, then alerts your team.
- **🟡 Zapier** — push new posts into Google Sheets, Airtable or Notion automatically.
- **💬 Slack / Discord / Email** — get notified the moment a competitor or keyword spikes.
- **📊 Google Sheets / Looker Studio / Power BI** — build a live social sentiment dashboard.
- **🗄 Webhooks & API** — stream results into your own database or app.

Use Apify **Schedules** to run this hourly, daily or weekly and build a continuous social listening feed.

***

### ❓ FAQ

**Do I need an X (Twitter) account or API key?**
No. The Actor collects publicly available posts without any authentication from you.

**How many posts can I collect?**
The limit applies per search term and per handle, so 10 terms × 1,000 posts = up to 10,000 posts in one run. Large jobs are supported.

**Can I use advanced X search operators?**
Yes — search terms accept standard X search syntax, including `from:`, `OR`, quoted phrases, `min_faves:`, `filter:media` and more.

**What's the difference between Latest and Top?**
*Latest* returns the newest posts chronologically — best for monitoring. *Top* returns the highest-engagement posts — best for research and influencer discovery. *Latest + Top* runs both and removes duplicates.

**Is private or deleted content included?**
No. Only public posts are collected.

**Which languages does sentiment analysis support?**
Posts are graded in their original language across all supported languages.

**Is AI sentiment available on the free plan?**
No — AI sentiment analysis requires a paid Apify plan. If you enable it on the free plan, the run still completes normally and returns every post with all other fields; only the sentiment fields are left empty, and the log notes that sentiment is available only for paid plans. Everything else — search, handles, sorting, date and language filters, and the full dataset — works exactly the same on the free plan.

**Can I schedule it?**
Yes — use Apify Schedules for recurring runs, and webhooks to push results downstream.

***

### 🔗 You may also like

Round out your social listening and market intelligence stack:

- [**Reddit Scraper & AI Insights**](https://apify.com/lofomachines/reddit-ai-insights) — posts, comments and sentiment from any subreddit or keyword.
- [**Brand Monitoring AI**](https://apify.com/lofomachines/brand-monitoring-ai) — mentions, sentiment and reputation tracking across the web.
- [**LinkedIn Post Search Scraper**](https://apify.com/lofomachines/linkedin-post-search-scraper) — B2B conversations and professional audience signals.
- [**TikTok Search by Keywords**](https://apify.com/lofomachines/tiktok-search-by-keywords) — short-form video trends and creator discovery.
- [**AI Media Monitor**](https://apify.com/lofomachines/ai-media-monitor) — brand, news and sentiment tracking across media sources.

***

### ⚖️ Legal & fair use

This Actor collects **publicly available** information only. It does not access private accounts, protected posts, or any content behind a login. You are responsible for ensuring your use complies with applicable laws (including GDPR and other data protection regulations) and with the terms of any platform you interact with. Personal data should only be processed where you have a lawful basis to do so.

***

*Questions or a feature request? Open an issue on the Actor's Issues tab — feedback shapes the roadmap.*

# Actor input Schema

## `searchTerms` (type: `array`):

Keywords, phrases, hashtags or full X search queries — one per line. Each line runs as its own search. You can use plain words (<code>climate summit</code>), exact phrases (<code>"black friday"</code>), hashtags (<code>#Bitcoin</code>), or advanced operators (<code>tesla OR rivian</code>, <code>nike min\_faves:100</code>).

## `twitterHandles` (type: `array`):

Usernames whose posts you want to collect — one per line, with or without the <code>@</code>. Each handle returns that account's own posts.

## `maxItems` (type: `integer`):

How many posts to collect for each search term and each handle. A job with 3 terms and a limit of 100 returns up to 300 posts.

## `sortBy` (type: `string`):

<b>Latest</b> returns the most recent posts. <b>Top</b> returns the highest-engagement posts. <b>Latest + Top</b> combines both and removes duplicates for the widest coverage.

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

Only return posts written in this language. Leave as <b>Any language</b> to collect everything.

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

Only collect posts published on or after this date. Accepts a date (<code>2024-01-31</code>) or a relative value (<code>7 days</code>, <code>3 months</code>).

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

Only collect posts published before this date. Accepts a date (<code>2024-12-31</code>) or a relative value (<code>1 day</code>).

## `sentimentAnalysis` (type: `boolean`):

Tag every post as <b>positive</b>, <b>negative</b>, <b>neutral</b> or <b>mixed</b>, with a confidence score and the emotional tone. Adds a small amount of processing time.<br><br><b>Available on paid Apify plans only.</b> On the free plan this option is ignored, and posts are returned without sentiment fields — everything else works exactly the same.

## Actor input object example

```json
{
  "searchTerms": [
    "artificial intelligence",
    "#Bitcoin"
  ],
  "twitterHandles": [
    "elonmusk",
    "NASA"
  ],
  "maxItems": 100,
  "sortBy": "latest",
  "language": "any",
  "startDate": "2024-01-01",
  "endDate": "2024-12-31",
  "sentimentAnalysis": false
}
```

# Actor output Schema

## `overview` (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 = {
    "searchTerms": [
        "artificial intelligence",
        "#Bitcoin"
    ],
    "twitterHandles": [
        "elonmusk",
        "NASA"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("lofomachines/x-twitter-sentiment-analysis").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 = {
    "searchTerms": [
        "artificial intelligence",
        "#Bitcoin",
    ],
    "twitterHandles": [
        "elonmusk",
        "NASA",
    ],
}

# Run the Actor and wait for it to finish
run = client.actor("lofomachines/x-twitter-sentiment-analysis").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 '{
  "searchTerms": [
    "artificial intelligence",
    "#Bitcoin"
  ],
  "twitterHandles": [
    "elonmusk",
    "NASA"
  ]
}' |
apify call lofomachines/x-twitter-sentiment-analysis --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,lofomachines/x-twitter-sentiment-analysis"
        }
    }
}

```

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/TWspxBJuTD9DYTuwn/builds/hfXpedDbCJgXGsxq3/openapi.json
