A command-line tool to authenticate with the Spotify Web API using the PKCE flow (no client secret required), fetch saved tracks, and (formerly) analyze audio features to create playlists based on user mood.
The project was designed to:
- Analyze the audio features (like energy, danceability, valence, etc.) of a user's saved tracks
- Detect a rough estimate of the user’s current mood or musical taste
- Automatically generate a playlist tailored to that mood
- Authenticates via PKCE flow (no need to store client secret)
- Stores and refreshes access/refresh tokens securely
- Fetches:
- User profile data
- Saved songs
- (Previously) audio features for tracks
This project has been discontinued due to the deprecation of Spotify’s audio-features endpoint, which was essential for mood-based playlist generation.
The code still works for basic authentication and fetching user data, and may be useful as a reference for:
- Implementing PKCE with
requests - Manually handling access/refresh tokens
- Interacting with REST APIs via Python
auth(): Starts PKCE login flowstoreTokens() / getTokens(): Handles saving/loading tokensrefreshAccessToken(): Refreshes expired access tokengetAllSavedTracks(): Fetches all liked/saved tracksgetAudioFeaturesWithIds(): (⚠️ Deprecated)
- No external Spotify SDK used — built purely with
requestsandpkce - Tokens are stored at:
~/.config/spotify-cli/tokens.txt - Custom redirect URI:
https://krishs-site.netlify.app/test
This project helped me understand:
- OAuth2 PKCE authentication flow
- Manual API calls without SDKs
- Token storage and refresh logic
- Spotify Web API structure
requestspkcewebbrowserurllib.parsepathlib
While the mood-based playlist generator idea couldn’t be fully realized due to API limitations, this repo stands as a useful reference for future CLI and API-based experiments.
Made by Krishanth — 2025