Documentation

Everything you need β€” whether you run the Discord bot or build on the API.

Endpoint reference

v1 exposes two endpoints. All requests and responses are JSON (UTF-8).

POST/v1/translate

Translates a single piece of text. Source language is auto-detected unless source is provided.

Request body

textstringrequiredThe text to translate. Up to 5,000 characters per request. Characters are metered against your plan's included volume.
targetstringrequiredTarget language code (e.g. ja, pt-BR). See GET /v1/languages.
sourcestringoptionalSource language code. Omit for automatic detection.
enginestringoptionallibre (default) or deepl(Growth plan and above). Requests fall back to your plan's best available engine.

Request examples

curl -X POST https://api.lingua-api.com/v1/translate \
  -H "Authorization: Bearer $LINGUA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "text": "Hello world", "target": "ja" }'

# { "text": "γ“γ‚“γ«γ‘γ―δΈ–η•Œ", "detected": "en", "confidence": 0.92,
#   "engine": "libre", "characters": 11 }

Response

{
  "text": "γ“γ‚“γ«γ‘γ―δΈ–η•Œ",
  "detected": "en",
  "confidence": 0.92,
  "engine": "libre",
  "characters": 11
}

Response fields

textstringThe translated text.
detectedstringSource language as a lower-case base code (e.g. en). When you pin source, this echoes it back.
confidencenumber | nullConfidence factor for the detected source language, normalized to 0–1. 1 when you pinned source (no detection performed); null when the engine does not report a score (currently DeepL auto-detection). Treat values below ~0.5 as unreliable β€” short or mixed-language text detects poorly; retry with an explicit source.
enginestringEngine that served the request: libre or deepl. May differ from the requested engine if your plan fell back.
charactersnumberCharacters metered against your plan for this request (input length).
GET/v1/languages

Lists all supported languages. Free to call β€” does not count against usage.

{
  "languages": [
    { "code": "en-US", "name": "English (US)" },
    { "code": "ja", "name": "Japanese" },
    ...
  ]
}

Errors

Errors use conventional HTTP status codes with a JSON body:

{ "error": { "code": "quota_exceeded", "message": "Monthly included characters exhausted and overage is disabled." } }
StatusCodeMeaning
400invalid_requestMissing/invalid fields, unsupported language code, text too long.
401invalid_keyMissing, revoked, or malformed API key.
402quota_exceededIncluded characters used up and overage disabled on your account.
429rate_limitedRequests-per-second cap hit β€” check the Retry-After header.
503engine_unavailableUpstream engine outage; retry with backoff or a different engine.