Search code examples
rdio

Getting track listing for an album?


The Rdio API only gives keys for track listings through the API.

Given, say, a call to Rdio's getAlbumsForArtist method with an artist key, you might get a response similar to:

{
 "status": "ok", 
 "result": [
  {
   "baseIcon": "album/a/8/2/000000000001e28a/1/square-200.jpg", 
   "releaseDate": "2007-07-10", 
   "artistUrl": "/artist/Justice/", 
   "duration": 2858, 
   "isClean": false, 
   "shortUrl": "http://rd.io/x/Qj5Dvck/", 
   "canStream": true, 
   "embedUrl": "https://rd.io/e/Qj5Dvck/", 
   "type": "a", 
   "price": "None", 
   "key": "a123530", 
   "icon": "http://img00.cdn2-rdio.com/album/a/8/2/000000000001e28a/1/square-200.jpg", 
   "canSample": true, 
   "name": "Justice", 
   "isExplicit": false, 
   "artist": "Justice", 
   "url": "/artist/Justice/album/Justice/", 
   "artistKey": "r80653", 
   "length": 12, 
   "trackKeys": [
    "t1555455", 
    "t1555488", 
    "t1555527", 
    "t1555555", 
    "t1555583", 
    "t1555618", 
    "t1555640", 
    "t1555663", 
    "t1555693", 
    "t1555727", 
    "t1555762", 
    "t1555798"
   ], 
   "canTether": true, 
   "displayDate": "Jul 10, 2007"
  }, 
  {
   "baseIcon": "album/f/2/d/0000000000451d2f/1/square-200.jpg", 
   "releaseDate": "2014-05-26", 

Sadly, that only gets you the keys for each track.

What's the best way to get — in one request — titles (and other associated information, if possible) for the tracks of a given album?


Solution

  • What you're looking for is the use of the extras field. I'm kind of surprised that album pages doesn't list it, but there's a "tracks" extra. It'll add a 'tracks' array to your result that has all the basic track information in it (which includes "name").