I love music, and I practically always have music playing at all hours of the day. Either on my headphones, earphones, or over speakers, I'm constantly playing something. I'm big into music, I go to a lot of concerts, and I'm constantly looking for new artists, too. That's why I decided to build my own program to list my most recently played music and then grab some new recommendations for me that I can listen to in the hopes of discovering something new that I like.
Best wireless earbuds in 2025
In the market for a new pair of truly wireless earbuds? Then read on, because we've compiled a list with some of the best ones out there.
Spotify's robust API is great for finding your recent tracks
Using Python, it was really easy to build a program to retrieve my most played tracks
Spotify has a pretty great, free API that anyone can sign up to and use, and we'll use it for this project to pull my most listened-to tracks in a recent period. Spotify gives you access to collect data from your playback history based on short-term, medium-term, and long-term, which is four weeks, six months, and a year respectively. For this project, we used short-term, though you can modify the code easily by changing the parameters to match what's available in the API.
From there, it's very easy to collect an embed URL, as the track ID can easily be inserted into the Spotify embed template, which follows the format "open.spotify.com/embed/track/
Next, we can create a playlist of recommended songs based on what was played. This uses the Get Recommendations API on Spotify, where we pass "seed tracks" along for Spotify to use in order to find songs that may be similar. You can pass other attributes like "target_acousticness" and "target_danceability," though we simply use seed tracks for the purposes of this program.
Once we've collected the most played recent songs and the recommended songs, we use a Flask server to launch a web page and show off the top tracks and recommended tracks, all embedded on the page in cards. Finally, we then create a playlist using the Create Playlist API with each of the songs and name it "My New Music Recommendations."
If you wanted to expand on it further, you would be able to try and find new recommendations by using services like Deezer or Last FM. Last FM has a free API that anyone can sign up to, and you could then find even more song recommendations that are outside of the typical suggestions that Spotify makes.
Thanks to the number of parameters available to you when trying to find recommendations, you can tune it as much as you'd like to find different kind of songs depending on what you've been listening to.
How I built a Spotify alternative with a Raspberry Pi and Navidrome
Not a fan of Spotify's subscription model? You can use Navidrome to turn your Raspberry Pi into a music-streaming server
Expanding on Spotify's recommendation APIs
Spotify has a great API
Spotify's API is well-documented, easy to use, and there are a lot of options. I use the Spotipy library for most of what I do with Python and Spotify, but you can do just as much in other programming languages, too. You can make simple POST requests to Spotify's API endpoints manually without a library in any other programming language, and you can build a lot of fun projects if you're imaginative enough.
For example, here's a great list of applications that have been built using the Spotify API, so you can imagine the possibilities of what you can do given that all of this has already been done. If you want to check out the application that I built, you can check out my GitHub. The webpage file for it is in /templates, and make sure you keep the project structure the same when you deploy it locally.
There's a lot you can do with Python, and I've built projects like a notification tracker and a cheat for Brotato. It's a very powerful programming language, and projects like this are a lot of fun and can teach you about the services that you use.
