import deeplauth_key = "f63c02c5-f056-..." # Replace with your keytranslator = deepl.Translator(auth_key)result = translator.translate_text("Hello, world!", target_lang="FR")print(result.text) # "Bonjour, le monde !"
Copy
$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!
Copy
var authKey = "f63c02c5-f056-..."; // Replace with your keyvar 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.
Copy
import * as deepl from 'deepl-node';const authKey = "f63c02c5-f056-..."; // Replace with your keyconst translator = new deepl.Translator(authKey);(async () => { const result = await translator.translateText('Hello, world!', null, 'fr'); console.log(result.text); // Bonjour, le monde !})();
Copy
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 !" }}
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.
Write API example: cURL
Example cURL request
Copy
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
Copy
{ "improvements": [ { "text": "I could really use some help with editing this text!", "target_language": "en-US", "detected_source_language": "en" } ]}