Music recommendations
async function createRecommendationPlaylist(userid, genre, recentlyPlayed, mostPlayed, likedTracks, currentlyPlaying, useAudioFeatures, useTrackSeeds, targetValues){ try{ const recommendations = await vibify.createRecommendationPlaylist(userid, genre, recentlyPlayed, mostPlayed, likedTracks, currentlyPlaying, useAudioFeatures, useTrackSeeds, targetValues); console.log('Recommendations:', recommendations); } catch (error) { console.error('Error:', error); }}
createRecommendationPlaylist('user-id', 'pop', true, true, true, false, true, false, {danceability: 0.8, energy: 0.8, valence: 0.8});
Or with cURL:
curl -s -X POST -H "Content-Type: application/json" -H "x-api-key: (your api key)" -d "{\"id\":\"(your user id)\", \"genre\":\"pop\", \"recentlyPlayed\":true, \"mostPlayed\":true, \"likedTracks\":true, \"currentlyPlaying\":false}" "http://localhost:3000/recommendations"
Target Values Learn more about the target values object
Parameters
Default parameters for the createRecommendationPlaylist
function:
- userId: No default value.
required
- genre: Default value is
null
.optional
- recentlyPlayed: Default value is
false
.optional
- mostPlayed: Default value is
true
.optional
- likedTracks: Default value is
true
.optional
- currentlyPlaying: Default value is
false
.optional
- useAudioFeatures: Default value is
true
.optional
- useTrackSeeds: Default value is
false
.optional
- targetValues: Default value is an empty object
{}
.optional
Response
{ "collaborative":false, "description":"", "external_urls":{ "spotify":"https://open.spotify.com/playlist/1RGP8n0xlmMmDpRuMjwwEu" }, "followers":{ "href":null, "total":0 }, "href":"https://api.spotify.com/v1/playlists/1RGP8n0xlmMmDpRuMjwwEu", "id":"1RGP8n0xlmMmDpRuMjwwEu", "images":[ { "height":640, "url":"https://mosaic.scdn.co/640/ab67616d00001e02232711f7d66a1e19e89e28c5ab67616d00001e02299d4954099bcfceb1d29ea9ab67616d00001e02810706724bf310ae6630e82dab67616d00001e0285ca00029c70d6b5b8372e96", "width":640 }, { "height":300, "url":"https://mosaic.scdn.co/300/ab67616d00001e02232711f7d66a1e19e89e28c5ab67616d00001e02299d4954099bcfceb1d29ea9ab67616d00001e02810706724bf310ae6630e82dab67616d00001e0285ca00029c70d6b5b8372e96", "width":300 }, { "height":60, "url":"https://mosaic.scdn.co/60/ab67616d00001e02232711f7d66a1e19e89e28c5ab67616d00001e02299d4954099bcfceb1d29ea9ab67616d00001e02810706724bf310ae6630e82dab67616d00001e0285ca00029c70d6b5b8372e96", "width":60 } ], "name":"Recommendations", "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":"Myw3MTEyMGYzODdmZGJkOTg3YmVlNTIyOWUzZTkwOTEyY2I1YTA2YjIw", "tracks":{ "href":"https://api.spotify.com/v1/playlists/1RGP8n0xlmMmDpRuMjwwEu/tracks?offset=0&limit=100", "items":[ [ "Object" ], [ "Object" ], [ "Object" ] ], "limit":100, "next":null, "offset":0, "previous":null, "total":50 }, "type":"playlist", "uri":"spotify:playlist:1RGP8n0xlmMmDpRuMjwwEu"}