# Review Sentiment Analysis - Positive or Negative, No API Key (`northbell/review-sentiment`) Actor

Score the sentiment of reviews, comments and survey answers in many languages with a model that runs inside the Actor. No API key, no external AI service. Runs straight after a review scraper.

- **URL**: https://apify.com/northbell/review-sentiment.md
- **Developed by:** [Northbell](https://apify.com/northbell) (community)
- **Categories:** AI, Developer tools
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.40 / 1,000 texts

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

## Review Sentiment Analysis - Positive or Negative, No API Key

**Score the sentiment of reviews, comments and survey answers: positive, neutral or negative, with a score from -1 to 1.** The model runs inside the Actor. No OpenAI or other AI key, no account, no external service: your texts never leave the run. Built to run right after a review or comment scraper.

**Try it now - the input is already filled in.** Press **Start**. It scores six made-up reviews in English, Spanish and Japanese. In our own local run: all six came back on the expected side (3 positive, 2 negative, and the Spanish "late delivery but it works" review as neutral, score 0.03), in about 4 seconds including loading the model. Cost: 6 texts = **$0.003** (plus $0.00005 for the run start).

Speed: a synthetic run of 2,000 English reviews (30 to 130 words each) took 119 seconds on our test PC (about 17 texts per second) and peaked at 745 MB of memory. On Apify, expect the same order of speed, depending on the CPU you get. 2,000 texts cost $1.00.

### What you pay

| Event | Price | When |
| --- | --- | --- |
| `text-scored` | $0.0005 | per scored text ($0.50 per 1,000) |
| `apify-actor-start` | $0.00005 | once per run |

- You are charged for a batch of texts only after its rows are saved in the dataset. Empty texts, rows without text and texts skipped by "Only new texts" are free.
- Set "Maximum total charge" on the run as your cap. The Actor checks it before scoring each batch and stops cleanly when the next batch does not fit.

### What you get

One dataset row per text:

```json
{ "id": "r-1042", "url": "https://example.com/reviews/1042", "rating": 2,
  "status": "ok", "sentiment": "negative", "score": -0.87, "confidence": 0.93, "language": "en" }
```

- `sentiment`: `positive`, `neutral` or `negative`.
- `score`: from -1 (very negative) to 1 (very positive).
- `confidence`: how much of the model's probability sits on the chosen side (0 to 1). Low values (below about 0.6) mean mixed or unclear text.
- `language`: detected language code (`en`, `es`, `ja`...), or null when the text is too short to tell.
- `status`: `ok`, or `skipped` (empty text, or already scored) with a `reason`. Skipped rows are free.
- The fields you list in `keepFields` are copied from the source row (default `url`, `id`, `rating`), so you can join the results back to the reviews. With plain `texts` input the row has `index` instead.
- **The text itself is not in the result** unless you turn on `includeText`. Nothing else of the source row is copied, and the Actor never writes your texts to the log.

The run's **OUTPUT** record (key-value store) holds the summary: counts of positive, neutral and negative, the average score, and the same per value of `groupBy` (for example per product or per place):

```json
{ "scored": 2000, "overall": { "count": 2000, "positive": 936, "neutral": 342, "negative": 722, "averageScore": 0.119 },
  "groups": { "P0": { "count": 667, "positive": 304, "neutral": 125, "negative": 238, "averageScore": 0.111 } } }
```

### Run it after your review scraper

1. In Apify Console, open the scraper Actor and go to **Integrations**.
2. Add **Run Actor** (on "Run succeeded") and pick this Actor.
3. Use an input like this, with the name of the field that holds the review text:

```json
{
  "datasetId": "{{resource.defaultDatasetId}}",
  "textField": "text",
  "keepFields": ["url", "id", "rating"],
  "groupBy": "placeName",
  "onlyNew": true
}
```

A dotted path such as `review.body` reaches into nested fields. Rows without text are skipped, free.

### Run it on a schedule with only new reviews

Turn on `onlyNew` and schedule the run. The Actor keeps a list of what it has scored in a key-value store named `review-sentiment-seen` in your account: only a short hash of each text (lower-cased), never the text. Texts already scored come back as `skipped` rows and are not charged. Texts that were not processed (over `maxItems`, or stopped at a charge limit) are not marked as done, so the next run picks them up. If the store cannot be opened, the run stops before charging anything.

### Input

| Input | Default | What it does |
| --- | --- | --- |
| `texts` | six made-up reviews | texts to score, one per line |
| `datasetId`, `textField` | none, `text` | read texts from another Actor's dataset (dotted path allowed) |
| `keepFields` | `url`, `id`, `rating` | fields copied from the source row |
| `groupBy` | none | field to summarise by in the OUTPUT record (up to 1,000 values) |
| `includeText` | off | also put the text in the result rows |
| `onlyNew` | off | skip texts scored in an earlier run |
| `maxItems` | 50,000 | cap on scored texts per run |

Texts are cut at 512 tokens (roughly the first 300 to 400 words). Long reviews are scored on their opening.

### The model

- **Model:** `Xenova/bert-base-multilingual-uncased-sentiment`, revision `fad9b372f770c208d2efaf00d02f2cb3b61ec450`, the 8-bit quantized ONNX file (`onnx/model_quantized.onnx`), run with transformers.js (`@huggingface/transformers`) on the CPU. It is the ONNX conversion of `nlptown/bert-base-multilingual-uncased-sentiment` (revision `8f6f4e3a8f70be4b65d3a4a8762b6d781cda240d`).
- **Licence:** MIT. The model card of the original, nlptown/bert-base-multilingual-uncased-sentiment, states `license: mit`. The ONNX repository card itself names that model as its base and states no licence of its own.
- **Inside the image:** the files are downloaded once when the Actor is built. A run never contacts the model host (remote models are switched off).
- It predicts 1 to 5 stars. The Actor turns the five probabilities into a score (1 star = -1, 2 = -0.5, 3 = 0, 4 = 0.5, 5 = 1, weighted by probability). Below -0.25 is `negative`, above 0.25 is `positive`, in between `neutral`.
- Language detection uses `tinyld` (MIT).

#### NOTICE

This Actor contains the model `nlptown/bert-base-multilingual-uncased-sentiment` (MIT licence, NLP Town), converted to ONNX by Xenova, and runs it with transformers.js (Apache-2.0). Language detection: tinyld (MIT). The MIT licence permits use, copying, modification and distribution of the software, provided the copyright notice and permission notice are included; the software is provided "as is", without warranty of any kind.

### Languages

The model was fine-tuned on product reviews in English, Dutch, German, French, Italian and Spanish. It is built on multilingual BERT, which knows many more languages, so Portuguese, Japanese and others work but are less reliable than those six. We tested clear positive and negative sentences in English, Spanish and Japanese (all got the expected side). Subtle Japanese text is the weak spot: in an early trial, a mildly negative Japanese review about slow delivery came back positive. Check a sample in your language first.

### Limits

- **A model, not a human: check samples.** Read 30 to 50 results in your own data before you rely on the numbers. Sarcasm, mixed reviews ("late but works"), very short texts and domain slang are where it goes wrong.
- Trained on product reviews. Tweets, news, legal text and support tickets may score less well.
- Scores can move by a few hundredths between runs, because the 8-bit model's arithmetic depends slightly on which texts share a batch. Labels near the +-0.25 lines can flip.
- Neutral is the 3-star middle: a review that is half good and half bad often lands there.
- Language detection is a guess on very short texts.
- Speed is roughly 17 texts per second on our test PC; 100,000 texts is about 1.6 hours. Raise the run timeout for big datasets; the Actor stops cleanly shortly before the time limit.

# Actor input Schema

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

Reviews, comments or survey answers, one per line. Or leave empty and give a Dataset ID. The six examples are made up.

## `datasetId` (type: `string`):

Read the texts from this Apify dataset (for example the dataset of a review scraper run). Use {{resource.defaultDatasetId}} when you connect this Actor as an integration after another Actor.

## `textField` (type: `string`):

Name of the field that holds the text. A dotted path works (review.body). Rows without text are skipped for free.

## `keepFields` (type: `array`):

Fields of the source row that are copied to the result row so you can match results to reviews. Dotted paths work. Nothing else of the source row is copied.

## `groupBy` (type: `string`):

Optional. A field of the dataset rows (for example product or placeName). The OUTPUT record of the run then shows the counts and the average score per value.

## `includeText` (type: `boolean`):

Off by default: result rows carry only the kept fields and the scores, never the text itself.

## `onlyNew` (type: `boolean`):

Skip texts this Actor already scored in an earlier run (kept as hashes in a key-value store named review-sentiment-seen in your account). Use it for scheduled runs. Skipped texts are free.

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

Cap on scored texts per run. Texts over the cap are left for the next run.

## Actor input object example

```json
{
  "texts": [
    "The blender is fantastic. Quiet, powerful and easy to clean. Best purchase this year!",
    "Terrible. It broke after two days and support never answered my emails.",
    "La entrega llegó tarde y la caja estaba rota, pero el producto funciona bien.",
    "Una experiencia horrible, el camarero fue grosero y la comida estaba fría.",
    "このお店の料理は本当においしくて、スタッフもとても親切でした。また来たいです。",
    "最悪です。ひどい品質で、二度と買いません。"
  ],
  "textField": "text",
  "keepFields": [
    "url",
    "id",
    "rating"
  ],
  "includeText": false,
  "onlyNew": false,
  "maxItems": 50000
}
```

# Actor output Schema

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

Sentiment, score, confidence and language for each text.

## `summary` (type: `string`):

Counts and average score, overall and per group.

# 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": [
        "The blender is fantastic. Quiet, powerful and easy to clean. Best purchase this year!",
        "Terrible. It broke after two days and support never answered my emails.",
        "La entrega llegó tarde y la caja estaba rota, pero el producto funciona bien.",
        "Una experiencia horrible, el camarero fue grosero y la comida estaba fría.",
        "このお店の料理は本当においしくて、スタッフもとても親切でした。また来たいです。",
        "最悪です。ひどい品質で、二度と買いません。"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("northbell/review-sentiment").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": [
        "The blender is fantastic. Quiet, powerful and easy to clean. Best purchase this year!",
        "Terrible. It broke after two days and support never answered my emails.",
        "La entrega llegó tarde y la caja estaba rota, pero el producto funciona bien.",
        "Una experiencia horrible, el camarero fue grosero y la comida estaba fría.",
        "このお店の料理は本当においしくて、スタッフもとても親切でした。また来たいです。",
        "最悪です。ひどい品質で、二度と買いません。",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("northbell/review-sentiment").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": [
    "The blender is fantastic. Quiet, powerful and easy to clean. Best purchase this year!",
    "Terrible. It broke after two days and support never answered my emails.",
    "La entrega llegó tarde y la caja estaba rota, pero el producto funciona bien.",
    "Una experiencia horrible, el camarero fue grosero y la comida estaba fría.",
    "このお店の料理は本当においしくて、スタッフもとても親切でした。また来たいです。",
    "最悪です。ひどい品質で、二度と買いません。"
  ]
}' |
apify call northbell/review-sentiment --silent --output-dataset

```

## MCP server setup

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

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/KCuvkt28DE8eREw5r/builds/Ta6axDkIpMj0kwyvZ/openapi.json
