Deepl (deepl v0.1.2)

View Source

An Elixir package providing a convenient interface to the DeepL API.

Summary

Functions

Get the base URL for the DeepL API based on the current plan.

Get the API key from the application environment.

Gets the current plan of the DeepL API based on the API key.

Sets the API key for the DeepL service.

Functions

base_url!()

(since 0.1.0)
@spec base_url!() :: String.t()

Get the base URL for the DeepL API based on the current plan.

Returns the base URL for the DeepL API, which varies depending on whether the user has a free or pro plan.

Examples

iex> Deepl.base_url!()
"https://api-free.deepl.com"

get_api_key()

(since 0.1.0)
@spec get_api_key() :: String.t() | nil

Get the API key from the application environment.

Retrieves the API key set in the application configuration.

Examples

iex> Deepl.get_api_key()
"wwwwwwww-xxxx-yyyy-zzzz-123456789012:fx"

plan!()

(since 0.1.0)
@spec plan!() :: :free | :pro | Exception.t()

Gets the current plan of the DeepL API based on the API key.

Returns :free for free accounts and :pro for pro accounts.

Examples

iex> Deepl.plan!()
:free

set_api_key(key)

(since 0.1.0)
@spec set_api_key(String.t()) :: :ok

Sets the API key for the DeepL service.

Stores the API key string in the application environment.

Examples

iex> Deepl.set_api_key("wwwwwwww-xxxx-yyyy-zzzz-123456789012:fx")
:ok