DEV Community

Cover image for Emotion Detection & Sentiment Analysis API: A Developer's Guide
AI Engine
AI Engine

Posted on • Originally published at ai-engine.net

Emotion Detection & Sentiment Analysis API: A Developer's Guide

Need to detect emotions, analyze sentiment, or profile personality from text? The Emotion & Personality Analysis API gives you 4 NLP endpoints behind a single subscription — no models to train.

4 Endpoints, 1 Subscription

Endpoint What it does
/emotions Detect emotions (joy, anger, sadness, fear, surprise, disgust) with confidence scores
/sentiment Classify text as positive, negative, or neutral
/personality Infer Big Five personality traits (openness, conscientiousness, etc.)
/communication Identify communication style and formality level

Detect Emotions in Text

import requests

url = "https://emotion-sentiment-personality-analysis.p.rapidapi.com/emotions"
headers = {
    "x-rapidapi-host": "emotion-sentiment-personality-analysis.p.rapidapi.com",
    "x-rapidapi-key": "YOUR_API_KEY",
    "Content-Type": "application/x-www-form-urlencoded",
}
payload = {"text": "I just got promoted! This is the best day of my life!"}

response = requests.post(url, headers=headers, data=payload)
result = response.json()

for emotion in result["body"]["emotions"]:
    print(f"{emotion['name']}: {emotion['score']:.2f}")
Enter fullscreen mode Exit fullscreen mode

Analyze Sentiment

url = "https://emotion-sentiment-personality-analysis.p.rapidapi.com/sentiment"
payload = {"text": "The product quality is terrible and customer support never responds."}

response = requests.post(url, headers=headers, data=payload)
result = response.json()
print(f"Sentiment: {result['body']['sentiment']}")
print(f"Score: {result['body']['score']:.2f}")
Enter fullscreen mode Exit fullscreen mode

Real-World Use Cases

  • Customer support — route tickets by emotional urgency (angry → priority queue)
  • Product reviews — aggregate sentiment across thousands of reviews
  • Social media monitoring — track brand sentiment in real-time
  • HR & recruiting — analyze communication style in written assessments
  • Mental health apps — flag concerning emotional patterns

Tips

  • Send at least 20-30 words for reliable emotion detection
  • Use /sentiment for binary classification, /emotions for granular analysis
  • Combine /personality + /communication for comprehensive profiling
  • Process text in the original language — the API handles multilingual input

👉 Read the full guide with JavaScript examples and more use cases

Top comments (0)