An Elixir client library for the Discogs API.
Discogs is the largest crowdsourced music database in the world. ExDisco provides a type-safe, ergonomic interface for querying artists, releases, labels, and user profiles, with support for both personal token authentication and full OAuth 1.0a flows.
- Resource APIs — Query artists, releases, labels, and user profiles
- Global Search — Search across releases, artists, labels, and masters
- Type-Safe — All API responses mapped to Elixir structs with proper typing
- Flexible Authentication — Token-based auth for personal use or OAuth 1.0a for multi-user apps
- Pagination Support — Built-in pagination for large result sets
- Error Handling — Typed error handling with clear error information
Add ex_disco to your dependencies in mix.exs:
def deps do
[
{:ex_disco, "~> 0.1.0"}
]
endExDisco requires a user agent to identify your application:
config :ex_disco, ExDisco,
user_agent: "my_app/1.0.0 (+https://github.com/me/my_app)"Choose one of two authentication methods:
Personal Token — For personal scripts and CLIs:
config :ex_disco, ExDisco,
user_token: "your_personal_token"Get a token at https://www.discogs.com/settings/developers
OAuth 1.0a — For apps acting on behalf of multiple users:
config :ex_disco, ExDisco,
consumer_key: "your_consumer_key",
consumer_secret: "your_consumer_secret"Register your app at https://www.discogs.com/settings/developers
Fetch an artist by ID:
{:ok, %ExDisco.Artists.Artist{} = artist} = ExDisco.Artists.get(1)Fetch a release:
{:ok, %ExDisco.Releases.Release{} = release} = ExDisco.Releases.get(249504)Search for music:
{:ok, results} = ExDisco.Search.query(q: "Thriller", type: :release)
IO.inspect(results.items |> Enum.count())
# 42Handle errors:
case ExDisco.Artists.get(999999999) do
{:ok, artist} -> "Found: #{artist.name}"
{:error, error} -> "Not found: #{error.message}"
end
# "Not found: 404 Not Found"Full API documentation is available at HexDocs.
The documentation is integrated into the code itself via module and function documentation. Start with the modules in this order:
ExDisco.Artists— Query artist informationExDisco.Releases— Query release dataExDisco.Labels— Query label informationExDisco.Search— Global search across all resourcesExDisco.Users— Query user profiles (requires authentication)ExDisco.Auth— Full OAuth 1.0a authentication flowExDisco.Request— Low-level request builder and execution
Contributions are welcome! Please submit a pull request or open an issue on GitHub.
MIT — see LICENSE for details