Skip to content

SolvCraft/Sentiment-Analysis-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

1 Commit
ย 
ย 

Repository files navigation

๐Ÿง  Sentiment Analysis API

Free, Open-Source Sentiment Analysis API โ€” Built for Speed, Privacy & Scale

License: MIT Cloudflare Workers Zero Dependencies Edge Native

The fastest free open-source sentiment analysis API on the planet.
Zero latency. Zero data sold. Zero cost.

Live API Docs โ†’ ย |ย  Try It Free โ†’ ย |ย  Star on GitHub โญ


What is the Sentiment Analysis API?

The Sentiment Analysis API is a free, open-source, lightning-fast NLP API that processes any text and returns a clear sentiment score โ€” whether it's POSITIVE, NEGATIVE, NEUTRAL, or MIXED โ€” in milliseconds.

Unlike cloud-based NLP services that charge per call, require accounts, or harvest your data, this API:

  • ๐Ÿš€ Runs at the edge โ€” deployed on Cloudflare's global network (300+ locations) so every request is served from the datacenter closest to your user
  • ๐Ÿ”’ Respects user privacy โ€” PII (emails, phone numbers, card numbers) is automatically masked before any data is stored
  • ๐Ÿ’ธ 100% Free โ€” MIT licensed, self-hostable in under 5 minutes
  • โšก Sub-2ms response times โ€” no external API calls, no cold starts, pure edge compute

Whether you're building a product review analyzer, social media sentiment dashboard, customer feedback tool, or brand monitoring system โ€” this API is the fastest way to get started.


โœจ Features

Feature Description
๐ŸŽฏ 4-Way Sentiment Classification POSITIVE, NEGATIVE, NEUTRAL, MIXED โ€” not just a binary result
๐Ÿ“Š Detailed Scores Confidence score, magnitude, positive/negative sub-scores
๐Ÿ”‘ Keyword Extraction Top keywords from the text, stop-word filtered
๐ŸŒ Language Detection Auto-detects English, Russian, Arabic, Hindi, Chinese, and more
๐Ÿ” PII Auto-Masking Emails, phone numbers, and card numbers masked before storage
๐Ÿ“ˆ Comprehensive Analytics Every request logged with geo, device, and performance data
๐Ÿ“– Interactive Docs Full Swagger UI available at /docs
๐ŸŒ OpenAPI 3.0 Machine-readable spec at /openapi.json
โ™พ๏ธ CORS Enabled Works from any browser, mobile app, or server

๐Ÿš€ Quick Start

Analyze text in one cURL command:

curl -X POST https://your-api.workers.dev/analyze \
  -H "Content-Type: application/json" \
  -d '{"text": "I absolutely love this product! The quality is outstanding."}'

Response:

{
  "success": true,
  "data": {
    "label": "POSITIVE",
    "score": 0.9124,
    "magnitude": 0.7231,
    "positive_score": 0.8800,
    "negative_score": 0.0200,
    "keywords": ["love", "product", "quality", "outstanding"],
    "token_count": 12,
    "sentence_count": 1,
    "language_hint": "en"
  },
  "meta": {
    "ray_id": "8a1b2c3d4e5f0000",
    "execution_time_ms": 1.45,
    "api_version": "1.0.0"
  }
}

๐Ÿ“ฆ Use Cases

  • E-commerce โ€” Analyze product reviews at scale
  • Customer Support โ€” Automatically flag negative feedback tickets
  • Social Media Monitoring โ€” Track brand sentiment on Twitter/Reddit/news
  • Content Moderation โ€” Pre-screen text for emotional extremes
  • Survey Analysis โ€” Process open-ended responses instantly
  • Chatbots & AI Agents โ€” Give your LLM app emotional awareness
  • Market Research โ€” Gauge public sentiment on topics and trends

๐Ÿ› ๏ธ Self-Host in 5 Minutes

This API is entirely self-hostable on your own Cloudflare Workers account (free tier is more than sufficient):

# 1. Clone the repo
git clone https://github.com/your-org/Sentiment-Analysis-API.git
cd Sentiment-Analysis-API

# 2. Install dependencies
npm install

# 3. Create the D1 database
npx wrangler d1 create saa_db
# โ†’ Copy the database_id into wrangler.toml

# 4. Run the schema migration
npm run db:init:remote

# 5. Deploy to Cloudflare Workers
npm run deploy

Your private API is live in under 5 minutes. No servers to manage, no scaling to worry about.


๐Ÿ“ก API Reference

Method Endpoint Description
POST /analyze Analyze text sentiment
GET /health Health check
GET /docs Interactive Swagger UI
GET /openapi.json OpenAPI 3.0 specification

Request Body (POST /analyze)

Field Type Required Description
text string โœ… Yes The text to analyze (1โ€“50,000 chars)
language string โŒ No ISO 639-1 language hint (e.g. "en")

๐Ÿ”’ Privacy First

We designed this API with privacy as a first-class feature:

  • No user accounts required โ€” call the API directly
  • PII Auto-Masking โ€” emails, phone numbers, and card numbers are masked (u***@domain.com, *******1234) before storage
  • No data sold โ€” analytics are used only for API health monitoring
  • Self-hostable โ€” deploy to your own Cloudflare account; your data never touches our servers

โšก Why Cloudflare Workers?

Traditional NLP APIs run on centralized servers. If you're in Mumbai and the server is in Virginia, you're paying 300ms+ in round-trip latency before the first byte.

This API runs on Cloudflare's edge network โ€” 300+ locations worldwide. Your request is handled by the datacenter nearest to you, typically in under 5ms network round-trip. Combined with our sub-2ms processing time, you get extremely fast, real-time sentiment analysis at global scale.


๐Ÿ“Š Performance Benchmarks

Metric Value
โšก Average Response Time < 5ms (edge-local)
๐Ÿงฎ Processing Time (server-side) < 2ms
๐Ÿ“ˆ Max Text Length 50,000 characters
๐ŸŒ Global Coverage 300+ edge locations
๐Ÿ“ฆ Cold Start None (Cloudflare Workers, always warm)

๐Ÿค Contributing

This is a community project. PRs, issues, and feature requests are welcome!

  1. Fork the repository
  2. Create your feature branch: git checkout -b feature/AmazingFeature
  3. Commit your changes: git commit -m 'Add AmazingFeature'
  4. Push to the branch: git push origin feature/AmazingFeature
  5. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License โ€” see LICENSE for details.

Free forever. No strings attached.


Built with โค๏ธ using Cloudflare Workers ยท Powered by edge computing

โญ If this project helped you, please star it on GitHub!

Contributors