Skip to content

These are sample scripts of using DeepL API by Python.

Notifications You must be signed in to change notification settings

michimani/deepl-api-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

deepl-api-sample

These are sample scripts of using DeepL API by Python.

  • Runtime: Python 3.x

Usage

Preparing

Create config.json

Create a config.json by copying config.json.sample .

$ cp config.json.sample config.json
{
  "auth_token": "your-deelpl-api-auth-token"
}

Features

  • translate
  • monitoring usage

translate

$ python3 src/translate.py -h
usage: translate.py [-h] [-m MESSAGE] [-t TARGET] [-s SOURCE]

optional arguments:
  -h, --help            show this help message and exit
  -m MESSAGE, --message MESSAGE
                        text to translate. (Default: Hello World.)
  -t TARGET, --target TARGET
                        target language code (Default: JA). allowed lang code
                        : ['DE', 'EN', 'FR', 'IT', 'JA', 'ES', 'NL', 'PL',
                        'PT-PT', 'PT-BR', 'PT', 'RU', 'ZH']
  -s SOURCE, --source SOURCE
                        source language code (Default: auto). allowed lang
                        code : ['DE', 'EN', 'FR', 'IT', 'JA', 'ES', 'NL',
                        'PL', 'PT', 'RU', 'ZH']

example

$ python3 src/translate.py -m "これは DeepL API のサンプルプログラムです。" -t EN
{
  "translations": [
    {
      "detected_source_language": "JA",
      "text": "This is a sample program for the DeepL API."
    }
  ]
}

monitoring usage

$ python3 src/usage.py
{
  "character_count": 192,
  "character_limit": 1000000
}

About

These are sample scripts of using DeepL API by Python.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages