Skip to content

Create a playlist

This method allows you to create a playlist from your liked songs from a specific period (month and year).

async function createPlaylist(userid, month, year){
const playlistName = `Liked Tracks from ${new Date(year, month - 1, 1).toLocaleString('en-US', { month: 'short' })} ${year}.`;
// (Liked songs from Feb 2024.)
try{
const playlist = await vibify.createPlaylist(userid, playlistName, month, year);
console.log('Playlist:', playlist);
} catch (error) {
console.error('Error:', error);
}
}
createPlaylist('user-id', 1, 2024);

The playlistName is optional and will default to Liked Tracks from {month} {year}, as shown in the example above.

Or with cURL:

Terminal window
curl -X POST -H "x-api-key: (your api key)" -d '{"id":"(user id)","month":"12","year":"2023","playlistName":"My Playlist"}' http://localhost:3000/create-playlist

Response

{
"collaborative":false,
"description":"",
"external_urls":{
"spotify":"https://open.spotify.com/playlist/0PIidLSojxO6gH2DuKXVlo"
},
"followers":{
"href":null,
"total":0
},
"href":"https://api.spotify.com/v1/playlists/0PIidLSojxO6gH2DuKXVlo",
"id":"0PIidLSojxO6gH2DuKXVlo",
"images":[
{
"height":640,
"url":"https://mosaic.scdn.co/640/ab67616d00001e02240b168192278ce576efa5aeab67616d00001e0294203dd82d27b494c777d07cab67616d00001e02b84b0516d901f95461bb5165ab67616d00001e02f2c68b5ce1fd32c2533df340",
"width":640
},
{
"height":300,
"url":"https://mosaic.scdn.co/300/ab67616d00001e02240b168192278ce576efa5aeab67616d00001e0294203dd82d27b494c777d07cab67616d00001e02b84b0516d901f95461bb5165ab67616d00001e02f2c68b5ce1fd32c2533df340",
"width":300
},
{
"height":60,
"url":"https://mosaic.scdn.co/60/ab67616d00001e02240b168192278ce576efa5aeab67616d00001e0294203dd82d27b494c777d07cab67616d00001e02b84b0516d901f95461bb5165ab67616d00001e02f2c68b5ce1fd32c2533df340",
"width":60
}
],
"name":"Liked Tracks from Feb 2024.",
"owner":{
"display_name":"your-name",
"external_urls":{
"spotify":"https://open.spotify.com/user/your-name"
},
"href":"https://api.spotify.com/v1/users/your-name",
"id":"your-name",
"type":"user",
"uri":"spotify:user:your-name"
},
"primary_color":null,
"public":true,
"snapshot_id":"Niw3MThjM2JjNjYwODVkNzQ0MmM2YmYxMDYxMzU1NDBjOGQ4Y2RhNTIz",
"tracks":{
"href":"https://api.spotify.com/v1/playlists/0PIidLSojxO6gH2DuKXVlo/tracks?offset=0&limit=100",
"items":[
[
"Object"
],
[
"Object"
],
[
"Object"
]
],
"limit":100,
"next":"https://api.spotify.com/v1/playlists/0PIidLSojxO6gH2DuKXVlo/tracks?offset=100&limit=100",
"offset":0,
"previous":null,
"total":123
},
"type":"playlist",
"uri":"spotify:playlist:0PIidLSojxO6gH2DuKXVlo"
}