#spotify #private #api #folders #session #user #add-remove-delete

spotify-private-api

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

2 releases

0.1.1 Oct 14, 2022
0.1.0 Oct 14, 2022

#35 in #folders

MIT and GPL-3.0-only

25KB
569 lines

Spotify Private API for Rust

Supports adding, removing and moving of spotify folders/playlists

Usage

Read the docs at crates.rs

Inspiration


lib.rs:

Spotify private api library

Supports adding, removing and moving of spotify folders/playlists

Examples

use spotify_private_api::Session;

#[tokio::main]
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)
        .await
        .expect("Failed to create session");

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

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

    s.send_changes(&changes)
        .await
        .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}

Dependencies

~7–20MB
~267K SLoC