SocketsIO API Documentation

Translation API — 195 languages, Google Translate v2 compatible, 90% cheaper

Base URL: https://api.socketsio.com

Authentication

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.

Plans

PlanPriceCharacters/MonthRate Limit
Free$0500,00010 req/min
Basic$9/mo5,000,00060 req/min
Pro$29/mo50,000,000300 req/min

Translate Text

POST /v1/translate

Translate text to a target language. Supports single string or array of strings.

Request Body

ParameterTypeRequiredDescription
qstring | string[]requiredText(s) to translate
targetstringrequiredTarget language code (e.g. "zh", "es", "ja")
sourcestringoptionalSource language code. Auto-detected if omitted.
formatstringoptional"text" (default) or "html"

Example — Single Text

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"
  }'

Response

{
  "data": {
    "translations": [
      {
        "translatedText": "Hola, ¿cómo estás?",
        "detectedSourceLanguage": "en",
        "input": "Hello, how are you?"
      }
    ]
  }
}

Example — Batch Translation

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"
  }'

Python

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)

JavaScript

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 Language

POST /v1/detect

Detect the language of input text.

Request Body

ParameterTypeRequiredDescription
qstring | string[]requiredText(s) to detect

Example

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"}'

Response

{
  "data": {
    "detections": [
      {
        "language": "fr",
        "confidence": 1.0,
        "isReliable": true,
        "input": "Bonjour le monde"
      }
    ]
  }
}

Supported Languages

GET /v1/languages

List all 195 supported languages.

Example

curl https://api.socketsio.com/v1/languages \
  -H "X-API-Key: YOUR_API_KEY"

Migrating from Google Translate v2

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.

SDKs & Libraries

LanguagePackageInstall
Pythonsocketsiopip install socketsio
JavaScriptsocketsionpm install socketsio

⚡ Interactive API Playground

Test the API live in your browser — no installation needed. Results appear in under a second.

No API key? Get one free → (500K chars/month, no credit card)  ·  Enter your key to begin

POST /v1/translate

Input text *
Target language *
Source language (optional)
Raw Response
💡 Response includes translatedText and detectedSourceLanguage. Press Ctrl+Enter to run.

POST /v1/translate — Batch Mode

Input texts (one per line) *
Target language *
Source language (optional)
Results
💡 Batch up to 128 strings in a single request — much faster than individual calls. Up to 10 lines shown as cards above.

POST /v1/detect

Input text *
Raw Response
💡 Returns language (ISO code) and confidence (0–1). Supports all 195 languages.

Rate Limits

All API endpoints are rate-limited per API key. Limits reset every 60 seconds (rolling window).

PlanRate LimitCharacters/Month
Free100 req/min500,000
Basic300 req/min5,000,000
Pro1,000 req/min50,000,000
EnterpriseUnlimitedCustom

429 Response Format

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:

Error Codes

All errors follow a consistent JSON structure:

{
  "error": {
    "code": 400,
    "message": "Human-readable description of what went wrong",
    "type": "error_type_string"
  }
}
HTTP CodeTypeMeaningExample Cause
400invalid_requestBad requestMissing q or target field; unsupported language code
401authentication_errorMissing or invalid API keyNo X-API-Key header; key revoked or mistyped
403quota_exceededMonthly character limit exceededFree plan 500K chars/month used up; upgrade to continue
429rate_limitToo many requestsExceeded req/min limit for your plan; check Retry-After header
500server_errorInternal server errorUnexpected backend error; safe to retry after a short delay

Error Examples

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"
  }
}

Ready to start?

500,000 characters/month free. No credit card required.

Get Your Free API Key →