According to the Spotify API, I can use the Library object to obtain an array of all of the albums that a user has in their library. However, when I enter the following preliminary code:
var sp = getSpotifyApi(1);
var models = sp.require("sp://import/scripts/api/models");
var userlib = models.library;
followed by a call to the albums attribute:
document.write(userlib.albums);
I get nothing, presumably because the albums attribute is undefined. If I try it on the other attributes listed in Spotify’s documentation, including .artists and .tracks, it does exactly what it should: lists every artist/track included in the user’s library. Any Spotify experts have an idea as to why this album functionality isn’t present and where it might be?
There is an obscure, undocumented way to grab an array of all of the albums in a user’s library that I found after a lot of aimless searching. After the initial call to Spotify’s API, usually done like this:
you can then make this call:
returning an array of Album objects in the user’s library. You can access the methods and attributes spelled out in the Documentation’s Album object.
I don’t know if this is some kind of hold over from an older version of Spotify’s API, but I hope it sticks around or they replace it with something better. Albums as a piece of data are still very important to many listeners, as much as Spotify seems to want to erode them with Playlists.