FritzApi v2.0.0-rc.0 FritzApi.Client View Source

A FritzApi API Client

Link to this section Summary

Functions

Authenticate with the FritzApi API using the name and password of the user.

Creates a new FritzApi API client.

Link to this section Types

Specs

t() :: %FritzApi.Client{
  base_url: String.t(),
  session_id: FritzApi.session_id(),
  tesla_client: Tesla.Client.t()
}

Link to this section Functions

Link to this function

login(client, username, password)

View Source

Specs

login(t(), String.t(), String.t()) :: {:ok, t()} | {:error, FritzApi.Error.t()}

Authenticate with the FritzApi API using the name and password of the user.

A valid session ID is required in order to interact with the FritzBox API.

Each application should only acquire a single session ID since the number of sessions to a FritzBox is limited.

In principle, each session ID has a validity of 60 Minutes whereby the validity period gets extended with every access to the API. However, if any application tries to access the API with an invalid session ID, all other sessions get terminated.

Examples

iex> {:ok, client} = FritzApi.Client.new()
...>                 |> FritzApi.Client.login(username, password)
{:ok, %FritzApi.Client{}}

Specs

new(Keyword.t()) :: t()

Creates a new FritzApi API client.

Options

  • :base_url - the base URL for all endpoints (default: http://fritz.box)
  • :adapter - the Tesla adapter for the API client (default: {Tesla.Adapter.Hackney, [pool: :default]})
  • :session_id - a session ID (see FritzApi.get_session_id/3)

Examples

iex> client = FritzApi.Client.new()
%FritzApi.Client{}