Sentiment
Premium · 5 creditsAnalyze the sentiment of text, returning a label and score. Optionally break down sentiment per sentence.
POST /api/sentiment
Section titled “POST /api/sentiment”Parameters
Section titled “Parameters”| Field | Type | Required | Default | Description |
|---|---|---|---|---|
text | string | Yes | — | Text to analyze |
granularity | string | No | document | document or sentence |
Response
Section titled “Response”| Field | Type | Description |
|---|---|---|
label | string | positive, negative, neutral, or mixed |
score | number | Sentiment score from -1.0 (negative) to 1.0 (positive) |
sentences | array | Per-sentence results (when granularity is sentence) |
sentences[].text | string | Sentence text |
sentences[].label | string | Sentence sentiment label |
sentences[].score | number | Sentence sentiment score |
Examples
Section titled “Examples”Document-level
Section titled “Document-level”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}Sentence-level
Section titled “Sentence-level”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} ]}