🔐 Authentication Guide
🎯 Overview
Learn how to securely authenticate your requests to the Sentor ML API using API keys.
✨ Prerequisites
- Sentor ML account (Get an API key here)
- Basic understanding of REST APIs
🔑 Getting Started with API Keys
1. 🎓 Guest Access
For quick testing, obtain a API key with limited usage by logging in to Sentor and we will provide you the key with free subscription plan.
2. 🔨 Getting a Production API Key
- Buy a plan in Sentor
- Get your API key from the API Access tab
- Save the key securely (it won’t be shown again)
🛡️ Using Your API Key
Authentication Header
Include your API key in the x-api-key header with every request:
curl -X POST 'https://sentor.app/api/predicts'
-H 'x-api-key: YOUR_API_KEY'
-H 'Content-Type: application/json'
-d '{"docs": [{"doc": "Great product!", "doc_id": "doc1", "entities": ["product"]}]}' With Language Parameter (Dutch):
curl -X POST 'https://sentor.app/api/predicts?language=nl'
-H 'x-api-key: YOUR_API_KEY'
-H 'Content-Type: application/json'
-d '{"docs": [{"doc": "Geweldig product!", "doc_id": "doc1", "entities": ["product"]}]}' 🔒 Secure Storage
For secure API key management:
✅ Best Practices:
- Store in environment variables
- Use secret management services
- Encrypt keys at rest
- Rotate keys regularly
- Set up monitoring for unusual activity
from sentor import SentorClient
# Initialize the client
client = SentorClient('your-api-key')
# Analyze sentiment
input_data = [
{
"doc": "In the competitive landscape of consumer electronics, Apple and Samsung continue to lead the market with innovative products and strong brand loyalty. While Apple focuses on a tightly integrated ecosystem with devices like the iPhone, iPad, and Mac, Samsung excels in offering a wide range of options across various price points, especially in its Galaxy smartphone lineup. Both companies push the boundaries of technology, from cutting-edge chipsets to advanced camera systems, often setting industry trends that others follow.",
"doc_id": "0",
"entities": [
"Apple",
"Samsung",
"camera"
]
},
{
"doc": "Apple's new iPhone is amazing!",
"doc_id": "1",
"entities": [
"Apple",
"iPhone"
]
},
{
"doc": "Samsung's new phone is amazing!",
"doc_id": "2",
"entities": [
"Samsung",
"phone"
]
}
]
result = client.analyze(input_data)
print(result) import { SentorClient } from 'sentor-sdk';
// Initialize the client
const client = new SentorClient('your-api-key');
// Analyze sentiment
const input =
{
"docs": [
{
"doc": "In the competitive landscape of consumer electronics, Apple and Samsung continue to lead the market with innovative products and strong brand loyalty. While Apple focuses on a tightly integrated ecosystem with devices like the iPhone, iPad, and Mac, Samsung excels in offering a wide range of options across various price points, especially in its Galaxy smartphone lineup. Both companies push the boundaries of technology, from cutting-edge chipsets to advanced camera systems, often setting industry trends that others follow.",
"doc_id": "0",
"entities": [
"Apple",
"Samsung",
"camera"
]
},
{
"doc": "Apple's new iPhone is amazing!",
"doc_id": "1",
"entities": [
"Apple",
"iPhone"
]
},
{
"doc": "Samsung's new phone is amazing!",
"doc_id": "2",
"entities": [
"Samsung",
"phone"
]
}
]
}
const result = await client.analyze(input);
console.log(result); ❌ Never:
- Hardcode keys in source code
- Share keys in public repositories
- Log keys in application logs
- Use keys without proper access controls
⚠️ Error Handling
Common Issues
| Error | Solution |
|---|---|
| Invalid API Key | Verify key in dashboard |
| Rate Limited | Review your plan’s usage limits |
Implementation Example
try:
client = SentorClient(api_key)
result = client.analyze(analyze_input)
except AuthenticationError as e:
if e.code == 'invalid_key':
notify_admin("Invalid API key")
elif e.code == 'expired_key':
rotate_api_key() 🤝 Support & Resources
- 📧 Email Support: sentor@nikx.one
- 💬 Discord Community: Join our Discord
- 📚 Documentation: sentor.app/docs