
spotify-rs
spotify-rs is a Rust library for the Spotify Web API,
offering full API coverage.
It was created with the goal of safety and compile-time correctness, encouraging intuitive correct usage
of the Spotify API.
Over time, the target has also become providing a transparent interface over the actual API, while
at the same time improving the areas where the Spotify API is awkward and inconsistent.
Usage example:
use spotify_rs::{AuthCodeClient, RedirectUrl};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let scopes = vec![
"user-read-private",
"playlist-modify-public",
"playlist-modify-private",
"playlist-read-private",
"playlist-read-collaborative",
];
let redirect_uri = RedirectUrl::new("your_redirect_url".to_owned())?;
let auto_refresh = true;
let (client, url) = AuthCodeClient::new(
"client_id",
"client_secret",
scopes,
redirect_uri,
auto_refresh,
);
let spotify = client.authenticate("auth_code", "csrf_state").await?;
let album = spotify_rs::album("album_id").get(&spotify).await?;
println!("The name of the album is: {}", album.name);
let album_gb = spotify_rs::album("album_id")
.market("GB")
.get(&spotify)
.await?;
println!("The popularity of the album is {}", album_gb.popularity);
let user_playlists = spotify_rs::current_user_playlists()
.limit(5)
.get(&spotify)
.await?;
let result_count = user_playlists.items.len();
println!("The API returned {} playlists.", result_count);
Ok(())
}
You can find more examples in the examples directory.
Detailed information is available in the API documentation.
License
spotify-rs is dual-licensed under Apache 2.0 and MIT terms.