# Text Sentiment Analysis (`maximedupre/text-sentiment-analysis`) Actor

Classify one line or a full text block as positive, negative, or neutral. Get a confidence score for every line plus line counts and sentiment shares in a structured dataset.

- **URL**: https://apify.com/maximedupre/text-sentiment-analysis.md
- **Developed by:** [Maxime Dupré](https://apify.com/maximedupre) (community)
- **Categories:** AI, Developer tools, Marketing
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$2.65 / 1,000 sentiment labels

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/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

### 📊 Turn text into sentiment signals

For developers, support teams, researchers, and analysts, Text Sentiment Analysis works as sentiment analysis software for text you submit. It returns a structured dataset with a positive, negative, or neutral label and confidence value for each line, plus the line count and sentiment shares, so you can review text in a machine-readable form.

- Review pasted support comments with [**Customer Feedback Sentiment Analysis**](https://apify.com/maximedupre/text-sentiment-analysis/examples/customer-feedback-sentiment-analysis).
- Paste social posts to run [**Twitter Sentiment Analysis**](https://apify.com/maximedupre/text-sentiment-analysis/examples/twitter-sentiment-analysis).
- Try the [**Sentiment Analysis Example**](https://apify.com/maximedupre/text-sentiment-analysis/examples/sentiment-analysis-example) with a short sample.
- Use a [**Text Analysis Tool**](https://apify.com/maximedupre/text-sentiment-analysis/examples/text-analysis-tool) to label each line in a text block.
- Open [**Sentiment Analysis Tools**](https://apify.com/maximedupre/text-sentiment-analysis/examples/sentiment-analysis-tools) to compare positive, negative, and neutral shares from one run.

#### 🧾 Line-level sentiment reports

**What each run returns**

The dataset contains one report for the submitted text. It shows the number of lines, the count and share for each sentiment, and the original text, label, and confidence value for every line.

**Sentiment labels**

Each line is labeled `positive`, `negative`, or `neutral`. Confidence is a number from `0` to `1` for that line's label. The distribution uses the same three labels and gives both counts and shares.

#### ▶️ Analyze one line or a text block

**Run steps**

1. Put one line or a block of text in the `text` input.
2. Start the Actor in Apify Console or through the standard Actor API.
3. Open the dataset to review the line labels, confidence values, and summary.

The Actor analyzes the text you submit. It does not fetch tweets, reviews, web pages, or other outside text for you.

#### ⚙️ Input

**Input fields**

| Field | Type | What it does |
|---|---|---|
| `text` | string | Required. Accepts one line or a block of text. Each line is labeled positive, negative, or neutral. |

**Example input**

This is the public input from the successful default-input beta run:

```json
{
  "text": "I love the fast delivery.\nThe packaging was damaged.\nThe meeting is scheduled for noon."
}
```

#### 🧾 Output

**Output shape: sentiment report**

Each successful dataset row has this shape:

| Field | Type | What it does |
|---|---|---|
| `lineCount` | integer | Number of text lines analyzed. |
| `sentimentDistribution` | object | Counts and shares for positive, negative, and neutral lines. |
| `sentimentDistribution.positive` | object | Count and share for positive lines. |
| `sentimentDistribution.positive.count` | integer | Number of positive lines. |
| `sentimentDistribution.positive.share` | number | Share of lines labeled positive, from `0` to `1`. |
| `sentimentDistribution.negative` | object | Count and share for negative lines. |
| `sentimentDistribution.negative.count` | integer | Number of negative lines. |
| `sentimentDistribution.negative.share` | number | Share of lines labeled negative, from `0` to `1`. |
| `sentimentDistribution.neutral` | object | Count and share for neutral lines. |
| `sentimentDistribution.neutral.count` | integer | Number of neutral lines. |
| `sentimentDistribution.neutral.share` | number | Share of lines labeled neutral, from `0` to `1`. |
| `lines` | object\[] | One line-level assessment for each analyzed line, in input order. |
| `lines[].lineNumber` | integer | 1-based position of the line in the input. |
| `lines[].text` | string | Original text for the line. |
| `lines[].sentiment` | string | Sentiment label: `positive`, `negative`, or `neutral`. |
| `lines[].confidence` | number | Confidence value for the label, from `0` to `1`. |

**Example row**

This genuine row is from a successful run on the current beta build:

```json
{
  "lineCount": 3,
  "sentimentDistribution": {
    "positive": {
      "count": 1,
      "share": 0.3333333333333333
    },
    "negative": {
      "count": 1,
      "share": 0.3333333333333333
    },
    "neutral": {
      "count": 1,
      "share": 0.3333333333333333
    }
  },
  "lines": [
    {
      "lineNumber": 1,
      "text": "I love the fast delivery.",
      "sentiment": "positive",
      "confidence": 0.99
    },
    {
      "lineNumber": 2,
      "text": "The packaging was damaged.",
      "sentiment": "negative",
      "confidence": 0.8625
    },
    {
      "lineNumber": 3,
      "text": "The meeting is scheduled for noon.",
      "sentiment": "neutral",
      "confidence": 0.55
    }
  ]
}
```

#### 💳 Pricing

**How charges work**

The primary event is `Sentiment label` at $0.00265 for one successful sentiment label and confidence value saved for a submitted text line. A multiline run can create one such event for each classified line.

#### 🔌 Integrations

**Use the results**

Start runs in Apify Console or call the Actor through the standard Apify API. Read the machine-readable dataset in your app, script, or text review workflow.

https://www.youtube.com/watch?v=bNACk1\_S\_6w\&list=PLObrtcm1Kw6MUrlLNDbK9QRg8VDJg0gOW\&index=4

#### ❓ FAQ

##### Can I analyze one line and a multiline block?

Yes. Put either one line or a text block in `text`. The output keeps the line order and adds one assessment for each analyzed line.

##### Does the Actor fetch Twitter posts or customer reviews?

No. It analyzes only the text you submit. Paste tweet text, feedback, or review text when you want a Twitter sentiment analysis or customer feedback check.

##### What does sentiment analysis mean in the output?

Each line gets one of three labels: `positive`, `negative`, or `neutral`. The row also includes a confidence value, line count, and the share of each label.

##### How should I read the confidence value?

It is a number from `0` to `1` returned with the line's label. It describes the Actor's confidence value for that assessment; it is not a promise that the label is always correct.

##### Can I run sentiment analysis from Python or another app?

Yes. Start the Actor through the standard Apify API and read its dataset from your Python workflow, script, or another application.

##### Does it use VADER sentiment analysis, BERT, or a named provider?

The public contract does not name VADER, BERT, or a third-party sentiment API. It promises the three labels, line-level confidence values, and aggregate counts and shares, so do not assume a specific model or provider.

### 📝 Changelog

**0.0: Initial release**

### 🆘 Support

For issues, questions, or feature requests, [file a ticket](https://console.apify.com/actors/maximedupre~text-sentiment-analysis/issues) and I'll fix or implement it in less than 24h 🫡

### 🔗 Related Actors

- [Twitter (X) Scraper](https://apify.com/maximedupre/twitter-scraper) — collect public posts and then submit their text for sentiment analysis.
- [Facebook Reviews Scraper](https://apify.com/maximedupre/facebook-reviews-scraper) — collect public Page recommendations before analyzing their tone.
- [Reddit Scraper](https://apify.com/maximedupre/reddit-scraper) — collect public posts or comments for a sentiment workflow.
- [Webpage Text Extractor](https://apify.com/maximedupre/webpage-text-extractor) — extract public page text before sending it to this Actor.
- [Readability Analyzer](https://apify.com/maximedupre/readability-analyzer) — check reading difficulty alongside sentiment.

**Made with ❤️ by Maxime Dupré**

# Actor input Schema

## `text` (type: `string`):

Enter one line or a block of text. Each line is classified as positive, negative, or neutral.

## Actor input object example

```json
{
  "text": "The support team solved my issue quickly.\nThe wait time was too long."
}
```

# Actor output Schema

## `dataset` (type: `string`):

The analyzed lines and their sentiment summary.

# 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 = {
    "text": `I love the fast delivery.
The packaging was damaged.
The meeting is scheduled for noon.`
};

// Run the Actor and wait for it to finish
const run = await client.actor("maximedupre/text-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 = { "text": """I love the fast delivery.
The packaging was damaged.
The meeting is scheduled for noon.""" }

# Run the Actor and wait for it to finish
run = client.actor("maximedupre/text-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 '{
  "text": "I love the fast delivery.\\nThe packaging was damaged.\\nThe meeting is scheduled for noon."
}' |
apify call maximedupre/text-sentiment-analysis --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,maximedupre/text-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/yzqFD2RpYLQjbSi8x/builds/8IEhwRwPz9rJvJAsA/openapi.json
