Detect the sentiment (positive or negative) of a given text. The entire document is scored and also each individual sentence.
Sentiment is computed for English text. Confidence values are numbers between 0 and 1.
| Name | Example | Description |
|---|---|---|
text | Happy times feel so good. | The English text for which the sentiment should be detected. Max 2,000 characters for Latin-script text. Because the text travels in the URL, texts in other scripts are limited to about 800 characters. |
api-key | abcd1234 | Your API key. |
{
"document": {
"sentiment": "positive",
"confidence": 1,
"average_confidence": 1
},
"sentences": [
{
"sentiment": "positive",
"offset": 0,
"confidence": 1,
"length": 34
}
]
} Copy Code
curl -X GET 'https://api.apileague.com/detect-sentiment?text=Everything+is+super+nice+and+happy' \ -H 'x-api-key: myapikey'
Response Headers:
Content-Type: application/jsonX-API-Quota-Request: The number of tokens used by the requestX-API-Quota-Used: The number of tokens used in total todayX-API-Quota-Left: The number of tokens left today (depends on your plan)It analyzes a given text to determine whether the sentiment is positive or negative. It provides a score for the entire document as well as for each individual sentence.
The API returns a JSON object containing the sentiment (positive/negative), a confidence score, and an average confidence score for the document, along with a breakdown for each sentence.
Yes, it is perfect for analyzing user reviews, comments, tweets, and other social media content to gauge public opinion and sentiment.
The Detect Sentiment API analyzes the emotion or opinion in the text, whereas the Detect Language API simply identifies which language the text is written in.