Spotify’s Web API is a RESTful API and gives you access to music artists, tracks, albums, public playlists, and user-specific data. The data access depends on the authentication you acquire.
So, I am going to write about acquiring the Authentication and Validation before I get to my project or analysis.
This process is quite similar to Accessing Twitch API or any other RESTful API for that matter.
1. Create an account with Soptify for Developers at https://developer.spotify.com/. Go to your dashboard and register a new app.

2. Enter basic information and the purpose of your app. Once you do this you will get your Client ID and Client Secret.

3. Check out Spotify’s Web API documentation to get a complete understanding of all the authentication flows and endpoints. Or stay tuned as I am going to cover it in my upcoming pieces.

4. Authenticating ourself to get the Access Token
I am using the Client Credentials flow because we do not need any user’s data as of now. Spotify’s Access Token’s last for 3600 seconds i.e. 1 hour.
To authenticate, you need to encode your Client ID and Client Secret in your endpoint request. I am going to write a function that takes care of encoding and the request.
You can call the function and pass the IDs as arguments but hold on. We can write another function directly for the request and call the base64-encode within that.
Now you have your access token. You can directly use the variable access_token in all other endpoint requests.
A sample request looks like this

That’s all for this one. I am going to be writing more and will present some examples of the API. Stay tuned.
2 thoughts on “How to access Spotify API”