Sentiment Analysis
Analyze the sentiment of any text and get back a positive, negative, or neutral classification with a confidence score and full breakdown.
Descripción general
Casos de uso
- 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
Funcionalidades
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
Puntos finales de la API
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://requiems.xyz/v1/text/sentiment
Parámetros
| Nombre | Tipo | Obligatorio | Descripción |
|---|---|---|---|
| text | string |
Obligatorio | The text to analyze. |
Pruébalo
Demostración en vivoSolicitud
The text to analyze.
Sending request...
Campos de respuesta
| Campo | Tipo | Descripción |
|---|---|---|
| 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) |
Ejemplos de código
curl -X POST https://requiems.xyz/v1/text/sentiment \
-H "requiems-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "I absolutely love this product!"}'
import requests
url = "https://requiems.xyz/v1/text/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://requiems.xyz/v1/text/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://requiems.xyz/v1/text/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)})"
Respuestas de error
422
unprocessable_entity
Analyze Sentiment (Batch)
Analyzes the sentiment of up to 50 texts in a single request. Results are returned in the same order as the input. Each text counts as one unit of usage.
POST
https://requiems.xyz/v1/text/sentiment/batch
Parámetros
| Nombre | Tipo | Obligatorio | Descripción |
|---|---|---|---|
| texts | array<string> |
Obligatorio | The list of texts to analyze. Between 1 and 50 items. |
Pruébalo
Demostración en vivoSolicitud
The list of texts to analyze. Between 1 and 50 items.
Sending request...
Campos de respuesta
| Campo | Tipo | Descripción |
|---|---|---|
| results | array<object> |
Sentiment results for each input text, in the same order as the input. |
| results[].sentiment | string |
The dominant sentiment class: positive, negative, or neutral |
| results[].score | number |
Confidence score for the dominant sentiment, between 0.0 and 1.0 |
| results[].breakdown.positive | number |
Proportional score for positive sentiment (sums to 1.0 with other classes) |
| results[].breakdown.negative | number |
Proportional score for negative sentiment (sums to 1.0 with other classes) |
| results[].breakdown.neutral | number |
Proportional score for neutral sentiment (sums to 1.0 with other classes) |
| total | number |
Total number of results returned. |
Ejemplos de código
curl -X POST https://requiems.xyz/v1/text/sentiment/batch \
-H "requiems-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"texts": ["I love this!", "This is terrible.", "The table is there."]}'
import requests
url = "https://requiems.xyz/v1/text/sentiment/batch"
headers = {
"requiems-api-key": "YOUR_API_KEY",
"Content-Type": "application/json"
}
payload = {
"texts": [
"I love this!",
"This is terrible.",
"The table is there."
]
}
response = requests.post(url, json=payload, headers=headers)
for item in response.json()['data']['results']:
print(f"{item['sentiment']} ({item['score']:.2f})")
const response = await fetch(
'https://requiems.xyz/v1/text/sentiment/batch',
{
method: 'POST',
headers: {
'requiems-api-key': 'YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
texts: ['I love this!', 'This is terrible.', 'The table is there.']
})
}
);
const { data } = await response.json();
data.results.forEach(r => console.log(`${r.sentiment} (${r.score.toFixed(2)})`));
require 'net/http'
require 'json'
uri = URI('https://requiems.xyz/v1/text/sentiment/batch')
request = Net::HTTP::Post.new(uri)
request['requiems-api-key'] = 'YOUR_API_KEY'
request['Content-Type'] = 'application/json'
request.body = {
texts: ['I love this!', 'This is terrible.', 'The table is there.']
}.to_json
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end
JSON.parse(response.body)['data']['results'].each do |r|
puts "#{r['sentiment']} (#{r['score'].round(2)})"
end
Respuestas de error
400
bad_request
422
unprocessable_entity
Preguntas frecuentes
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.
Yes. Use the batch endpoint (POST /v1/text/sentiment/batch) to send up to 50 texts in a single request. Results are returned in the same order as the input and each text counts as one unit of usage.