This snippet of code retrieves the user's 20 latest songs added to their Library and creates a Player & List view of the songs.
/* Instantiate the global sp object; include models & views */
var sp = getSpotifyApi(1);
var models = sp.require("sp://import/scripts/api/models");
var views = sp.require("sp://import/scripts/api/views");
/* Create an array of tracks from the user's library */
var tracks = models.library.tracks;
/* Create a temporary playlist and fill it with tracks
* from the previous query */
var tempPlaylist = new models.Playlist();
for(var i=0;i<20;i++) {
var track = models.Track.fromURI(tracks[i].data.uri);
tempPlaylist.add(track);
}
/* Create a Player() object and fill it with content
* from the temporary playlist object created earlier */
var player = new views.Player();
player.track = tempPlaylist.get(0);
player.context = tempPlaylist;
/* Pass the player HTML code to the #player div */
$('#player').append(player.node);
/* Create a "view" for the playlist and pass the list
* code to the #player div */
var playlist = new views.List(tempPlaylist);
$('#player').append(playlist.node);
<div id="player"></div>
<style>
@import url('sp://import/css/eve.css');
@import url('sp://import/css/list.css');
</style>