Skip to main content
These proxies are intended for prototyping and frontend testing. For production environments, consider implementing your own backend service with additional security measures and rate limiting.

Rationale

The DeepL API does not permit calls from client-side JavaScript - that is, from JavaScript running in a browser. This policy exists to keep your API key safe. When you place a call from your website directly to the DeepL API, that call needs to include your API key. Anyone using your website could look at the network calls or your code itself, find your API key, and use it themselves. For this and other security considerations, DeepL does not enable the CORS headers you would need to call the API from a webpage hosted on your origin. The industry-standard approach is to call APIs like DeepL’s from a back-end service. DeepL enforces this best practice to keep your credentials secure.

When to use a quick proxy

But what do you do if you want to use the API quickly, in a prototype, a demo, or a hackathon, where you need to get up and running fast? What if you don’t have easy access to a server? For such situations, here are two solutions.

Node.js Proxy Server

GitHub - DeepLcom/deepl-api-nodejs-proxy

DeepL API Node.js Proxy on GitHub
This full-featured proxy server supports all DeepL API endpoints, including text translation, document translation, and glossaries. Built with Node.js and Express with minimal dependencies, it handles CORS headers for you and keeps your API key secure. It even includes an interactive web demo for testing translations right in your browser. This proxy includes an interactive setup wizard to get you started quickly. Clone the repo, run the setup, and start sending requests from your browser. Check out the GitHub repository for full setup instructions and Docker support.

Quick & dirty PHP proxy

If you’re just using our /translate endpoint and want an even quicker solution, or if you don’t use node.js, you could use the PHP code below to create an instant proxy server. If PHP is not already installed on your machine, you can download and install it at php.net. The PHP script takes the parameters in the query string and passes them into a POST request to /translate. It does not check that the parameters are valid and does not support any other endpoints, although you could modify it to do so. To use this while developing on your local machine:
  • replace {your API key here} with your actual API key
  • create a file in your favorite directory with the PHP code below
  • go to your terminal and visit that directory
  • type php -S localhost:8000
Your JavaScript can then access the DeepL API at http://localhost:8000/php-proxy.php. For example, to send a translation request with text and target_lang:
const url = `http://localhost:8000/deepl-proxy.php?text=${encodeURIComponent(text)}&target_lang=${encodeURIComponent(targetLang)}`;
const response = await fetch(url);
const result = await response.text();
Here is the PHP script:
<?php
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');

$apiKey = '{your API key here}';
$apiUrl = 'https://api.deepl.com/v2/translate';

$data = http_build_query($_GET);

$context = stream_context_create([
  'http' => [
      'method' => 'POST',
      'header' => "Authorization: DeepL-Auth-Key " . $apiKey . "\r\n" .
                  "Content-Type: application/x-www-form-urlencoded\r\n",
      'content' => $data
  ]
]);

echo file_get_contents($apiUrl, false, $context);
?>

Screenshots

Node.js proxy

Node.js proxy server running and ready to accept requests
Interactive web demo interface for testing translations

PHP proxy