Authentication
All API requests require authentication using an API key. This guide covers everything you need to know about authentication, security best practices, and API key management.
Overview
TranslatePlus API uses API key authentication. Every request must include your API key in the X-API-KEY header. Your API key is unique to your account and carries full access to your account's resources, so keep it secure.
Getting Your API Key
- Sign up for a TranslatePlus account (or log in if you already have one)
- Navigate to the API Keys section in your dashboard
- Generate a new API key or copy your existing one
- Store it securely - you'll need it for all API requests
Using Your API Key
Basic Usage
Include your API key in the X-API-KEY header with every request:
curl https://api.translateplus.io/v2/translate \
-H "X-API-KEY: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"text": "Hello, world!",
"source": "en",
"target": "fr"
}'Using Environment Variables
Never hardcode your API key in your source code. Instead, use environment variables:
# Set environment variable
export TRANSLATEPLUS_API_KEY="your_api_key_here"
# Use in curl
curl https://api.translateplus.io/v2/translate \
-H "X-API-KEY: $TRANSLATEPLUS_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Hello", "source": "en", "target": "fr"}'Configuration Files
For local development, use a .env file (and add it to .gitignore):
# .env file
TRANSLATEPLUS_API_KEY=your_api_key_herePython (.env with python-dotenv):
from dotenv import load_dotenv
import os
load_dotenv()
API_KEY = os.getenv('TRANSLATEPLUS_API_KEY')Node.js (.env with dotenv):
require('dotenv').config();
const API_KEY = process.env.TRANSLATEPLUS_API_KEY;Security Best Practices
Critical Security Rules:
-
Never commit API keys to version control
- Add
.envto your.gitignore - Use environment variables or secret management services
- Review your Git history if you accidentally committed a key
- Add
-
Restrict key access
- Only share key with trusted team members
- Use secret management services (AWS Secrets Manager, HashiCorp Vault, etc.)
- Never expose keys in client-side code or public repositories
-
Use HTTPS only
- Always use HTTPS endpoints
- Never send API keys over unencrypted connections
API Key Management
Generating New Keys
- Go to API Keys in your dashboard
- Click "Reset API Key"
- Copy the key.
- Store it securely
Revoking Keys
If your API key is compromised or you no longer need it:
- Go to API Keys in your dashboard
- Click "Reset API Key"
Important: Reset API Key immediately invalidates it. All requests using that key will fail. Make sure to update all applications it.
Authentication Errors
Missing API Key
Error: 403 Forbidden
{
"detail": "API key is required. Please provide X-API-KEY header."
}Solution: Include the X-API-KEY header in your request.
Invalid API Key
Error: 403 Forbidden
{
"detail": "Invalid API key. Please check your API key and try again."
}Possible causes:
- API key is incorrect or mistyped
- API key has been reset
Solution:
- Verify the API key in your dashboard
- Check for typos or extra spaces
Expired or Revoked Key
Error: 403 Forbidden
{
"detail": "API key has been revoked or is no longer valid."
}Solution:
- Check your API Keys to see if the key was reset
- Reset a new API key
- Update all applications using the old key
Rate Limiting and Authentication
Rate limits are applied per API key. This means:
- Each API key has its own rate limit quota
- Rate limit headers are included in responses:
X-RateLimit-Limit- Maximum requests per time windowX-RateLimit-Remaining- Remaining requests in current windowX-RateLimit-Reset- Time when the rate limit resets
For more information, see the Rate Limits guide.
Testing Your API Key
You can test your API key using the health endpoint:
curl https://api.translateplus.io/health \
-H "X-API-KEY: your_api_key"A successful response indicates your API key is valid:
{
"status": "healthy",
"timestamp": "2025-01-15T10:30:00Z"
}Troubleshooting
API Key Not Working
- Check the header name: Must be exactly
X-API-KEY(case-sensitive) - Check for spaces: Ensure no leading/trailing spaces in the key
- Verify the key: Copy it fresh from your dashboard
- Check account status: Ensure your account is active
- Check credits: Verify you have sufficient credits
Key Works in Dashboard but Not in Code
- Environment variable not loaded: Verify your
.envfile is being read - Wrong variable name: Check the environment variable name matches
- Caching issues: Restart your application/server
- Scope issues: Ensure the variable is accessible where it's used
Best Practices Checklist
- API key stored in environment variable
-
.envfile added to.gitignore - No API keys in source code or config files
- HTTPS used for all requests
- Error handling implemented for auth failures
Related Documentation
- Quick Start Guide - Get started with your first API request
- Rate Limits - Understand rate limiting and quotas
- Error Handling - Comprehensive error handling guide
- Account Summary - View your account details and usage