If you chose a free API plan and you are writing cURL or HTTP requests, replace https://api.deepl.com with https://api-free.deepl.com.
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!"
}
]
}
If you chose a free API plan and you are writing cURL or HTTP requests, replace https://api.deepl.com with https://api-free.deepl.com.
export API_KEY={YOUR_API_KEY}
curl -X POST https://api.deepl.com/v2/translate \
--header "Content-Type: application/json" \
--header "Authorization: DeepL-Auth-Key $API_KEY" \
--data '{
"text": ["Hello world!"],
"target_lang": "DE"
}'
{
"translations": [
{
"detected_source_language": "EN",
"text": "Hallo, Welt!"
}
]
}
import deepl
auth_key = "{YOUR_API_KEY}" # replace with your key
deepl_client = deepl.DeepLClient(auth_key)
result = deepl_client.translate_text("Hello, world!", target_lang="DE")
print(result.text)
In production code, it’s safer to store your API key in an environment variable.
import * as deepl from 'deepl-node';
const authKey = "{YOUR_API_KEY}"; // replace with your key
const deeplClient = new deepl.DeepLClient(authKey);
(async () => {
const result = await deeplClient.translateText('Hello, world!', null, 'de');
console.log(result.text);
})();
In production code, it’s safer to store your API key in an environment variable.
composer require deeplcom/deepl-php
require_once 'vendor/autoload.php';
use DeepL\Translator;
$authKey = "{YOUR_API_KEY}"; // replace with your key
$deeplClient = new \DeepL\DeepLClient($authKey);
$result = $deeplClient->translateText('Hello, world!', null, 'de');
echo $result->text;
In production code, it’s safer to store your API key in an environment variable.
dotnet add package DeepL.net
using DeepL; // this imports the DeepL namespace. Use the code below in your main program.
var authKey = "{YOUR_API_KEY}"; // replace with your key
var client = new DeepLClient(authKey);
var translatedText = await client.TranslateTextAsync(
"Hello, world!",
null,
LanguageCode.German);
Console.WriteLine(translatedText);
In production code, it’s safer to store your API key in an environment variable.
// For instructions on installing the DeepL Java library,
// see https://github.com/DeepLcom/deepl-java?tab=readme-ov-file#installation
import com.deepl.api.*;
public class Main {
public static void main(String[] args) throws DeepLException, InterruptedException {
String authKey = "{YOUR_API_KEY}"; // replace with your key
DeepLClient client = new DeepLClient(authKey);
TextResult result = client.translateText("Hello, world!", null, "de");
System.out.println(result.getText());
}
}
In production code, it’s safer to store your API key in an environment variable.
require 'deepl'
DeepL.configure do |config|
config.auth_key = '{YOUR_API_KEY}' # replace with your key
end
translation = DeepL.translate 'Hello, world!', nil, 'de'
puts translation.text
In production code, it’s safer to store your API key in an environment variable.