Skip to main content

Sentiment Analysis

The sentiment endpoint checks the sentiment for a given text - positive, negative, or neutral. The overall sentiment is returned as well as the sentiment for each sentence for a more fine-grained breakdown.

If you're looking for specific emotions/tones, please see our tone endpoint.

Try it out

Sample Code

curl -X POST https://api.sapling.ai/api/v1/sentiment \
-H "Content-Type: application/json" \
-d '{"key":"<api-key>", "text":"Im really stoked about this! This was a very difficult project. Excited to see it go through!"}'

Sample Response

{
"overall": [
[ 0.9966725875565317, "POSITIVE" ]
],
"results": [
[
[ 0.9962439247756265, "POSITIVE" ]
],
[
[ 0.8007598668336868, "NEGATIVE" ],
[ 0.04219657927751541, "POSITIVE" ]
],
[
[ 0.9941994925029576, "POSITIVE" ],
[ 0.0009521204046905041, "NEUTRAL" ]
]
],
"sents": [
"I'm really stoked about this!",
"This was a very difficult project.",
"Excited to see it go through!"
]
}

Request Parameters

POST to https://api.sapling.ai/api/v1/sentiment

key: String
32-character API key.

text: String
Text to analyze the sentiment for.

Response Parameters

The sentiment endpoint contains three fields:

  1. sents: The sentences the text contains.
  2. overall: A list of tuples of the form (probability, sentiment).
  3. results: For each sentence, a list item containing a list of tuples of the form (probability, sentiment).