Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create Spotify Playlist with Artwork
// initialize axios instance
let spotify = axios.create({
baseURL: 'https://api.spotify.com',
headers: {
'Authorization': `Bearer ${token}`
}
})
// get user id for playlist creation
spotify.get('/v1/me').then(res => {
let userId = res.data.id
// create playlist
spotify.post(`/v1/users/${res.data.id}/playlists`, {
name: "Chris Cornell at City Park on Oct 28, 2011"
}).then(res => {
let playlistId = res.data.id
// add tracks to playlist
spotify.post(`/v1/playlists/${playlistId}/tracks?uris=${ids}`).then(res => {
// add artwork to playlist
spotify.put(`/v1/playlists/${playlistId}/images`, canvas.toDataURL('image/jpeg').replace('data:image/jpeg;base64,', ''), {
headers: {
'Content-Type': 'image/jpeg'
},
})
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.