10 releases (6 breaking)

0.7.0 Feb 12, 2023
0.5.0 Dec 4, 2022
0.4.3 Nov 16, 2022
0.4.2 May 11, 2022
0.2.0 Jan 20, 2021

#2197 in Web programming

Download history 102/week @ 2023-11-25 61/week @ 2023-12-02 73/week @ 2023-12-09 79/week @ 2023-12-16 69/week @ 2023-12-23 69/week @ 2023-12-30 76/week @ 2024-01-06 67/week @ 2024-01-13 74/week @ 2024-01-20 134/week @ 2024-01-27 74/week @ 2024-02-03 85/week @ 2024-02-10 99/week @ 2024-02-17 141/week @ 2024-02-24 105/week @ 2024-03-02 110/week @ 2024-03-09

469 downloads per month
Used in rescrobbled

MIT license

44KB
874 lines

listenbrainz

Crate Documentation CI builder License

ListenBrainz API bindings for Rust.

There is also listenbrainz-rust. However, that crate only supports single listens, imports and now playing requests, and is also not maintained anymore. This crate, on the other hand, aims to be a complete API wrapper for the ListenBrainz API, version 1.


lib.rs:

API bindings for ListenBrainz.

This crate aims to be an idiomatic wrapper of the ListenBrainz HTTP API (version 1). It contains functionality for direct access to the API in the [raw] module, as well as a more convenient ListenBrainz client which is easier to use.

Generally, using the raw functionality is more cumbersome, as its types and functions map one-to-one to the HTTP API's JSON input- and response data. Using the ListenBrainz type is therefore recommended.

Example

Submit a currently playing song to ListenBrainz.org:

#
let mut client = ListenBrainz::new();

client.authenticate("LISTENBRAINZ TOKEN")
    .expect("Could not authenticate with ListenBrainz");

client.playing_now("The Beatles", "Here Comes the Sun", Some("Abbey Road"))
    .expect("Could not submit 'playing now' request");

Use a custom API URL, for example to submit songs to Maloja:

#
let mut client = ListenBrainz::new_with_url("http://maloja.example.com/apis/listenbrainz");

client.authenticate("MALOJA API KEY")
    .expect("Could not authenticate with Maloja");

client.listen("Lymbyc Systym", "Split Stones", None)
    .expect("Could not submit listen");

Dependencies

~2.7–4MB
~106K SLoC