Expand description
Provides a lightweight wrapper for the DeepL Pro REST API.
If you are looking for the deepl
commandline utility, 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.
- Glossary
- Representation of a glossary.
- Glossary
Listing - Language
Information - Information about a single language.
- Translatable
Text List - Holds a list of strings to be translated.
- Translated
Text - Holds one unit of translated text.
- Translation
Options - Custom flags for the translation request.
- Usage
Information - Information about API usage & limits for this account.
Enums§
- Error
Kind - The kind of an error.
- Formality
- Translation option that controls the desired translation formality.
- Glossary
Entries Format - Format of glossary entries when creating a glossary.
- Split
Sentences - Translation option that controls the splitting of sentences before the translation.
Traits§
- Result
Ext - Additional methods for
Result
, for easy interaction with this crate.
Type Aliases§
- Language
List - Information about available languages.
- Result
- Convenient wrapper around
std::Result
.