Consumer Apps
Mood-Based Playlist Generator
Users open Spotify and don't know what to listen to. Generic 'workout' or 'chill' playlists feel stale, and Spotify's editorial picks don't adapt to weather, time of day, or how the user is actually feeling right now.
How the API solves it: Combine /audio_features (energy, valence, danceability) with /recommendations seeded from a user's input mood. Apply weather/time signals server-side to bias the seed selection. Return a 25-track playlist tuned to the moment, not a static genre.
Endpoints used
Architecture & data flow
- User selects a mood (or app reads weather + time of day)
- Map mood to target valence + energy values (e.g. 'cozy rainy night' = valence 0.3, energy 0.2)
- Seed /recommendations with 2 anchor tracks + target_valence + target_energy
- Filter results by /audio_features to keep only tracks within tolerance band
- Return ranked playlist with 30s previews and Open-in-Spotify deep links
Code example
// pseudo-code
const mood = { valence: 0.3, energy: 0.2 };
const recs = await fetch(`/api/spotify/recommendations?seed_tracks=${seed}&limit=50&target_valence=${mood.valence}&target_energy=${mood.energy}`);
const filtered = recs.tracks.filter(t => Math.abs(t.audio_features.valence - mood.valence) < 0.15);
return filtered.slice(0, 25);