While I was working on the project, I couldn’t find desired Spotify API calls. At that time I was looking for the following:

1) Search function which will deliver Artist Name, song name, song ID, external URL is handy to listen for a whole song, explicit has two values True or False, preview gives you 30 seconds to listen a song and a cover image for the specific song.

2) All of the above plus the audio features for the searched songs. Audio features contain acousticness, danceability, energy, instrumentalness, key, liveness etc. The audio features can be used to create visualizations and to predict similar songs.

3) Also I was requested to create a predicting model in order to get the desired amount of similar songs. The model had to use audio features to suggest similar songs.

All of the results had to be in a nice readable json format for the backend team to use.

Register Spotify for Developers account

Before getting into the code you have to register an account at Spotify for Developer and create an app in order to get Client ID and Client Secret keys. In edit settings add Redirect URIs. I added http://127.0.0.1:5000/callback/ and https://sp-search.herokuapp.com/callback/.

Note: You need to change URIs to your own localhost and to the host you will deploy your APIs to.

By the end of the project I created 3 API. First API searches for a track, second searches for a track and provides 10 tracks along with audio features, third gives 4 the most related songs to the desired one depending on the audio features using K-Nearest Neighbor. I used Heroku to deploy the API then shared it with the backend team.

You can find full code here

To be continued

var foo = function(x) {
  return(x + 5);
}
foo(3)