Skip to main content
In this tutorial, you’ll translate your first text with the DeepL API, then batch several strings into a single request. By the end, you’ll have made the two most common types of text translation request, using curl or the official client library for your language.

Prerequisites

If you’re on a free API plan, replace https://api.deepl.com with https://api-free.deepl.com in curl examples. Client libraries detect your account type and pick the correct URL automatically.

Building with an AI coding agent?

Wire it up to the DeepL Docs MCP Server so it can search and read this documentation while it writes code. In Claude Code:
claude mcp add --transport http deepl-docs https://developers.deepl.com/mcp
Then describe what you want to build. To get the same result as this tutorial, paste:
Using the DeepL API, write a script that translates a list of English strings to German and prints the results.
Setup instructions for Claude Desktop, Cursor, VS Code, and other MCP clients are on the Docs MCP Server page.

Step 1: Send your first translation request

A translation request needs only two parameters: text, the text to translate, and target_lang, the language you’re translating to. You don’t need to specify the source language. DeepL detects it and returns it in the response as detected_source_language. If your text is very short or mixes languages, you can pin the source with the optional source_lang parameter. Language codes follow ISO 639, like DE for German or JA for Japanese, and are case-insensitive. Some target languages support regional variants, like en-US or pt-BR. See the full list of supported languages.
Set the API key
export API_KEY={YOUR_API_KEY}
Sample request
curl -X POST https://api.deepl.com/v2/translate \
  --header "Content-Type: application/json" \
  --header "Authorization: DeepL-Auth-Key $API_KEY" \
  --data '{
    "text": ["Your order has shipped and will arrive on Tuesday."],
    "target_lang": "DE"
}'
Sample response
{
  "translations": [
    {
      "detected_source_language": "EN",
      "text": "Ihre Bestellung wurde versandt und kommt am Dienstag an."
    }
  ]
}
The examples hardcode the key to keep them short. In production code, store your API key in an environment variable instead.
For security reasons, you can’t call the DeepL API directly from client-side JavaScript. During testing or prototyping, route requests through a simple proxy instead.

Step 2: Translate multiple strings in one call

The text parameter is an array, so one request can carry many strings, like every notification in a template file. Each string is translated separately and the response preserves their order. If you don’t set source_lang, DeepL detects the language of each string individually.
Sample request
curl -X POST https://api.deepl.com/v2/translate \
  --header "Content-Type: application/json" \
  --header "Authorization: DeepL-Auth-Key $API_KEY" \
  --data '{
    "text": [
      "Your order has shipped.",
      "Estimated delivery: Tuesday, July 14."
    ],
    "target_lang": "DE"
}'
Sample response
{
  "translations": [
    {
      "detected_source_language": "EN",
      "text": "Ihre Bestellung wurde versandt."
    },
    {
      "detected_source_language": "EN",
      "text": "Voraussichtliche Lieferung: Dienstag, 14. Juli."
    }
  ]
}
The client libraries accept a list of strings in the same translate_text methods you used in step 1. The total request body is limited to 128 KiB. For anything larger, or for files whose formatting should be preserved, translate a document instead.

Next steps

You’ve now covered the core text translation workflow: single strings and batches. To keep going: