We included text translation examples for our client libraries, too, just to give you an idea of what they look like.
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.
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.
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 !"
$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!
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.
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 !
})();
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 !"
}
}
Text improvement
To improve text, you can use the /write/rephrase endpoint. We included an example below.
The text improvement endpoint (DeepL API for Write) is currently only available to Pro API subscribers via the v2 endpoint.
Example cURL request
curl -X POST 'https://api.deepl.com/v2/write/rephrase' \
--header 'Authorization: DeepL-Auth-Key [yourAuthKey]' \
--header 'Content-Type: application/json' \
--data '{
"text": [
"I could relly use sum help with edits on thiss text !"
],
"target_lang": "en-US"
}'
Example response
{
"improvements": [
{
"text": "I could really use some help with editing this text!",
"target_language": "en-US",
"detected_source_language": "en"
}
]
}