# Sentiment Analysis API

> Sentiment Analysis evaluates the emotional tone of any text string. It returns an AFINN valence score, a comparative word-normalized score, and a five-tier sentiment label from very negative to very positive. Paid plans add sentence-level labels from a transformer model, a mixed-sentiment flag, magnitude, and the words that drove the score.

**Endpoint:** `POST https://api.apiverve.com/v1/sentimentanalysis`  
**Category:** AI/Computer Vision  
**Cost:** 10 credits per call  
**Canonical page:** https://apiverve.com/marketplace/sentimentanalysis

## Overview

A sentiment analysis API and text analysis API for reviews, tickets and social posts. Send any text and get back a sentiment score, a five-step label from very negative to very positive, and isPositive and isNegative flags you can route on without choosing thresholds yourself.

Every plan, including the free one, scores text against the AFINN word list. Each known word carries a value from -5 to +5, the values are added up, and a comparative score divides by the number of words so a one-line tweet and a long review can be compared fairly. It is fast and fully explainable, which suits dashboards, alerts and bulk tagging of customer feedback.

Paid plans add a transformer model that reads the text sentence by sentence. It returns its own label and a -1 to 1 score, flags mixed text where one sentence is clearly positive and another clearly negative, and lists the words that moved the score. That is where social media sentiment analysis and support triage gain the most: "Great app. Billing is broken." comes back as mixed instead of neutral.

## Authentication

Every call carries your key in an `x-api-key` header. The same key works across the whole
APIVerve catalog — there are no per-API subscriptions. Responses always use the same three
top-level keys: `status`, `error`, and `data`.

## Example request

```bash
curl -X POST "https://api.apiverve.com/v1/sentimentanalysis" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text":"I'\''m so excited that tomorrow is going to be sunny! Can'\''t wait!"}'
```

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `text` | string | Yes | The text to analyze the sentiment of. length 0-50000 |

## Response fields

- `comparative` — number · The sentiment score divided by the number of words, so long and short texts compare
- `sentimentText` — string · The score read as a label: very positive, positive, neutral, negative or very negative
- `sentiment` — number · AFINN sentiment score: the summed valence of the matched words, negative for negative sentiment
- `isPositive` — boolean · Whether the sentiment is positive
- `isNegative` — boolean · Whether the sentiment is negative
- `normalizedScore` — number · Sentiment score normalized to -1 to 1 range · (premium)
- `magnitude` — number · Total emotional strength: the summed absolute valence of every matched word, so strongly mixed text scores high even when sentiment nets to zero · (premium)
- `positiveWords` — array · The distinct words that pushed the AFINN score up · (premium)
- `negativeWords` — array · The distinct words that pulled the AFINN score down, including positive words negated by not or never · (premium)
- `modelSentiment` — string · Overall label from a transformer sentiment model read sentence by sentence: positive, neutral, negative, or mixed when the text has a confident positive and a confident negative sentence; null if the model is unavailable · (premium)
- `modelScore` — number · Model score from -1 (negative) to 1 (positive): the mean positive minus the mean negative probability across sentences · (premium)
- `isMixed` — boolean · True when at least one sentence is confidently positive and another confidently negative (model confidence 0.6 or higher) · (premium)
  - `sentences.0.text` — string · The sentence as split from the input · (premium)
  - `sentences.0.label` — string · positive, neutral or negative · (premium)
  - `sentences.0.confidence` — number · Model probability of the label, 0 to 1 · (premium)
  - `sentences.0.scores` — object · Probability of each label · (premium)
    - `sentences.0.scores.positive` — number · Probability the sentence is positive · (premium)
    - `sentences.0.scores.neutral` — number · Probability the sentence is neutral · (premium)
    - `sentences.0.scores.negative` — number · Probability the sentence is negative · (premium)

## Sample response

```json
{
  "status": "ok",
  "error": null,
  "data": {
    "comparative": 0.25,
    "sentimentText": "positive",
    "sentiment": 3,
    "isPositive": true,
    "isNegative": false,
    "normalizedScore": 0.3,
    "magnitude": 3,
    "positiveWords": [
      "excited"
    ],
    "negativeWords": [],
    "modelSentiment": "positive",
    "modelScore": 0.98,
    "isMixed": false,
    "sentences": [
      {
        "text": "I'm so excited that tomorrow is going to be sunny!",
        "label": "positive",
        "confidence": 0.992,
        "scores": {
          "positive": 0.992,
          "neutral": 0.006,
          "negative": 0.002
        }
      },
      {
        "text": "Can't wait!",
        "label": "positive",
        "confidence": 0.973,
        "scores": {
          "positive": 0.973,
          "neutral": 0.024,
          "negative": 0.003
        }
      }
    ]
  }
}
```

## Use cases

- **Support Ticket Escalation** — Route angry customer messages to senior support reps immediately when the sentiment score drops to very negative.
- **Review Stream Filtering** — Product managers categorize incoming app store feedback into positive praise and negative complaints using the five-tier sentiment label.
- **Social Media Sentiment Analysis** — When tracking brand tags on social networks, marketing teams flag sudden spikes in negative valence scores to address PR issues early.
- **Survey Response Sorting** — Sort open-ended employee survey responses automatically by comparative sentiment to isolate recurring workplace grievances without manual reading.

## SDKs

- **npm** — `npm install @apiverve/sentimentanalysis` (https://www.npmjs.com/package/@apiverve/sentimentanalysis)
- **PyPI** — `pip install apiverve-sentimentanalysis` (https://pypi.org/project/apiverve-sentimentanalysis/)
- **NuGet** — `dotnet add package APIVerve.API.SentimentAnalysis` (https://www.nuget.org/packages/APIVerve.API.SentimentAnalysis)
- **Source** — https://github.com/apiverve/sentimentanalysis-api

## More

- Full reference: https://docs.apiverve.com/ref/sentimentanalysis
- Get an API key: https://dashboard.apiverve.com
- Full catalog: https://apiverve.com/marketplace
