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.
POST /v2/translate HTTP/2Host:api.deepl.comAuthorization:DeepL-Auth-Key [yourAuthKey]User-Agent:YourApp/1.2.3Content-Length:45Content-Type:application/json{"text":["Hello, world!"],"target_lang":"DE"}
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 !"
$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 keyvar translator =newTranslator(authKey);// Translate text into a target language, in this case, French:var translatedText =awaittranslator.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';constauthKey="f63c02c5-f056-..."; // Replace with your keyconsttranslator=newdeepl.Translator(authKey);(async () => {constresult=awaittranslator.translateText('Hello, world!',null,'fr');console.log(result.text); // Bonjour, le monde !})();
importcom.deepl.api.*;classExample {Translator translator;publicExample() throwsException {String authKey ="f63c02c5-f056-..."; // Replace with your key translator =newTranslator(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" } ]}