Recently, I got started working on a new project that I’ve been meaning to work on for quite some time. The whole purpose of this project was to create a new Twitch extension that would, if available, display your currently playing song as well as a few previously played songs. I would get this information via Last.FM.
Last.FM is a scrobbling service for your music. Essentially, what it does is it connects either directly to your Spotify account or it analyzes the media playing on your device of choice to help catalogue all of the music that you’ve listened to. Think of it similar to how Spotify does their “Spotify Wrapped” event at the end of every year to recap your music taste. Last.FM essentially does this, but whenever you want the information.
A long standing issue.
Now, this isn’t my first time utilizing Last.FM’s API. Back in the very end of 2022, like the very very end… like December 31st of 2022, I had made a widget for streamers that would allow them to display their currently playing song when it changes. Just like what I’m trying to do now, I used the Last.FM API to fetch this information.
And it worked fine almost the entire time. The problem was, occasionally it would display the incorrect song. I initially thought this was just a skill issue and I somehow managed to screw things up, until I realized that occasionally the song it would display, I had never listened to ever. It was a difficult problem to troubleshoot because of how inconsistent the issue was, but it was still consistent enough that it became an issue that I needed to fix.
After some rigorous troubleshooting, I found out that occasionally the Last.FM API will simply return the information for the wrong user. And apparently, even to this day, this is still a long standing issue that hasn’t been fixed.
Check out this website. This is an unofficial website that (arguably, better) documents the Last.FM API and the issues that can occur when using it, and one of the four bugs that are on a dedicated page, talks about how the API can sometimes just return data from a completely different user.
And this isn’t the only place where people have complained about this, you can see threads on Reddit, and even Last.FM’s own support forum of people complaining about this specific issue.
- Reddit - the (sad) state of last.fm for developers
- Last.FM Support Forums - API sometimes returning data for different users
Now, you may notice that in the support forums, supposedly a fix for this was released. I, personally, cannot confirm nor deny if this is the case anymore, but I’ve still seen people complain about this issue. And to be honest, this issue even existing in the first place is a huge dent for any developer who wants to interface with the service.
Their API is different than the website?
I suppose we should get to the entire point of me writing this, and that’s how their API just refuses to serve data that the regular website would display without any issues.
Let me explain. There is one API endpoint that I would always want to call when making my Twitch extension. And that is user.getRecentTracks
. This endpoint returns the specified user’s previously playing songs, as well as their currently playing one, if available.
The problem was, when I called the user.getRecentTracks
endpoint, I noticed that the response returned an empty string for the album cover images.
You may also notice that there is no ID returned for the album itself. This is where I started to notice a problem. No matter what song I played, the API refused to send me these properties. Which didn’t make sense to me. If I check on their website, everything appears fine.
This is when I noticed the discrepancy between the data the website displays, and the data the API returns. The website can totally tell what album the song belongs to, and displays the album art image without any problem.
Me being a nerd, I decided to do some troubleshooting. When I had originally played these songs, I was using a third-party YouTube Music client that supported Last.FM scrobbling. Maybe that was the problem? So, I opened Spotify and started streaming a couple songs to see how the API would respond. Bingo.
Whenever Spotify is used - likely only for Spotify Premium subscribers - all of the information is returned correctly. The website still displayed the correct information regardless of what client was used, but when using Spotify, it looks like the API actually returns the necessary data needed for developers.
This discrepancy, where the website can display information that is entirely missing from their own API, is very frustrating. I intentionally picked using the Last.FM API as opposed to using Spotify’s API directly so that I could support more users instead of just relying on a single music streaming platform. By limiting myself to only Spotify, I also turn away potential users who would’ve used the Twitch extension if it supported platforms like TIDAL, or YouTube Music.
Which is disappointing to see, and I hope Last.FM will address and fix this problem at some point.
Oops, no images! (again)
Somewhat similar to the issues I was having, other users were having a problem where the Last.FM API would just return placeholder images.
In this instance, the API endpoint in question was user.getTopTracks
. This endpoint is used to get the specified user’s top tracks of all time, or for other time periods. This information could be useful for a developer to integrate into their own project, whether it’s a widget, website, or whatever.
Here’s a snippet of what the API still, to this day, returns.
Do you notice something wrong in this API response? Maybe… a string that keeps repeating in each response? Yeah. The API would keep returning various sizes of this placeholder image: https://lastfm.freetls.fastly.net/i/u/300x300/2a96cbd8b46e442fc41c2b86b821562f.png
And just like before, multiple people have complained about this not working.
- Last.FM Support Forums - No images on tracks received using user.gettoptracks
- Last.FM Support Forums - Issue with cover art when getting top tracks?
The first post originates from March of 2022, and the second post being as recent as September of 2024. And today, this problem STILL EXISTS. A staff member had even replied to the first post in 2022, and said the following:
This is by design, artist images cannot be retrieved by the api.
Which is misleading, because we aren’t retrieving artist images, we need the album art images - which are literally included in the API response? Even if that’s what the staff member meant to say, why is this information even being returned if it’s not intended to be there in the first place?
Which leads me to believe that this is just another long-running issue with Last.FM’s API.
In conclusion.
Last.FM has the worst API I’ve ever seen. From incorrect responses, to inconsistencies, to just plain broken, it sucks.
As a developer (an amateur one, at that), I understand that maintaining these codebases are not easy. Especially when you begin operating at such a large scale. But when the entire purpose of your platform is to provide information, you should do a far better job than what we are currently working with.
And the reality is, there isn’t really a good alternative to Last.FM. Because outside of Last.FM’s API, their platform is pretty good, works well, and has easy to digest information. Which just makes it all the more obnoxious when they refuse to fix longstanding issues that should’ve been a decently high priority.
I hope I don’t have to work their API again any time soon. But maybe one day they’ll get around to fixing it. API v3, maybe?
Either way, thank you for reading.
❤️