Sentiment of a text (overall and per sentence)

Scores how positive or negative the text is. Returns an overall label and compound score (-1 to 1), the positive/neutral/negative breakdown, and a score for every sentence.

Request

POSThttps://text-analysis.p.apihiver.com/v1/sentiment

JSON object. Required: text.

Request Body

Edit the values below to test different scenarios.

Parameters and body structure are inherited from this endpoint's definition. Changes here only apply to this test run.

Language
Client
1curl --request POST \
2  --url https://text-analysis.p.apihiver.com/v1/sentiment \
3  --header 'Accept: application/json' \
4  --header 'Content-Type: application/json' \
5  --header 'X-API-Key: YOUR_API_KEY' \
6  --data '{
7  "text": "I love this product, it is great!"
8}'

Sentiment of a text (overall and per sentence): Text Analysis API reference

Scores how positive or negative the text is. Returns an overall label and compound score (-1 to 1), the positive/neutral/negative breakdown, and a score for every sentence. This endpoint is part of the Text Analysis API: Sentiment, keywords, extractive summaries, readability scores and text statistics for English text — one simple JSON call each.

Example response (200, application/json)

Success.

1{
2  "score": 0.8622,
3  "breakdown": {
4    "neutral": 0.368,
5    "negative": 0,
6    "positive": 0.632
7  },
8  "sentences": [
9    {
10      "score": 0.8622,
11      "sentence": "I love this product, it is great!",
12      "sentiment": "positive"
13    }
14  ],
15  "sentiment": "positive"
16}

Errors

  • 400 — A required parameter is missing or a value has the wrong format.
    1{
    2  "error": {
    3    "code": "INVALID_INPUT",
    4    "message": "text: Field required"
    5  }
    6}

Gateway errors (missing key, no subscription, rate limits) are listed in Error codes.