This Python script allows users to retrieve their Spotify library data, including saved albums, liked songs, and playlists using the Spotify Web API.
- Retrieve saved albums
- Fetch liked songs
- List user playlists
- OAuth 2.0 authentication with Spotify
- Python 3.7+
requests
library- Spotify Developer Account
- Registered Spotify Application
Install the required Python library:
pip install requests
- Create a new application at the Spotify Developer Dashboard
- Obtain your:
- Client ID
- Client Secret
- Redirect URI
This script follows the Spotify Authorization Code Flow:
- Generate an authorization URL
- User logs in and grants permissions
- Receive authorization code
- Exchange code for access token
- Make API requests with the token
Replace the following variables in the script:
CLIENT_ID
: Your Spotify application's client IDCLIENT_SECRET
: Your Spotify application's client secretREDIRECT_URI
: Your registered redirect URI
- Authorize the application by opening the generated authorization URL
- Copy the authorization code from the redirected URL
- Replace
auth_code
with your received code - Run the script
- Never commit sensitive information like client secrets to version control
- Use environment variables or a configuration file to store credentials
- Rotate your Spotify application credentials periodically
user-library-read
: Access user's saved albums and liked songsplaylist-read-private
: Read user's private playlistsuser-read-private
: Access user's private profile informationuser-read-email
: Read user's email address
- Ensure valid credentials and active internet connection
- Check Spotify API response status for potential errors
- Access token expires after a short period
- Requires manual token refresh
Contributions, issues, and feature requests are welcome!
This project is licensed under the MIT License. See the LICENSE file for details.