#spotify #private


Spotify private api for rust, add/remove/delete folders

2 releases

0.1.1 Oct 14, 2022
0.1.0 Oct 14, 2022

#641 in Audio

MIT and GPL-3.0-only

569 lines

Spotify Private API for Rust

Supports adding, removing and moving of spotify folders/playlists


Read the docs at crates.rs



Spotify private api library

Supports adding, removing and moving of spotify folders/playlists


use spotify_private_api::Session;

async fn main() {
    let dc = "SP_DC".to_string();
    let key = "SP_KEY".to_string();
    let user_id = "USER_ID".to_string();

    let s = Session::new(&dc, &key, &user_id)
        .expect("Failed to create session");

    let root_list = s.get_root_list()
        .expect("failed to get root list");

    let changes = root_list
        .add("New Folder", &root_list.generate_folder_uri(), 0, 2)

        .expect("failed to send changes");

How to generate dc and key (valid for 1 year)

  • Open a new Incognito window in your browser at and login to spotify
  • Open Developer Tools in your browser (might require developer menu to be enabled in some browsers)
  • In the Network tab, enable "Preserve log"
  • Login to Spotify.
  • In the Network tab, search/Filter for password
  • Under cookies for the request save the values for sp_dc and sp_key.
  • Close the window without logging out (Otherwise the cookies are made invalid).

How to get your user id

  • Click on your account name at the top right corner in the spotify web player
  • Choose Profile
  • The last part of the link is your user id, e.g: https://open.spotify.com/user/{user_id}


~293K SLoC