spotify2csv

raw JSON →
0.4.2 verified Sat May 09 auth: no python

A Python library to convert Spotify URLs (tracks, playlists, albums) into CSV files containing track info like name, artist, and album. Current version: 0.4.2. Release cadence: infrequent.

pip install spotify2csv
error spotipy.exceptions.SpotifyException: http status: 401, code: -1 - code: 401, ...
cause Invalid or missing Spotify API credentials.
fix
Check that SPOTIFY_CLIENT_ID and SPOTIFY_CLIENT_SECRET are set correctly and the app is registered.
error AttributeError: module 'spotify2csv' has no attribute 'Spotify2CSV'
cause Incorrect import pattern (import spotify2csv instead of from spotify2csv import Spotify2CSV).
fix
Use 'from spotify2csv import Spotify2CSV'.
error TypeError: __init__() missing 2 required positional arguments: 'client_id' and 'client_secret'
cause Instantiated Spotify2CSV() without arguments.
fix
Pass client_id and client_secret: Spotify2CSV('your_id', 'your_secret').
breaking Requires a Spotify Developer account and valid client_id/client_secret. Without these, all methods will raise an error.
fix Create an app at https://developer.spotify.com/dashboard and set environment variables SPOTIFY_CLIENT_ID and SPOTIFY_CLIENT_SECRET.
gotcha CSV file path must be writable; if the file exists, it will be overwritten without warning.
fix Ensure the output directory exists and the file is not opened elsewhere.
gotcha The library does not support track IDs; you must provide full URLs (e.g., https://open.spotify.com/track/...).
fix Use the URL format as shown in the Spotify share menu.

Initialize with Spotify API credentials, then call one of the conversion methods: track_to_csv, playlist_to_csv, album_to_csv.

from spotify2csv import Spotify2CSV
import os

client_id = os.environ.get('SPOTIFY_CLIENT_ID')
client_secret = os.environ.get('SPOTIFY_CLIENT_SECRET')

s2c = Spotify2CSV(client_id, client_secret)
# Convert a Spotify playlist URL to CSV
s2c.playlist_to_csv('https://open.spotify.com/playlist/37i9dQZF1DXcBWIGoYBM5M', 'playlist.csv')