Crate rspotify

source ·
Expand description

RSpotify is a wrapper for the Spotify Web API, inspired by spotipy. It includes support for all the authorization flows, and helper methods for all available endpoints.


HTTP Client

By default, RSpotify uses the reqwest asynchronous HTTP client with its default TLS, but you can customize both the HTTP client and the TLS with the following features:

  • reqwest: enabling client-reqwest, TLS available:
    • reqwest-default-tls (reqwest’s default)
    • reqwest-rustls-tls
    • reqwest-native-tls
    • reqwest-native-tls-vendored
  • ureq: enabling client-ureq, TLS available:
    • ureq-rustls-tls (ureq’s default)
    • ureq-rustls-tls-native-certs (rustls with OS root certificates)

If you want to use a different client or TLS than the default ones, you’ll have to disable the default features and enable whichever you want. For example, this would compile RSpotify with reqwest and the native TLS:

rspotify = {
    version = "...",
    default-features = false,
    features = ["client-reqwest", "reqwest-native-tls"]

maybe_async internally enables RSpotify to use both synchronous and asynchronous HTTP clients. You can also use ureq, a synchronous client, like so:

rspotify = {
    version = "...",
    default-features = false,
    features = ["client-ureq", "ureq-rustls-tls"]


reqwest supports system proxies by default. It reads the environment variables HTTP_PROXY and HTTPS_PROXY environmental variables to set HTTP and HTTPS proxies, respectively.

Environmental variables

RSpotify supports the dotenv crate, which allows you to save credentials in a .env file. These will then be automatically available as environmental values when using methods like Credentials::from_env.

rspotify = { version = "...", features = ["env-file"] }

CLI utilities

RSpotify includes basic support for Cli apps to obtain access tokens by prompting the user, after enabling the cli feature. See the Authorization section for more information.

Getting Started


All endpoints require app authorization; you will need to generate a token that indicates that the client has been granted permission to perform requests. You can start by registering your app to get the necessary client credentials. Read the official guide for a detailed explanation of the different authorization flows available.

RSpotify has a different client for each of the available authentication flows. They may implement the endpoints in BaseClient or OAuthClient according to what kind of flow it is. Please refer to their documentation for more details:

In order to help other developers to get used to rspotify, there are public credentials available for a dummy account. You can test rspotify with this account’s RSPOTIFY_CLIENT_ID and RSPOTIFY_CLIENT_SECRET inside the .env file for more details.


There are some available examples on the GitHub repository which can serve as a learning tool.



  • Synchronization primitives that have both synchronous and asynchronous variants under the same interface.


  • Create a HashSet from a list of &str to easily create scopes for Token or OAuth.




Type Aliases