Packages

A Last.fm API client for Elixir.

Current section

Files

Jump to
lastex lib lastex.ex
Raw

lib/lastex.ex

defmodule Lastex do
@moduledoc """
A Last.fm API client for Elixir.
Each Last.fm API namespace has its own module: `Lastex.Album`,
`Lastex.Artist`, `Lastex.Chart`, `Lastex.Geo`, `Lastex.Library`,
`Lastex.Tag`, `Lastex.Track`, and `Lastex.User`. Authentication lives in
`Lastex.Auth`.
Every function returns `{:ok, result}` or `{:error, %Lastex.Error{}}`. List
endpoints return a `Lastex.Page` carrying the data and pagination counts.
Configure your credentials before making any call:
config :lastex,
api_key: System.get_env("LASTFM_API_KEY"),
api_secret: System.get_env("LASTFM_API_SECRET")
"""
@doc """
Returns the configured API key.
Raises if `:api_key` is not configured.
"""
def api_key do
Application.fetch_env!(:lastex, :api_key)
end
@doc """
Returns the configured API secret.
Raises if `:api_secret` is not configured. The secret is only needed for
signed and authenticated calls.
"""
def api_secret do
Application.fetch_env!(:lastex, :api_secret)
end
end