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 โญ
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.
| 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 |
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."}'{
"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"
}
}- 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
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 deployYour private API is live in under 5 minutes. No servers to manage, no scaling to worry about.
| Method | Endpoint | Description |
|---|---|---|
POST |
/analyze |
Analyze text sentiment |
GET |
/health |
Health check |
GET |
/docs |
Interactive Swagger UI |
GET |
/openapi.json |
OpenAPI 3.0 specification |
| 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") |
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
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.
| 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) |
This is a community project. PRs, issues, and feature requests are welcome!
- Fork the repository
- Create your feature branch:
git checkout -b feature/AmazingFeature - Commit your changes:
git commit -m 'Add AmazingFeature' - Push to the branch:
git push origin feature/AmazingFeature - Open a Pull Request
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!