Skip to content

Sentiment

Premium · 5 credits

Analyze the sentiment of text, returning a label and score. Optionally break down sentiment per sentence.

FieldTypeRequiredDefaultDescription
textstringYesText to analyze
granularitystringNodocumentdocument or sentence
FieldTypeDescription
labelstringpositive, negative, neutral, or mixed
scorenumberSentiment score from -1.0 (negative) to 1.0 (positive)
sentencesarrayPer-sentence results (when granularity is sentence)
sentences[].textstringSentence text
sentences[].labelstringSentence sentiment label
sentences[].scorenumberSentence sentiment score
Terminal window
curl -X POST https://morso.dev/api/sentiment \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "This product is absolutely amazing! Best purchase I have ever made."}'
{
"label": "positive",
"score": 0.92
}
Terminal window
curl -X POST https://morso.dev/api/sentiment \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "The food was excellent. However, the service was terrible.", "granularity": "sentence"}'
{
"label": "mixed",
"score": 0.1,
"sentences": [
{"text": "The food was excellent.", "label": "positive", "score": 0.88},
{"text": "However, the service was terrible.", "label": "negative", "score": -0.85}
]
}