Spotify has a free Web API with generous rate limits.
Spotify Web API
// Get access token (client credentials flow)
async function getSpotifyToken(clientId, clientSecret) {
const res = await fetch("https://accounts.spotify.com/api/token", {
method: "POST",
headers: {
"Authorization": "Basic " + btoa(clientId + ":" + clientSecret),
"Content-Type": "application/x-www-form-urlencoded"
},
body: "grant_type=client_credentials"
});
const data = await res.json();
return data.access_token;
}
// Search tracks
async function searchTracks(query, token) {
const url = `https://api.spotify.com/v1/search?q=${encodeURIComponent(query)}&type=track&limit=10`;
const res = await fetch(url, {
headers: { "Authorization": "Bearer " + token }
});
const data = await res.json();
return data.tracks.items.map(t => ({
name: t.name,
artist: t.artists[0].name,
album: t.album.name,
popularity: t.popularity,
preview: t.preview_url
}));
}
Data Available
- Track name, artist, album
- Popularity score (0-100)
- Audio features (tempo, energy, danceability)
- Playlist tracks and followers
- Artist top tracks and related artists
Use Cases
- Music market research
- Playlist curation tools
- Artist analytics
- Trend detection
- Content recommendation
Resources
Need music or entertainment data? $20. Email: Spinov001@gmail.com | Hire me
Top comments (0)