MastodonClient View Source

Lightweight Elixir HTTP client for Mastodon and Pleroma based on Tesla.


Add mastodon_client, a JSON parser, and an HTTP client to your list of dependencies in mix.exs:

def deps do
    {:mastodon_client, "~> 0.1.0"},

    # Tesla-compatible HTTP client
    {:hackney, "~> 1.18"},

    # Any Tesla-compatible JSON parser
    {:jason, "~> 1.2"}

Tesla's default HTTP adapter is insecure, so you need to configure it to Hackney or something else in config/config.exs:

config :tesla, adapter: Tesla.Adapter.Hackney


Construct a %MastodonClient.Conn{} and pass it to the HTTP functions:

conn =
    instance: "",
    access_token: "OkgdLaYHU8A6Dc70eW7gSfBQzPFpwWI6UfHg2F2zQdM"

MastodonClient.get(conn, "/api/v1/instance")
MastodonClient.get(conn, "/api/v1/accounts/verify_credentials"), "/api/v1/statuses", %{status: "Hello world!"})

That's it. It's a simple wrapper around Tesla and returns a %Tesla.Env{} struct.


mastodon_client is licensed under the MIT license. See for the full text.