spotify-recommender-api

raw JSON →
5.4.5 verified Sat May 09 auth: no python deprecated

Generates song recommendations for Spotify playlists using K-Nearest-Neighbors and optionally VADER sentiment analysis. Version 5.4.5 is the final release; the library has been deactivated due to Spotify API changes in 2025. No longer maintained.

pip install spotify-recommender-api==5.4.5
error AttributeError: module 'spotify_recommender_api' has no attribute 'SpotifyAPI'
cause Importing the package directly instead of the class.
fix
Use: from spotify_recommender_api import SpotifyAPI
error spotipy.exceptions.SpotifyException: http status: 403, code:-1 - Forbidden
cause The playlist is private or the token lacks required scopes (playlist-read-private).
fix
Authenticate with scope='playlist-read-private' and ensure the playlist is accessible by the user.
error ModuleNotFoundError: No module named 'vadersentiment'
cause VADER sentiment is an optional dependency not installed by default.
fix
Install it: pip install vadersentiment
deprecated Library is deprecated and no longer maintained. Spotify API changes in May 2025 broke core endpoints; recommendations may fail or return empty results.
fix Consider migrating to official Spotify Web API via spotipy library directly.
breaking Authentication flow changed in v5.2.0: token refreshing is now automatic. Old code that manually refreshes tokens may cause duplicate calls or errors.
fix Upgrade to >=5.2.0 and remove manual token refresh logic.
gotcha The 'recommend_songs' method requires a playlist ID from a public or collaborative playlist; private playlists will cause a 403 error silently.
fix Ensure the playlist is public or use your own authorized user's playlist with proper scopes.

Authenticate with Spotify and get song recommendations for a given playlist.

from spotify_recommender_api import SpotifyAPI

api = SpotifyAPI(
    client_id='YOUR_CLIENT_ID',
    client_secret='YOUR_CLIENT_SECRET',
    redirect_uri='http://localhost:8888/callback'
)

# Authenticate and get token
api.authenticate()

# Get recommendations based on a playlist ID
playlist_id = 'your_playlist_id'
recommendations = api.recommend_songs(playlist_id, count=10)
for song in recommendations:
    print(song['name'], song['artists'])