[][src]Crate deepl_api

Provides a lightweight wrapper for the DeepL Pro REST API.

If you are looking for the deepl commandline utitlity, please refer to its documentation instead.

Requirements

You need to have a valid DeepL Pro Developer account with an associated API key. This key must be made available to the application, e. g. via environment variable:

export DEEPL_API_KEY=YOUR_KEY

Example

use deepl_api::*;

// Create a DeepL instance for our account.
let deepl = DeepL::new(std::env::var("DEEPL_API_KEY").unwrap());

// Translate Text
let texts = TranslatableTextList {
    source_language: Some("DE".to_string()),
    target_language: "EN-US".to_string(),
    texts: vec!("ja".to_string()),
};
let translated = deepl.translate(None, texts).unwrap();
assert_eq!(translated[0].text, "yes");

// Fetch Usage Information
let usage_information = deepl.usage_information().unwrap();
assert!(usage_information.character_limit > 0);

See Also

The main API functions are documented in the DeepL struct.

Structs

DeepL

The main API entry point representing a DeepL developer account with an associated API key.

Error

The Error type.

LanguageInformation

Information about a single language.

TranslatableTextList

Holds a list of strings to be translated.

TranslatedText

Holds one unit of translated text.

TranslationOptions

Custom flags for the translation request.

UsageInformation

Information about API usage & limits for this account.

Enums

ErrorKind

The kind of an error.

Formality

Translation option that controls the desired translation formality.

SplitSentences

Translation option that controls the splitting of sentences before the translation.

Traits

ResultExt

Additional methods for Result, for easy interaction with this crate.

Type Definitions

LanguageList

Information about available languages.

Result

Convenient wrapper around std::Result.