r/truespotify•
kitated

Way to extract list of my most played tracks of all time, including by year?

Question

I want to create a couple of different playlists of my most-played tracks of all time. I'm very curious as to just how many times I've played some of the songs I really like.

I've had Spotify since it launched in the US in July 2011, so it would be wonderful to be reminded of those tracks I really liked years ago but have forgotten about. I'd like to be able to rerun the query periodically and update the playlists I've made.

I think of this like I'm making my own Rolling Stone top whatever's of all time list. Speaking of that, it would be great to be able to sort by year so I could make a "most played songs of 2021" playlist. What would be really cool is to make a "most played of 2011", my first year on Spotify.

Is it possible to extract this data from the API, and how would I go about doing it? Is there a tool on GitHub that would help?

Thanks for any help you can provide. I'm really excited about this, and hope it's possible to obtain the data.

Posted Nov 15, 2021, 1:39 PM UTC

1329
xenon_xenomorph•

do you mean like an auto updating playlist of your top songs? if not, there are discord bots that can access the api and show your top artists and stuff and you can also make a last.fm account and then import your spotify history

edit: here's a link to the import instructions if you're interested

10
kitatedOP•

I want to see the songs I've played the most (have the biggest play counts) going back to July 2011 when I signed up for Spotify. I'd like a list of them with their respective play counts sorted from most to least. Pulling the top 500 would be ideal.

  1. SongA - 500 plays
  2. SongB - 480 plays
  3. SongC - 400 plays
  4. etc. ...
  5. Song500 - 25 plays

If possible, I'd like this info broken down by year so I could see my most played songs of each year, especially 2011, my first year on Spotify.

By auto-updating, I just mean being able to do this query at any time to see how the list has changed, maybe twice a year or something like that.

Can those tools you suggested generate this type of info?

2
xenon_xenomorph•

Yeah, you can filter your library like this. It's a very useful website for listening stats. There is also a discord bot called .fmbot that makes accessing your last.fm stats a little more convenient

2
kitatedOP•

Great, thanks for this. Will take a look.

2
kitatedOP•

Thanks for this. Will take a look and see if it'll give me what I want.

2
lolothens•

There's a great app called Spotistats (soon to be Backtrack) on Google Play, that shows you that kind of info, and it's a lot more user-friendly than other tools.

The downside is that the stuff you're trying to achieve require the plus version of the app that costs like 4 bucks, and import your streaming history, but if you ask me, it's worth it.

​

The app

5
Adi_B007•

Same! 4 bucks were totally worth it for me too. Plus the other features apart from this are just cheery on top.

Also, how do you know the "soon to be name" ? It just says spotistats to me.

3
vxyg•

says within the app if you go to the stats page. or maybe the settings. says at the top in one of those two pages.

2
kitatedOP•

Ok, will take a look. Thanks.

1
kitatedOP•

The Mac and iOS apps are $2.99 each for Plus btw.

2
kitatedOP•

Thanks for making me aware of this. I'll take a look and see if I can get what I want.

One disappointment, and I've never seen this before, is on the Mac app. It's only compatible with the new AMD Silicon M1 chips, not both the Intel chips and the M1's. That's really odd if you ask me. I do have an iPhone so I guess it's no big deal, but I wonder why the dev did it that way. Because he only has an M1 Mac? Weird.

1
lolothens•

That's odd, but as far as my experience goes, just used a laptop to make the import once I got my data, other than that just get the iPhone app, that's where most of the stuff is anyway

1
kitatedOP•

Ingot my data

what is Ingot?

1
lolothens•

I got* sorry 😔

1
ryhaltswhiskey•

It's going to be a bit of work and learning if you aren't a software developer. But you can start here: https://developer.spotify.com/documentation/web-api/

For actually making the API calls you can use Insomnia or Postman. Basically you need to get an authorization token by making a request to the Spotify API. From there you include the "token" (a little chunk of text) in all of the requests you make. I don't know how to get the exact information you want but if it can be done the web API will be how you do it.

2
kitatedOP•

Ok, already figured out how to use the Console section of the Spotify for Developers webpages. You can input your query parameters and it will generate a command you can run in say the Terminal on a Mac.

The output is what I assume is a json with the results of your query. Some time range examples you can use are medium_term and long_term. I don't know yet if you can specify exact dates. I generated commands to search for top artists and top tracks. I assume the number in the popularity field in the output is the number of plays.

Next step is to learn how to parse the json so I can get the data into a list like I want. Any guidance on how to do that?

2
ryhaltswhiskey•

There is an app called JQ that is a command line app that you can use to query JSON. For a small amount of data I would recommend just doing it by hand if you are not comfortable with that app. But for a large amount of data you're definitely going to need to use a piece of software. You could also write a Python script or a JavaScript script to sort the data out. JQ is a little hard to understand in comparison if you ask me. There may be other options like bringing the data into a spreadsheet, but I have not tried that or heard of any options for that.

2
kitatedOP•

I thought about mentioning the idea of maybe getting the output into a spreadsheet. That would be ideal for what I want to do.

I have no experience in parsing json, but it would seem someone must have developed an app that makes the process fairly easy. I'll take a look at JQ, but will see what else I can find.

Thanks for your response.

1
kitatedOP•

I figured this might be the case. Do any of the API wrapper's I see on GitHub help with this?

1
ryhaltswhiskey•

They might, point me to one and I will give you some input

2
kitatedOP•

I've looked briefly at this one (https://github.com/zmb3/spotify). It was the top hit on my GitHub search. At first glance I have no idea how to use it. At the bottom of the main page he mentions this:

You may find tools such as Spotify's Web API Console or Rapid API valuable for experimenting with the API.

The Web Console is what I've already discovered, and was just looking at the Rapid API when I saw got notified of your replies.

Any thoughts on how one goes about using this guy's repo and what advantages it has for my use case, if any?

1
ryhaltswhiskey•

I've looked briefly at this one

To use that you'd need to write a Go program to interact with the data that comes back from the API. You're better off with Postman and JQ. Go is not easy.

1
kitatedOP•

Just took a quick look at Insomnia and Postman for API calls. Will these also do parsing of the json output?

Thanks for your replies btw.

1
ryhaltswhiskey•

I'm pretty sure the answer to that is no. You need a different tool to parse the Json. I would save the results of the API calls out to a file and then use JQ to do a little bit of manipulation of the file to get the data you want. Or you can just load the file up in a text editor and take a look at it. If you want something a little more fancy for text editing that json use VSCode. It's free.

1
kitatedOP•

Thanks so much for this. I have used some editors like Sublime and Coteditor, so I know how to visually display and interpret the data. I just need to parse it and get it into a table or even a spreadsheet.

It's pretty amazing as everything about each track is output, including available markets. external url's of the artist, album and track, artist, album, track # on album, image url's and sizes, release dates, total album tracks, disc #, explicit T/F, duration in ms, popularity (which I assume is the play count), etc.

I'll take a look at VSCode as well. Thanks again.

2
Klangspot•

I think the best way is to use last.fm.

1
kitatedOP•

Thanks for this. Will look into it.

Do you know if it will go back in time and pull all your play history since you first signed up for Spotify? That's one of the things I'm running into by using the Spotify Web API to query the database ... there's a 50 track limit, and you can't specify an exact time period you want to use to extract the data.

1