Sentiment Analysis
Analyze the sentiment of any text and get back a positive, negative, or neutral classification with a confidence score and full breakdown.
Overview
Use Cases
- Monitoring customer feedback and support tickets
- Analyzing social media mentions and product reviews
- Preprocessing text for NLP and ML pipelines
- Real-time moderation of user-generated content
Features
Returns positive, negative, or neutral classification
Confidence score between 0.0 and 1.0
Full breakdown showing proportional scores for all three classes
Works on short phrases and long-form text
API Endpoints
Analyze Sentiment
Analyzes the sentiment of the provided text and returns a classification, confidence score, and a full breakdown across all three sentiment classes.
POST
https://api.requiems.xyz/v1/ai/sentiment
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| text | string |
Required | The text to analyze. |
Try it out
Live DemoRequest
The text to analyze.
Sending request...
Response Fields
| Field | Type | Description |
|---|---|---|
| sentiment | string |
The dominant sentiment class: positive, negative, or neutral |
| score | number |
Confidence score for the dominant sentiment, between 0.0 and 1.0 |
| breakdown.positive | number |
Proportional score for positive sentiment (sums to 1.0 with other classes) |
| breakdown.negative | number |
Proportional score for negative sentiment (sums to 1.0 with other classes) |
| breakdown.neutral | number |
Proportional score for neutral sentiment (sums to 1.0 with other classes) |
Code Examples
curl -X POST https://api.requiems.xyz/v1/ai/sentiment \
-H "requiems-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "I absolutely love this product!"}'
import requests
url = "https://api.requiems.xyz/v1/ai/sentiment"
headers = {
"requiems-api-key": "YOUR_API_KEY",
"Content-Type": "application/json"
}
payload = {"text": "I absolutely love this product!"}
response = requests.post(url, json=payload, headers=headers)
data = response.json()['data']
print(f"{data['sentiment']} ({data['score']:.2f})")
const response = await fetch(
'https://api.requiems.xyz/v1/ai/sentiment',
{
method: 'POST',
headers: {
'requiems-api-key': 'YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({ text: 'I absolutely love this product!' })
}
);
const { data } = await response.json();
console.log(`${data.sentiment} (${data.score.toFixed(2)})`);
require 'net/http'
require 'json'
uri = URI('https://api.requiems.xyz/v1/ai/sentiment')
request = Net::HTTP::Post.new(uri)
request['requiems-api-key'] = 'YOUR_API_KEY'
request['Content-Type'] = 'application/json'
request.body = { text: 'I absolutely love this product!' }.to_json
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
data = JSON.parse(response.body)['data']
puts "#{data['sentiment']} (#{data['score'].round(2)})"
Error Responses
422
unprocessable_entity
Frequently Asked Questions
The sentiment field returns one of three values β positive, negative, or neutral β based on whichever class has the highest score.
The three breakdown values (positive, negative, neutral) always sum to 1.0. They represent the proportional confidence across all classes, not just the dominant one.
There is no strict character limit enforced at the API level, but very long inputs may be truncated by the underlying model. Aim for inputs under 512 tokens for best accuracy.