Sentiment Analysis

Detect positive, negative or neutral sentiment with polarity score and star rating

You send one text and the service classifies its sentiment polarity (positive, negative, or neutral). Returns a label, confidence score, polarity (-1 to +1), a star rating string ("1 stars" through "5 stars"), an is_positive boolean, and the auto-detected language. Synchronous.

textanalysisnlp

Overview

Features

Sentiment polarity

positive / negative / neutral label with confidence score (0-1).

Polarity score

Continuous polarity from -1 (very negative) to +1 (very positive).

Star rating

1-5 star interpretation as a string (e.g. "5 stars").

Auto language detect

The detected language is included in the result.

Use Cases

Review analysis

Classify customer reviews by sentiment for dashboards and alerts.

Social listening

Monitor mentions and comments for positive/negative trends.

Triage

Flag negative messages in support queues for fast response.

Input / Output

Input

texts: array (in practice 1 element — see Important Notes)

JSON body

Output

results[0] with label, score, stars, is_positive, polarity, language

JSON

Specs

Latency
~0.5-2 s
Async
false
Rate Limit
Per API key
Max Input
Model-dependent (typically a few thousand characters)

Quickstart

Prerequisites

  • -A CN8 Gateway API key with text-sentiment in allowed_services

1. Analyze sentiment

text-sentiment

POST a single-element texts array. The service returns one result with label, score, stars, is_positive, polarity and language.

POST/v1/proxy/text-sentiment
{
  "texts": ["The product arrived quickly and works great!"]
}

Response

{
  "status": "success",
  "data": {
    "results": [
      {
        "label": "positive",
        "score": 0.9366,
        "stars": "5 stars",
        "is_positive": true,
        "polarity": 1.0,
        "language": "en",
        "scores": null
      }
    ]
  }
}

Field name is texts (plural), not text. Body must be a JSON array even for a single text.

Sentiment Analysis

POSTsync

Detect positive/negative/neutral sentiment with polarity, star rating and confidence. Auto-detects language.

/v1/proxy/text-sentiment

Pricing

Billed per request.

ServiceUnitPrice
Sentiment Analysisitem$0.002/request

Guides & Tips

Important Notes (verified against the live upstream)

  • -Field name is `texts` (plural). The legacy `text` field returns 400.
  • -Send exactly 1 text per request. Sending 2+ items in `texts` triggers an upstream
  • -bug: `"invalid literal for int() with base 10: 'p'"`. The gateway does not bill the
  • -failure but the call returns status=error.
  • -`aspects`, `return_scores`, `language` and similar flags are silently ignored — the
  • -upstream does not implement aspect-based sentiment via this endpoint, despite older
  • -documentation. The `scores` field in the result is always null.
  • -Cost is per request, not per text (the second point makes this academic, but this
  • -is the rule for any future multi-text fix).

How it works

  • -The text is classified into positive / negative / neutral by a sentiment classification
  • -model. Polarity (-1 to +1) is a continuous reading; stars maps that polarity to a
  • -1-5 string label.

FAQ

Q: Why does my call fail with 'invalid literal for int()'?

A: You sent more than one text in the texts array. Reduce to a single element until the upstream is fixed.

Q: Is aspect-based sentiment supported?

A: Not currently. The aspects field is accepted but ignored by the upstream.

Q: What is the polarity score?

A: A continuous value from -1 (most negative) to +1 (most positive). 0 is neutral.

Related Products

Changelog

1.2 (2026-04-29)

  • -Aligned to live upstream: request body is texts (array), response is data.results[].
  • -Removed aspects support — confirmed silently ignored by the upstream.
  • -Documented the multi-text upstream bug (only 1 text per call works today).
  • -Documented actual response fields: stars (string), is_positive (bool), language (auto-detected), scores (always null).

1.1 (2026-02-23)

  • -Aligned with sentiment_analyzer prose (now superseded by 1.2).

1.0 (2026-01-26)

  • -Initial catalog.