DEV Community

miccho27
miccho27

Posted on

NLP Without ML Expertise: Text Analysis API for Sentiment, Topics, and Keywords

Extract Intelligence from Text Without Touching TensorFlow

Most developers don't have time to build, train, and deploy machine learning models. You need sentiment analysis, keyword extraction, or topic detection—but you need it yesterday, and you don't have a PhD.

The Text Analysis API gives you production-grade NLP without the infrastructure overhead.

What You Get

  • Sentiment Analysis: Positive, negative, neutral with confidence scores
  • Keyword Extraction: Important terms and their relevance
  • Topic Detection: What's this text actually about?
  • Language Detection: Identify language automatically
  • Text Summarization: Condense long content to essentials
  • Entity Recognition: Names, places, organizations, dates

All in one REST call. No model training required.

Real-World Use Case: Monitoring Customer Feedback

You're running a SaaS product. Users leave feedback in three places:

  1. In-app comments
  2. Support emails
  3. Twitter mentions

You can't read every message. You need to automatically:

  • Sort by sentiment (angry customers first)
  • Extract pain points (what problems are they reporting?)
  • Identify trends (are multiple people complaining about the same feature?)

Python Implementation: Feedback Dashboard

import requests
from typing import Dict, List

RAPIDAPI_KEY = "YOUR_RAPIDAPI_KEY"
RAPIDAPI_HOST = "text-analysis-api.p.rapidapi.com"

def analyze_feedback(text: str) -> Dict:
    """
    Analyze customer feedback for sentiment, keywords, and topics.

    Returns:
        {
            "sentiment": "negative|neutral|positive",
            "confidence": 0.95,
            "keywords": ["billing", "slow", "expensive"],
            "topics": ["pricing", "performance"]
        }
    """
    url = "https://text-analysis-api.p.rapidapi.com/analyze"

    payload = {
        "text": text,
        "features": ["sentiment", "keywords", "topics"]
    }

    headers = {
        "X-RapidAPI-Key": RAPIDAPI_KEY,
        "X-RapidAPI-Host": RAPIDAPI_HOST,
        "Content-Type": "application/json"
    }

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

    return response.json()

# Example: Analyze support ticket
feedback_text = """
Your pricing is getting ridiculous. We're paying $500/month but the service keeps going down.
I've had 3 outages in the last week. For this price, I expect enterprise-grade uptime.
Please fix this or we're switching to Competitor X.
"""

analysis = analyze_feedback(feedback_text)

print(f"Sentiment: {analysis['sentiment']}")  # Output: negative
print(f"Confidence: {analysis['confidence']}")  # 0.97
print(f"Keywords: {analysis['keywords']}")  # ['pricing', 'outages', 'uptime']
print(f"Topics: {analysis['topics']}")  # ['pricing', 'reliability']
Enter fullscreen mode Exit fullscreen mode

Express.js: Feedback Intake API

const axios = require("axios");
const express = require("express");
const app = express();

app.use(express.json());

const analyzeFeedback = async (text) => {
  const response = await axios.post(
    "https://text-analysis-api.p.rapidapi.com/analyze",
    {
      text,
      features: ["sentiment", "keywords", "topics", "entities"]
    },
    {
      headers: {
        "X-RapidAPI-Key": process.env.RAPIDAPI_KEY,
        "X-RapidAPI-Host": "text-analysis-api.p.rapidapi.com",
        "Content-Type": "application/json"
      }
    }
  );

  return response.data;
};

// Endpoint: Submit feedback
app.post("/api/feedback", async (req, res) => {
  const { text, source } = req.body;  // source: "email" | "in-app" | "twitter"

  try {
    const analysis = await analyzeFeedback(text);

    // Save to database with analysis
    const feedback = await saveFeedback({
      text,
      source,
      sentiment: analysis.sentiment,
      confidence: analysis.confidence,
      keywords: analysis.keywords,
      topics: analysis.topics,
      priority: analysis.sentiment === "negative" ? "high" : "normal",
      created_at: new Date()
    });

    // Alert team if urgent
    if (analysis.sentiment === "negative" && analysis.confidence > 0.9) {
      await notifyTeam({
        type: "urgent_feedback",
        text: text.substring(0, 100),
        source,
        keywords: analysis.keywords
      });
    }

    res.json({ success: true, feedback_id: feedback.id });

  } catch (error) {
    res.status(500).json({ error: error.message });
  }
});

app.listen(3000);
Enter fullscreen mode Exit fullscreen mode

Advanced: Batch Analysis for Trend Detection

Process multiple feedback items to identify patterns:

import csv
from collections import Counter

def identify_feedback_trends(csv_file: str, num_top_issues: int = 10) -> Dict:
    """
    Analyze all feedback and identify top issues.

    Returns:
        {
            "sentiment_distribution": {"positive": 30, "neutral": 50, "negative": 20},
            "top_keywords": [("pricing", 45), ("slow", 38), ("support", 22)],
            "top_topics": [("billing", 0.8), ("performance", 0.7)],
            "urgent_feedback": [...]
        }
    """

    all_keywords = []
    all_topics = []
    sentiments = {"positive": 0, "neutral": 0, "negative": 0}
    urgent_feedback = []

    with open(csv_file, 'r') as f:
        reader = csv.DictReader(f)
        for row in reader:
            text = row['feedback_text']

            # Analyze each feedback item
            analysis = analyze_feedback(text)

            # Aggregate sentiment
            sentiment = analysis['sentiment']
            sentiments[sentiment] += 1

            # Collect keywords and topics
            all_keywords.extend(analysis.get('keywords', []))
            all_topics.extend(analysis.get('topics', []))

            # Flag urgent (negative, high confidence)
            if sentiment == "negative" and analysis.get('confidence', 0) > 0.85:
                urgent_feedback.append({
                    "text": text[:100],
                    "confidence": analysis['confidence'],
                    "keywords": analysis['keywords']
                })

    # Calculate top issues
    keyword_counts = Counter(all_keywords)
    topic_counts = Counter(all_topics)

    return {
        "sentiment_distribution": sentiments,
        "top_keywords": keyword_counts.most_common(num_top_issues),
        "top_topics": topic_counts.most_common(5),
        "urgent_feedback_count": len(urgent_feedback),
        "urgent_feedback_sample": urgent_feedback[:5]
    }

# Weekly trends report
trends = identify_feedback_trends("feedback.csv")

print(f"This week's sentiment:")
for sentiment, count in trends['sentiment_distribution'].items():
    pct = count / sum(trends['sentiment_distribution'].values()) * 100
    print(f"  {sentiment}: {count} ({pct:.1f}%)")

print(f"\nTop issues:")
for keyword, count in trends['top_keywords'][:5]:
    print(f"  {keyword}: {count} mentions")

print(f"\nUrgent feedback: {trends['urgent_feedback_count']} items")
Enter fullscreen mode Exit fullscreen mode

API Parameters

Parameter Type Required Notes
text string Yes Text to analyze
features array No Which analyses to run: sentiment, keywords, topics, entities, summary
language string No Language code (auto-detected if omitted)

Response Format

{
  "sentiment": "positive",
  "confidence": 0.92,
  "keywords": [
    {"term": "pricing", "relevance": 0.95},
    {"term": "slow", "relevance": 0.87}
  ],
  "topics": ["billing", "performance"],
  "entities": [
    {"type": "ORGANIZATION", "value": "Competitor X"},
    {"type": "NUMBER", "value": "500"},
    {"type": "DURATION", "value": "3 outages"}
  ],
  "summary": "User is unhappy with pricing and service reliability."
}
Enter fullscreen mode Exit fullscreen mode

Best Practices

1. Prioritize by Sentiment + Confidence

Not all negative feedback is created equal:

def calculate_priority(analysis: Dict) -> str:
    """Determine how urgent this feedback is."""
    sentiment = analysis['sentiment']
    confidence = analysis.get('confidence', 0.5)

    if sentiment == "negative" and confidence > 0.85:
        return "urgent"  # Angry AND we're confident
    elif sentiment == "negative" and confidence > 0.7:
        return "high"
    elif sentiment == "positive":
        return "low"
    else:
        return "normal"
Enter fullscreen mode Exit fullscreen mode

2. Deduplicate Issues Across Sources

Group similar feedback:

def group_similar_feedback(feedback_items: List[Dict]) -> Dict:
    """Group feedback by common keywords."""
    groups = {}

    for item in feedback_items:
        keywords = tuple(sorted(item['keywords'][:3]))  # Top 3 keywords

        if keywords not in groups:
            groups[keywords] = []

        groups[keywords].append(item)

    # Sort by group size
    return sorted(groups.items(), key=lambda x: -len(x[1]))
Enter fullscreen mode Exit fullscreen mode

3. Track Sentiment Trends Over Time

Monitor sentiment drift:

import json
from datetime import datetime, timedelta

def trending_sentiment(days: int = 7) -> Dict:
    """Show sentiment trend over last N days."""

    trends = {}
    for i in range(days):
        date = datetime.now() - timedelta(days=i)
        feedback = get_feedback_for_date(date)

        sentiments = [analyze_feedback(f['text'])['sentiment'] for f in feedback]
        negative_pct = (sentiments.count('negative') / len(sentiments)) * 100

        trends[date.isoformat()] = negative_pct

    return trends
Enter fullscreen mode Exit fullscreen mode

Use Cases

Perfect for:

  • Customer feedback analysis
  • Social media sentiment monitoring
  • Support ticket triage
  • Review aggregation (AppStore, Trustpilot, etc.)
  • Survey response analysis
  • User interview synthesis

Not ideal for:

  • Real-time streaming (high-volume)
  • Complex multi-language mixing
  • Sarcasm detection (still an NLP challenge)

Pricing

Plan Cost Analyses/mo Rate Limit
Free $0 1,000 1 req/sec
Pro $19.99 100,000 10 req/sec
Ultra $99.99 1,000,000 50 req/sec

Final Thoughts

Understanding what users are saying requires NLP. But you don't need to become an ML engineer to use it. APIs let you extract sentiment, keywords, and topics from user feedback without touching a training script.

Get started free at RapidAPI Marketplace.


What kind of feedback are you analyzing in your product? Let me know in the comments!

Top comments (0)