Your first API request

Make your first API request and translate text with the BeringAI API.

Once you’ve created a BeringAI API account and located your authentication key, you’re ready to make your first request. Let’s start with text translation.

To translate text, you can use the /translate endpoint, which also supports translation of XML and HTML content.the /translate endpoint, which also supports translation of XML and HTML content.
We included text translation examples for our client libraries client libraries, too, just to give you an idea of what they look like.

Example request

				
					curl -X POST 'https://api.deepl.com/v2/translate' \
--header 'Authorization: DeepL-Auth-Key [yourAuthKey]' \
--header 'Content-Type: application/json' \
--data '{
  "text": [
    "Hello, world!"
  ],
  "target_lang": "DE"
}'
				
			

Example response

				
					{
  "translations": [
    {
      "detected_source_language": "EN",
      "text": "Hallo, Welt!"
    }
  ]
}
				
			

HTTP Request

The example below uses our API Pro endpoint https://api.deepl.com. If you’re an API Free user, remember to update your requests to use https://api-free.deepl.com instead.
				
					POST /v2/translate HTTP/2
Host: api.deepl.com
Authorization: DeepL-Auth-Key [yourAuthKey] 
User-Agent: YourApp/1.2.3
Content-Length: 45
Content-Type: application/json

{"text":["Hello, world!"],"target_lang":"DE"}
				
			
				
					{
  "translations": [
    {
      "detected_source_language": "EN",
      "text": "Hallo, Welt!"
    }
  ]
}
				
			

Python

				
					import deepl

auth_key = "f63c02c5-f056-..."  # Replace with your key
translator = deepl.Translator(auth_key)

result = translator.translate_text("Hello, world!", target_lang="FR")
print(result.text)  # "Bonjour, le monde !"
				
			

PHP

				
					$authKey = "f63c02c5-f056-..."; // Replace with your key
$translator = new \DeepL\Translator($authKey);

$result = $translator->translateText('Hello, world!', null, 'fr');
echo $result->text; // Bonjour, le monde!
				
			

C#

				
					var authKey = "f63c02c5-f056-..."; // Replace with your key
var translator = new Translator(authKey);

// Translate text into a target language, in this case, French:
var translatedText = await translator.TranslateTextAsync(
      "Hello, world!",
      LanguageCode.English,
      LanguageCode.French);
Console.WriteLine(translatedText); // "Bonjour, le monde !"
// Note: printing or converting the result to a string uses the output text.
				
			

Node.js

				
					import * as deepl from 'deepl-node';

const authKey = "f63c02c5-f056-..."; // Replace with your key
const translator = new deepl.Translator(authKey);

(async () => {
    const result = await translator.translateText('Hello, world!', null, 'fr');
    console.log(result.text); // Bonjour, le monde !
})();
				
			

Java

				
					import com.deepl.api.*;

class Example {
    Translator translator;

    public Example() throws Exception {
        String authKey = "f63c02c5-f056-...";  // Replace with your key
        translator = new Translator(authKey);
        TextResult result =
                translator.translateText("Hello, world!", null, "fr");
        System.out.println(result.getText()); // "Bonjour, le monde !"
    }
}
				
			

Published