Translation API — 195 languages, Google Translate v2 compatible, 90% cheaper
All API requests require an API key passed via the X-API-Key header.
curl https://api.socketsio.com/v1/translate \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"q": "Hello", "target": "zh"}'
Get your free API key at socketsio.com — 500,000 characters/month free, no credit card required.
| Plan | Price | Characters/Month | Rate Limit |
|---|---|---|---|
| Free | $0 | 500,000 | 10 req/min |
| Basic | $9/mo | 5,000,000 | 60 req/min |
| Pro | $29/mo | 50,000,000 | 300 req/min |
Translate text to a target language. Supports single string or array of strings.
| Parameter | Type | Required | Description |
|---|---|---|---|
q | string | string[] | required | Text(s) to translate |
target | string | required | Target language code (e.g. "zh", "es", "ja") |
source | string | optional | Source language code. Auto-detected if omitted. |
format | string | optional | "text" (default) or "html" |
curl -X POST https://api.socketsio.com/v1/translate \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"q": "Hello, how are you?",
"target": "es"
}'
{
"data": {
"translations": [
{
"translatedText": "Hola, ¿cómo estás?",
"detectedSourceLanguage": "en",
"input": "Hello, how are you?"
}
]
}
}
curl -X POST https://api.socketsio.com/v1/translate \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"q": ["Good morning", "Thank you", "Goodbye"],
"target": "ja"
}'
from socketsio import SocketsIO
client = SocketsIO(api_key="YOUR_API_KEY")
result = client.translate("Hello world", target="zh")
print(result.text) # "你好世界"
# Batch
results = client.translate(["Hello", "Goodbye"], target="es")
for r in results:
print(r.text)
import { SocketsIO } from 'socketsio';
const client = new SocketsIO({ apiKey: 'YOUR_API_KEY' });
const result = await client.translate('Hello world', { target: 'zh' });
console.log(result.text); // "你好世界"
Detect the language of input text.
| Parameter | Type | Required | Description |
|---|---|---|---|
q | string | string[] | required | Text(s) to detect |
curl -X POST https://api.socketsio.com/v1/detect \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"q": "Bonjour le monde"}'
{
"data": {
"detections": [
{
"language": "fr",
"confidence": 1.0,
"isReliable": true,
"input": "Bonjour le monde"
}
]
}
}
List all 195 supported languages.
curl https://api.socketsio.com/v1/languages \
-H "X-API-Key: YOUR_API_KEY"
SocketsIO is drop-in compatible with Google Translate v2. To migrate, change one line:
# Before (Google)
POST https://translation.googleapis.com/language/translate/v2?key=GOOGLE_KEY
# After (SocketsIO)
POST https://api.socketsio.com/v1/translate
Header: X-API-Key: YOUR_SOCKETSIO_KEY
Request and response formats are identical. Your existing code works with minimal changes.
| Language | Package | Install |
|---|---|---|
| Python | socketsio | pip install socketsio |
| JavaScript | socketsio | npm install socketsio |
Test the API live in your browser — no installation needed. Results appear in under a second.
translatedText and detectedSourceLanguage. Press Ctrl+Enter to run.language (ISO code) and confidence (0–1). Supports all 195 languages.All API endpoints are rate-limited per API key. Limits reset every 60 seconds (rolling window).
| Plan | Rate Limit | Characters/Month |
|---|---|---|
| Free | 100 req/min | 500,000 |
| Basic | 300 req/min | 5,000,000 |
| Pro | 1,000 req/min | 50,000,000 |
| Enterprise | Unlimited | Custom |
When you exceed the rate limit, the API returns HTTP 429 Too Many Requests with a Retry-After header indicating how many seconds to wait:
HTTP/1.1 429 Too Many Requests
Retry-After: 60
Content-Type: application/json
{
"error": {
"code": 429,
"message": "Rate limit exceeded. You have sent too many requests in the past 60 seconds.",
"type": "rate_limit"
}
}
Best practices:
Retry-After header and wait that many seconds before retryingq array parameter to batch up to 128 strings in a single requestAll errors follow a consistent JSON structure:
{
"error": {
"code": 400,
"message": "Human-readable description of what went wrong",
"type": "error_type_string"
}
}
| HTTP Code | Type | Meaning | Example Cause |
|---|---|---|---|
| 400 | invalid_request | Bad request | Missing q or target field; unsupported language code |
| 401 | authentication_error | Missing or invalid API key | No X-API-Key header; key revoked or mistyped |
| 403 | quota_exceeded | Monthly character limit exceeded | Free plan 500K chars/month used up; upgrade to continue |
| 429 | rate_limit | Too many requests | Exceeded req/min limit for your plan; check Retry-After header |
| 500 | server_error | Internal server error | Unexpected backend error; safe to retry after a short delay |
401 — Missing API key:
curl https://api.socketsio.com/v1/translate \
-H "Content-Type: application/json" \
-d '{"q": "Hello", "target": "es"}'
# Response:
{
"error": {
"code": 401,
"message": "API key required. Pass your key via the X-API-Key header.",
"type": "authentication_error"
}
}
400 — Invalid language code:
curl https://api.socketsio.com/v1/translate \
-H "X-API-Key: YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"q": "Hello", "target": "zzz"}'
# Response:
{
"error": {
"code": 400,
"message": "Unsupported target language: 'zzz'. See /v1/languages for supported codes.",
"type": "invalid_request"
}
}
403 — Monthly quota exceeded:
{
"error": {
"code": 403,
"message": "Monthly character quota exceeded. Upgrade your plan at socketsio.com/pricing.",
"type": "quota_exceeded"
}
}