# Sentiment Analysis Using Jev (`confidential_gnat/sentiment-analysis`) Actor

Classifies the sentiment of your texts as positive, negative, neutral or mixed, or into your own custom labels such as good, bad or urgent, and returns a confidence score for every text.

- **URL**: https://apify.com/confidential_gnat/sentiment-analysis.md
- **Developed by:** [ActorFlow](https://apify.com/confidential_gnat) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.08 / 1,000 results

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

## Sentiment Analysis — Classify Text as Positive, Negative or Your Own Custom Labels

**Run sentiment analysis on any list of texts** — reviews, comments, survey answers, tweets or support tickets. Each text is classified as **positive, negative, neutral or mixed**, or into **your own custom labels** such as good, bad or urgent, with a confidence score for every label. Results export as **JSON, CSV or Excel** and the actor can be called as an **API**. Classification is powered by **JEV**, a fast AI classification model. Paste your texts, press Start.

### ✨ Features of this sentiment analysis actor

- **JEV-powered sentiment classification** — texts are classified by the JEV model, and every text gets one label plus a confidence score and the score of each label
- **Custom sentiment labels** — define your own classes (up to 10), for example `good`, `bad`, `urgent` or `question`
- **Default labels** — leave the labels empty to use positive, negative, neutral and mixed
- **Batch processing** — classify up to 100 texts in one run
- **No scraping or proxy needed** — you supply the text, runs are fast and cheap

### 🚀 How to run sentiment analysis in 5 steps

1. [Sign up](https://apify.com/sign-up) for a free Apify account — includes **$5 monthly credit**.
2. Open the actor page and click **Try for free**.
3. Add your texts to the **Texts** field, one per line.
4. Optionally add your own **Custom sentiment labels**.
5. Click **Start** and download the results from the **Output** tab in JSON, CSV, or Excel format.

You can also run this actor via the [Apify API](https://docs.apify.com/api/v2) or integrate it directly into your workflows using [Zapier](https://zapier.com/apps/apify), [Make](https://www.make.com/), or [n8n](https://n8n.io/).

### 💰 Pricing

This actor uses **pay-per-result** billing: you pay for each classified text.

- New Apify accounts include **$5 of free monthly credit**.
- There is no browser, proxy or scraping involved, so runs cost very little.

### 🔧 Input configuration

| Field                                  | Type  | Required | Default                            | Description                                                                                                 |
| -------------------------------------- | ----- | -------- | ---------------------------------- | ----------------------------------------------------------------------------------------------------------- |
| Texts (`texts`)                        | array | ✅       | 3 example texts                    | The texts to classify. Up to **100 texts** per run; each text is cut to its first **2,000 characters**.     |
| Custom sentiment labels (`sentiments`) | array | —        | positive, negative, neutral, mixed | Your own labels. Up to **10 labels** of up to **50 characters**. Duplicates are ignored (case-insensitive). |

**Tip for custom labels:** use clear, distinct labels. `urgent complaint` and `happy feedback` separate better than overlapping words like `bad` and `urgent`.

### 📦 Sentiment analysis output data

The output is a dataset with one record per text and these fields: `text`, `sentiment`, `confidence` and `scores`. `scores` holds the probability of every label, so you can spot borderline texts. The dataset has 1 view, **Overview**, a compact table of text, sentiment and confidence. If a text could not be classified, `sentiment` and `confidence` are `null`.

**Sample output:**

```json
[
    {
        "text": "Great screen but the battery is awful.",
        "sentiment": "mixed",
        "confidence": 1,
        "scores": { "negative": 0, "neutral": 0, "mixed": 1, "positive": 0 }
    },
    {
        "text": "What time do you open on Sunday?",
        "sentiment": "question",
        "confidence": 1,
        "scores": { "question": 1, "good": 0, "bad": 0, "urgent": 0 }
    }
]
```

### 🐍 How to run sentiment analysis with Python, JavaScript or the API

Run the actor programmatically with the official Apify clients. Replace `<YOUR_API_TOKEN>` with the token from your [Apify Console](https://console.apify.com/account/integrations).

**Python** (`pip install apify-client`):

```python
from apify_client import ApifyClient

client = ApifyClient("<YOUR_API_TOKEN>")

run = client.actor("<username>/sentiment-analysis").call(run_input={
    "texts": ["I love this product!", "Terrible support, nobody replied."],
    "sentiments": ["happy", "unhappy"],
})

for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item["text"], item["sentiment"], item["confidence"])
```

**JavaScript** (`npm install apify-client`):

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

const client = new ApifyClient({ token: '<YOUR_API_TOKEN>' });

const run = await client.actor('<username>/sentiment-analysis').call({
    texts: ['I love this product!', 'Terrible support, nobody replied.'],
    sentiments: ['happy', 'unhappy'],
});

const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);
```

**cURL** — start a run and wait for the dataset:

```bash
curl -X POST "https://api.apify.com/v2/acts/<username>~sentiment-analysis/run-sync-get-dataset-items?token=<YOUR_API_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{"texts": ["I love this product!", "Terrible support, nobody replied."]}'
```

### 💡 What you can use sentiment analysis data for

- Sorting customer reviews and survey answers into happy and unhappy groups
- Triaging support tickets with custom labels such as urgent, question or complaint
- Measuring public opinion in social media posts, comments and news headlines
- Tagging feedback by theme with your own label set
- Adding a sentiment column to data scraped with other actors

Typical users are product, support, marketing and research teams in e-commerce, SaaS, media and market research.

### ⚠️ Limitations & known issues

- **100 texts per run** — extra texts are skipped, and a warning is logged.
- **2,000 characters per text** — longer texts are cut, so the opening of the text decides the label.
- **JEV model** — results come from the JEV classifier, which is most reliable on clear opinions and weaker on sarcasm.
- **One label per text** — each text gets its single best label, so use the `scores` field to see runner-up labels.
- **Short labels can be ambiguous** — descriptive labels give more accurate results.

### ❓ Frequently asked questions

#### How does this sentiment analysis actor work?

You provide texts, and the **JEV** model picks the best-fitting label for each one and reports a confidence score and a score for every label.

#### Can I use my own sentiment labels instead of positive and negative?

Yes. Add up to 10 labels such as `good`, `bad`, `urgent` or `question` in **Custom sentiment labels**. They fully replace the defaults for that run.

#### How many texts can I analyze in one run?

Up to 100 texts, each up to 2,000 characters. For larger datasets, split them across several runs or call the actor from the API in a loop.

#### How accurate is the sentiment classification?

It is accurate on clear opinions and weaker on sarcasm or very short, context-free text. Check `confidence` and `scores` and review low-confidence rows.

#### What languages are supported?

The classifier handles many major languages, though results are most reliable for English. Test a small sample in your language first.

#### How do I run sentiment analysis with Python?

Use the Apify client shown above: call the actor with a list of texts and iterate over the dataset items.

#### What output formats are supported?

JSON, CSV, Excel, XML and RSS, either from the **Output** tab or through the Apify API.

### 🔗 Other actors you may find useful

| Actor                                                                                                   | Description                                                                                |
| ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ |
| [✍️ Substack Scraper](https://apify.com/confidential_gnat/substack-newsletter-scraper)                  | Scrapes Substack posts and comments with free sentiment and AI summaries.                  |
| [⭐ Google Play Store Reviews Scraper](https://apify.com/confidential_gnat/google-play-reviews-scraper) | Scrapes user reviews from Google Play apps, including review text, star rating and author. |
| [🎬 YouTube Video List Scraper](https://apify.com/confidential_gnat/youtube-video-list-scraper)         | Scrapes video listings from YouTube channels and playlists.                                |
| [🗞️ Google News AI Scraper](https://apify.com/confidential_gnat/google-news-ai-scraper)                 | Searches Google News by keyword with optional full article text and AI summaries.          |

### 💬 Support & contact

If you encounter any issues or have questions, please [open an issue](https://apify.com/confidential_gnat/sentiment-analysis/issues/open) or reach out via the [Apify Community Forum](https://community.apify.com/).

You can also find more of our actors on the [Actor Flow](https://apify.com/confidential_gnat) page.

# Actor input Schema

## `texts` (type: `array`):

The texts to classify, one per line. Up to 100 texts per run; each text is cut to its first 2,000 characters.

## `sentiments` (type: `array`):

Optional. Your own labels to classify into, for example good, bad, urgent. Up to 10 labels of up to 50 characters. Leave empty to use positive, negative, neutral and mixed.

## Actor input object example

```json
{
  "texts": [
    "I love this product, it works perfectly and arrived early!",
    "Terrible support. I waited two weeks and nobody replied.",
    "The package arrived on Tuesday."
  ]
}
```

# 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 = {
    "texts": [
        "I love this product, it works perfectly and arrived early!",
        "Terrible support. I waited two weeks and nobody replied.",
        "The package arrived on Tuesday."
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("confidential_gnat/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 = { "texts": [
        "I love this product, it works perfectly and arrived early!",
        "Terrible support. I waited two weeks and nobody replied.",
        "The package arrived on Tuesday.",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("confidential_gnat/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 '{
  "texts": [
    "I love this product, it works perfectly and arrived early!",
    "Terrible support. I waited two weeks and nobody replied.",
    "The package arrived on Tuesday."
  ]
}' |
apify call confidential_gnat/sentiment-analysis --silent --output-dataset

```

## MCP server setup

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