While I have experience writing small programs that run in the command line, I've realized that I have no experience making web applications and as we're moving towards a more browser-based world, learning about APIs and app development may be beneficial. Plus, I like music and wanted to see if there was any interesting statistics I could learn about my music from the Spotify API. (It's worth noting that before this project I messed around a little bit with NodeJS)
This application was written in Javascript, due to the web-based nature. To create this web app, I decided to use Node.js (express), and axios.
While I didn't have a clear vision for this project at the beginning, and I arguably still don't, I knew that I wanted to be able to make an API call through the Spotify API to see what song the user logged in through the app was currently listening to. To gain access to the user's account and use the Spotify API, I had to go through their authorization system. This requires the utilization of a client secret and a client ID, both of which are given through the Spotify for Developers client. The client ID is included in the URL that redirects the user to Spotify log in, along with the correct scope for accessing the relevant data.
The client ID and client secret had to be combined, separated by a colon, and then converted to Base64. This was passed to a Spotify API call which returns a token that grants access to other Spotify API's.
Through the use of this token I made two other API calls. One to receive the data of the song currently playing by the logged-in user, and one to receive user data. The song data is rendered to the HTML index file through a try-catch block, by using the EJS view engine, and I have yet to explore the user data.
Below is an example of what the user sees when using the platform