Skip to main content
The DeepLX API returns translation results in a structured JSON format. All successful translations return an HTTP 200 status code with the complete DeepLXTranslationResult object.

Response Structure

The response object contains the following fields:
code
integer
required
HTTP status code indicating the result of the translation request. Returns 200 for successful translations.
id
integer
required
Unique identifier for the translation request. This ID is randomly generated for each request and can be used for tracking purposes.
data
string
required
The primary translated text. This is the main translation result returned by DeepL.
alternatives
string[]
required
An array of alternative translations. DeepL may provide up to 3 alternative translations for the same input text, offering different phrasings or word choices.
source_lang
string
required
The detected or specified source language code in ISO 639-1 format (e.g., “EN”, “DE”, “FR”). If the request specified auto or an empty source language, this field contains the automatically detected language.
target_lang
string
required
The target language code in ISO 639-1 format (e.g., “EN”, “DE”, “FR”). This matches the language specified in the translation request.
method
string
required
Indicates the translation method used. Possible values:
  • "Free" - Translation performed using the free DeepL API method
  • "Pro" - Translation performed using a DeepL Pro account with dl_session cookie
message
string
Error or status message. This field is only present when an error occurs or when additional information needs to be conveyed. It is omitted in successful responses.

Success Response Example

{
  "code": 200,
  "id": 8352948020,
  "data": "Hello, World!",
  "alternatives": [
    "Hi, World!",
    "Hello World!",
    "Greetings, World!"
  ],
  "source_lang": "DE",
  "target_lang": "EN",
  "method": "Free"
}

Alternatives Array

The alternatives array provides additional translation options:
DeepLX requests up to 3 alternatives from the DeepL API by setting requestAlternatives: 3 in the translation request. The actual number of alternatives returned may vary depending on the input text and language pair.
The alternatives are extracted from the DeepL API response structure:
  1. The API response contains a texts array with translation results
  2. Each text object has an alternatives array field
  3. DeepLX extracts the text field from each alternative object
  4. Only non-empty alternative texts are included in the final response
If no alternatives are available, the array will be empty [].

Language Detection

source_lang
string
When automatic language detection is used (by specifying "auto" or an empty string for source_lang in the request), DeepLX uses the whatlanggo library to detect the input language.The detected language is then:
  1. Used in the translation request to DeepL
  2. May be overridden by DeepL’s own language detection
  3. Returned in the response’s source_lang field
If the DeepL API returns a detected language in the response (result.lang), it will override the initially detected language. This ensures the most accurate source language is reported.

Method Field

The method field indicates which translation endpoint was used:
MethodDescriptionEndpoint
FreeUses the free DeepL translation service without authentication/translate, /v2/translate
ProUses DeepL Pro account with dl_session cookie for enhanced features/v1/translate
The method is determined by checking if a dl_session value was provided in the request. From translate/translate.go:201:
Method: map[bool]string{true: "Pro", false: "Free"}[dlSession != ""]

Build docs developers (and LLMs) love