Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using DeepL API to translate text

Is there any possibility to find out if the DeepL translator offers an API for the translation? Unfortunately I haven't found any information on this.

Would like to implement this to an Excel script for auto translation. I've already tried it with Google (like https://translate.google.com/#en/es/Hello%20World) but DeepL seems more accurate.

like image 430
dontbyteme Avatar asked Aug 29 '17 11:08

dontbyteme


People also ask

How do you translate using DeepL?

Click the DeepL icon next to your text or paragraph for an instant translation. Free users can translate selected texts while browsing the web. Highlight the desired section and instantly translate it into your desired language. Once you highlight the text, the DeepL icon will appear.

Is DeepL API free?

With the DeepL API Free plan, you can translate up to 500,000 characters per month for free. For more advanced use cases, the DeepL API Pro plan allows unlimited translation with usage-based pricing, maximum data security, and prioritized execution of translation requests.

Why is DeepL so much better than Google Translate?

The most significant difference between the two is the language data each tool is trained on. DeepL Translator draws from Linguee's massive corpus of manually translated sentences, idioms, and text snippets. Google Translate, on the other hand, uses a mix of digital resources in various languages.


2 Answers

The REST API is finally (commercially) available, see the API reference documentation.

A sample request would be

https://api.deepl.com/v1/translate?text=Hello%20World!&target_lang=EN&auth_key=XXX

where XXX is the authentication key you need to register with DeepL.

like image 122
dontbyteme Avatar answered Oct 10 '22 09:10

dontbyteme


There is a POST call that allows you get the translations, I don't know how many time this will be supported or it's times limitations but here it is:

Url: https://www.deepl.com/jsonrpc

You should make a POST call with the next json:

{
        'jsonrpc': '2.0',
        'method': 'LMT_handle_jobs',
        'params': {
            'jobs': [
                {
                    'kind':'default',
                    'raw_en_sentence': TEXT_TO_TRANSLATE
                }
            ],
            'lang': {
                'user_preferred_langs': [
                    FROM_LANGUAGE,
                    TO_LANGUAGE
                ],
                'source_lang_user_selected': FROM_LANGUAGE,
                'target_lang': TO_LANGUAGE
            },
            'priority': -1
        },
}

The available languages are:

auto  Auto detect
DE    German
EN    English
FR    French
ES    Spanish
IT    Italian
NL    Dutch
PL    Polish

TO_LANGUAGE must be a valid language and FROM_LANGUAGE can be a valid language or auto

I wrote a python module that wraps this API: pydeepl There are currently also a node package and a php client that accomplish the same goal.

like image 45
EmilioK Avatar answered Oct 10 '22 09:10

EmilioK