Comprehensive guide to integrate sentiment analysis into your applications. Analyze text sentiment and extract entity-based insights with our powerful API endpoints.
Get up and running with the Sentiment API in minutes
curl -X POST "https://api.example.com/sentiment" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"text": "I love this amazing product!"}'
Secure your API requests with API key authentication
Sign up for an account
Create your developer account at our platform
Generate API key
Navigate to API Keys section and create a new key
Copy and secure
Copy your API key and store it securely
Include your API key in the Authorization header of every request:
Authorization: Bearer YOUR_API_KEY_HERE
Security Note
Never expose your API key in client-side code or public repositories. Always use environment variables or secure configuration management.
Two powerful endpoints for comprehensive sentiment analysis
Headers:
Authorization: Bearer YOUR_API_KEY Content-Type: application/json
Body:
{ "text": "Your text to analyze" }
{ "sentiment": "positive", "compound_score": 0.6369, "positive_score": 0.636, "negative_score": 0.0, "neutral_score": 0.364, "confidence": 0.95 }
Headers:
Authorization: Bearer YOUR_API_KEY Content-Type: application/json
Body:
{ "text": "Your text to analyze" }
{ "entities": [ { "name": "Google", "type": "ORGANIZATION", "sentiment": "positive", "score": 0.8, "magnitude": 0.8 }, { "name": "Microsoft", "type": "ORGANIZATION", "sentiment": "negative", "score": -0.3, "magnitude": 0.3 } ], "overall_sentiment": "mixed" }
Headers:
Authorization: Bearer YOUR_API_KEY
{ "ok": true, "timestamp": "2024-01-15T10:30:00Z", "version": "1.0.0" }
Ready-to-use code snippets in your preferred language
const axios = require('axios'); const analyzeSentiment = async (text) => { try { const response = await axios.post( 'https://api.example.com/sentiment', { text }, { headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' } } ); return response.data; } catch (error) { console.error('Error:', error.response?.data || error.message); } }; // Usage analyzeSentiment("I love this amazing product!") .then(result => console.log(result));
import requests def analyze_sentiment(text, api_key): url = "https://api.example.com/sentiment" headers = { "Authorization": f"Bearer {api_key}", "Content-Type": "application/json" } data = {"text": text} try: response = requests.post(url, json=data, headers=headers) response.raise_for_status() return response.json() except requests.exceptions.RequestException as e: print(f"Error: {e}") return None # Usage api_key = "YOUR_API_KEY" result = analyze_sentiment("I love this amazing product!", api_key) print(result)
Overall Sentiment:
curl -X POST "https://api.example.com/sentiment" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"text": "I love this amazing product!"}'
Entity Sentiment:
curl -X POST "https://api.example.com/entity-sentiment" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"text": "Google is great, Microsoft has issues"}'
Import our Postman collection to test all endpoints:
Note: Remember to set your API key in the collection variables before testing the endpoints.
Common issues and solutions for smooth API integration
401 Unauthorized
Check that your API key is correct and included in the Authorization header
403 Forbidden
Verify your API key has the necessary permissions and hasn't expired
If you receive 429 Too Many Requests:
400 Bad Request
Ensure your request body contains valid JSON with the required "text" field
413 Payload Too Large
Text input is limited to 10,000 characters per request
Can't find the solution you're looking for? Our support team is here to help.