I made lastfm to csv - a page for downloading lastfm listening data as a csv file. API requests are made directly from the browser, avoiding the need for any server-side code.
give it a shot now (my username is benjaminf)
My friend Andy wanted some lastfm listening data for a visualisation project so I wrote him a ruby script that uses the user.getrecenttracks method to get the track history for a user. This worked fine though if someone else wanted to use it - they would need to install ruby, and have a familiarity of the command line.
I figured it might be easier for people to do this in the browser - so I put together lastfm-to-csv, which lets you enter a username and download a csv file containing all the tracks for a user.
Using the browser
A few libraries that I found useful:
- reqwest - for making xhr calls, nice and lightweight.
- async - for organising the calls to the api and processing the results.
- Filesaver.js - lets you download the resulting Blob objects as a file.
A few things I noticed by doing it this way:
- people have access to their data instantly - no waiting around for a file to be generated on the server before downloading it.
- no servers to keep running - all code runs in the browser
- harder to avoid api limiting - it someone gathers data in several windows, they could get rate limited.
- potential access issues. Last fm gives you access to a nice cors endpoint, though that’s not always the case with other apis.