Magpie 🐦

Hex.pmHexdocsCICoverage StatusLicense: MIT

Elixir client for the Dropbox API v2, built on Req.

Like the bird, Magpie collects and stashes your things — in your Dropbox.

Installation

def deps do
[
{:magpie, "~> 0.3"}
]
end

No configuration is required. Endpoint URLs and extra Req options can be set with config :magpie, ... — see the Magpie module docs.

Quick start

# A refresh token keeps the client working indefinitely — Magpie mints
# access tokens as needed (see the OAuth guide)
client =
Magpie.Client.new(
refresh_token: System.fetch_env!("DROPBOX_REFRESH_TOKEN"),
app_key: System.fetch_env!("DROPBOX_APP_KEY"),
app_secret: System.fetch_env!("DROPBOX_APP_SECRET")
)
# For a quick script, a static access token works too (Dropbox expires it in ~4h)
client = Magpie.Client.new("DROPBOX_ACCESS_TOKEN")
{:ok, account} = Magpie.Users.current_account(client)
{:ok, %{"entries" => entries}} = Magpie.Files.ListFolder.list_folder(client, "/Photos")
{:ok, metadata} = Magpie.Files.upload_file(client, "/Backup/report.pdf", "priv/report.pdf")
{:ok, %{body: contents}} = Magpie.Files.download(client, "/Backup/report.pdf")

Every call returns {:ok, result} on success or {:error, %Magpie.Error{}} on API errors — with the HTTP status, Dropbox's error_summary and the full error body.

Features

Documentation

The API reference lives on HexDocs, along with the guides:

Roadmap

Planned work — typed metadata structs, webhooks, a folder watcher, streaming downloads and more — is tracked in ROADMAP.md. Suggestions and PRs are welcome — open an issue.

Development

The test suite runs entirely offline against Req.Test stubs:

mix test # run the suite
mix coveralls # run with coverage report

Origin

Magpie started as a fork of sger/elixir_dropbox, which is no longer maintained. It has since been rewritten on top of Req/Jason with a new offline test suite. Credit and thanks to the original Elixir Dropbox contributors.

License

MIT — see LICENSE.