I am trying to query echonest with both an Artist name and Song name and have it return the spotify ID of the song. Currently I can only get the artist to be returned.
I am reading the documentation but it makes no sense at all I think it might be out dated and was wondering if someone could help me.
Here is the link to the doc I am using (http://developer.echonest.com/sandbox/spotify.html) the API example is the 2nd from the last which is:
http://developer.echonest.com/api/v4/song/search?api_key=FILDTEOIK2HBORODV&format=json&results=1&artist=radiohead&title=karma%20police&bucket=id:spotify&bucket=tracks&limit=true
Artists: Radiohead Song title: Karma Police
What is returned as the example in the document is
songs: [
{
title: "Karma Police"
artist_name: "Radiohead"
id: "SOHJOLH12A6310DFE5"
tracks: [
{
"catalog": "spotify",
"foreign_id": "spotify:track:3L7BcXHCG8uT92viO6Tikl",
"id": "TRAVAWH13386461C1A"
}
]
}
]
And I am trying to get the spotify:track:NUMBER_HERE
But when I actually run the api in my browser I get something totally different.
I get
{"response": {"status": {"version": "4.2", "code": 0, "message": "Success"}, "songs": [{"title": "Karma Police", "artist_name": "Radiohead", "artist_foreign_ids": [{"catalog": "spotify", "foreign_id": "spotify:artist:4Z8W4fKeB5YxbusRsdQVPb"}], "tracks": [{"album_type": "album", "album_date": "1997-07", "foreign_release_id": "spotify:album:4ofIyjnuLMspKVVEM5k7KA", "catalog": "spotify", "foreign_id": "spotify:track:0CheWtm72bDFyuqxxJm7Jl", "album_name": "Karma Police", "id": "TRMKRIH144D09912F7"}, {"album_type": "album", "album_date": "1997-07", "foreign_release_id": "spotify:album:3Y0KfwfHGnuuSqVQAxODb9", "catalog": "spotify", "foreign_id": "spotify:track:4MBMrG8UypQfADJTg3cfPl", "album_name": "Karma Police", "id": "TRTEKIH144D14B88AB"}, {"album_type": "unknown", "album_date": "1997-05-21", "foreign_release_id": "spotify:album:2fGCAYUMssLKiUAoNdxGLx", "catalog": "spotify", "foreign_id": "spotify:track:4toSP60xmDNCFuXly8ywNZ", "album_name": "OK Computer", "id": "TREZAIC144D16517CA"}, {"album_type": "other", "album_date": "1999-02-16", "foreign_release_id": "spotify:album:2xYrPRSUPI1Q33xbyFhEN2", "catalog": "spotify", "foreign_id": "spotify:track:5YtKNQRPr4WE4EW1q2KJ8y", "album_name": "Ka-Boom: 16 Rippin' Tunes!", "id": "TRJIACH144D1845ABD"}, {"album_type": "other", "album_date": "2006", "foreign_release_id": "spotify:album:2ravCeM1o3ZoDZkMbRA2Df", "catalog": "spotify", "foreign_id": "spotify:track:3L7BcXHCG8uT92viO6Tikl", "album_name": "Essential Bands", "id": "TRGUGNY144D11B4378"}, {"album_type": "other", "album_date": "2008-06-02", "foreign_release_id": "spotify:album:1ouYZxiEjRSlUdoldMJyNF", "catalog": "spotify", "foreign_id": "spotify:track:4NGagGvZxVZ1ox7NsOSMDU", "album_name": "The Best Of", "id": "TRITWZK144D147AB62"}, {"album_type": "other", "album_date": "2008-06-02", "foreign_release_id": "spotify:album:58ukFMtQgwjVD9vMlfnSi9", "catalog": "spotify", "foreign_id": "spotify:track:116R91XyWtWQUHw1VZD3pu", "album_name": "The Best Of", "id": "TRQZPLJ144D0B965CE"}, {"album_type": "other", "album_date": "2008-06-02", "foreign_release_id": "spotify:album:3hWomTJKGucGKv6EPpiHK9", "catalog": "spotify", "foreign_id": "spotify:track:36OTdTMwBC0SQvc0TMxqgf", "album_name": "The Best Of", "id": "TRMJVDN144D114268C"}, {"album_type": "other", "album_date": "2008-06-02", "foreign_release_id": "spotify:album:0YbEgKS7zN6HkDW8bATFn3", "catalog": "spotify", "foreign_id": "spotify:track:3FWvP216t2YLltarju8fIt", "album_name": "The Best Of", "id": "TRVHZKK144D1175CDB"}, {"album_type": "other", "album_date": "2008-06-02", "foreign_release_id": "spotify:album:30bTqpK0cUWDD4VxHVjv0f", "catalog": "spotify", "foreign_id": "spotify:track:57GM3IdxqmCX15rGBw7C0Q", "album_name": "The Best Of", "id": "TRUBASC144D1704E37"}, {"album_type": "other", "album_date": "2008-06-02", "foreign_release_id": "spotify:album:4ZbRrwQyYPoYLg689BLOdG", "catalog": "spotify", "foreign_id": "spotify:track:7afVhhphp8iwwb5c6zDD4M", "album_name": "The Best Of", "id": "TRHDXVW144D1D82BF6"}, {"album_type": "other", "album_date": "2008-06-02", "foreign_release_id": "spotify:album:40i2i4LZN75liVKAjbMKP5", "catalog": "spotify", "foreign_id": "spotify:track:4rl2PAW1pb9uvn5BrjCUPd", "album_name": "The Best Of", "id": "TRCOWWN144D1635B08"}, {"album_type": "other", "album_date": "2008-06-02", "foreign_release_id": "spotify:album:1WsOWlFxZ3u7bW2GigFhoS", "catalog": "spotify", "foreign_id": "spotify:track:0REhU4YzXin94yj5VIhfXR", "album_name": "The Best Of", "id": "TRVGGHY144D0A2A56F"}, {"album_type": "other", "album_date": "2008-06-02", "foreign_release_id": "spotify:album:4wciNwfgbL74SJG9BFlf2R", "catalog": "spotify", "foreign_id": "spotify:track:0hCW6LbmFCYwM1uGmnjjNe", "album_name": "The Best Of", "id": "TRFHBAP144D0AC7509"}, {"album_type": "other", "album_date": "2008-06-02", "foreign_release_id": "spotify:album:5lEQ9RF9W2jBIKT369b6XA", "catalog": "spotify", "foreign_id": "spotify:track:0w13hCzWc9x2ODo0lhW3AT", "album_name": "The Best Of", "id": "TRIJWLD144D0B70EB1"}, {"album_type": "other", "album_date": "2008-06-02", "foreign_release_id": "spotify:album:0kiElBKf2UH2AL51cSnjFs", "catalog": "spotify", "foreign_id": "spotify:track:7jglhg35UU1rHKo3TMMlhs", "album_name": "The Best Of", "id": "TRDAANY144D1DDC1B0"}, {"album_type": "other", "album_date": "2009-11-16", "foreign_release_id": "spotify:album:2ARSMRIAl1RrPIYODKpSvn", "catalog": "spotify", "foreign_id": "spotify:track:7IGdoYPZjwkFZObVrnhQwB", "album_name": "101 Indie Classics", "id": "TRATJQY144D1D34F86"}, {"album_type": "other", "foreign_release_id": "spotify:album:4VaGdGXKBYsDSOZpZb33YH", "catalog": "spotify", "foreign_id": "spotify:track:4TDPAhRJvIIxC2iOj3tfnJ", "album_name": "Personal Effects", "id": "TRODNEI144D15055F1"}, {"album_type": "other", "foreign_release_id": "spotify:album:3JVhCJ0KrRNNyqAbDtuUlR", "catalog": "spotify", "foreign_id": "spotify:track:7bm4xECd4E5BagR8tzshXR", "album_name": "L'album pop rock 1980-1999, Volume 2", "id": "TRIAUMZ144D1CE6B92"}, {"foreign_release_id": "spotify:album:37bbqRNY7TYPMVchZAkant", "catalog": "spotify", "foreign_id": "spotify:track:1H9Fdn0ufWXoaOZhaA3XhW", "id": "TRUOSTZ144D0C565DA"}, {"foreign_release_id": "spotify:album:2QlyISc2f7wPcwdggl8k6x", "catalog": "spotify", "foreign_id": "spotify:track:1Y6Nw0Xfh2hCBpu27F0Xce", "id": "TRLULHG144D0D0E0A8"}, {"foreign_release_id": "spotify:album:7vHLtDbWD2N2PUdWorYvL6", "catalog": "spotify", "foreign_id": "spotify:track:31VtM8plvEaBKEkwmJ5iVx", "id": "TRSAUZY144D110B9F0"}, {"foreign_release_id": "spotify:album:5VHphzoQ5AmAUv1NTXTgeA", "catalog": "spotify", "foreign_id": "spotify:track:4722k1npcMc5e1kBiWWIYI", "id": "TRBVBET144D1423032"}, {"foreign_release_id": "spotify:album:2bKod32TblM1nReRDi9gTG", "catalog": "spotify", "foreign_id": "spotify:track:6MRtrRQVOwyk6cMZY3Smnl", "id": "TRSEEQW144D1A7817C"}, {"foreign_release_id": "spotify:album:1ssRgLbh4dOEpu57bImChh", "catalog": "spotify", "foreign_id": "spotify:track:01puceOqImrzSfKDAcd1Ia", "id": "TRBHSFP144D0923CC6"}, {"foreign_release_id": "spotify:album:1EAJOr9xA3rHzhS5rWpziG", "catalog": "spotify", "foreign_id": "spotify:track:2Mvy2Ob0m1MIaOwjieDSdD", "id": "TRWBMXG144D0F402E2"}, {"foreign_release_id": "spotify:album:5bNn3KPcrlgLmhRXj4d2EX", "catalog": "spotify", "foreign_id": "spotify:track:4BFAWLRycYNSbhUgZFijc9", "id": "TRSXGVY144D1438433"}, {"foreign_release_id": "spotify:album:4195NRmc5jxkCw9jcmd4rt", "catalog": "spotify", "foreign_id": "spotify:track:5MIblG9hLxBnQcrDwdWF98", "id": "TRBLQPB144D17B11CC"}, {"foreign_release_id": "spotify:album:6vjzhxwIgTtDVW34bteGyG", "catalog": "spotify", "foreign_id": "spotify:track:10u0TOqp3bd1DAPNskHvK8", "id": "TRPIDKB144D0BA6CBC"}, {"foreign_release_id": "spotify:album:6uhBsv0PbcwolrbhgCDqDR", "catalog": "spotify", "foreign_id": "spotify:track:6XPGNyB95TZwYiqe2t964T", "id": "TRGUQDL144D1B040D8"}, {"foreign_release_id": "spotify:album:45wvzRUVtoEPsXsiNtO2TX", "catalog": "spotify", "foreign_id": "spotify:track:3u7TUfV1fjAvxJtqvtUbGO", "id": "TRNPOOC147B6E30B68"}, {"foreign_release_id": "spotify:album:3Hl5wRTlE9vNuXdZ54okbn", "catalog": "spotify", "foreign_id": "spotify:track:1vDio38orbAGqrXAR13RD3", "id": "TRHKSFX144D0E0D5DC"}, {"foreign_release_id": "spotify:album:3fjD2coxF2SQwLRcjm0ctg", "catalog": "spotify", "foreign_id": "spotify:track:6IJW8YFpoJ5DQ0YiBITqfq", "id": "TRTHCOU144D1A55B13"}, {"foreign_release_id": "spotify:album:4VYcoe0QDAGJmZA5zpgvgq", "catalog": "spotify", "foreign_id": "spotify:track:6oeIc0gfmKLlYe5gkJ3cJP", "id": "TRDVZZZ144D1B59768"}, {"foreign_release_id": "spotify:album:7eQtS9KqZmqCGkbieox4fV", "catalog": "spotify", "foreign_id": "spotify:track:6ZGOmPtSvx1hxwjwqpdKQ7", "id": "TRIBYGA144D1A9AF3B"}, {"foreign_release_id": "spotify:album:6Bjl48Ev6V97G6Uc37IRTw", "catalog": "spotify", "foreign_id": "spotify:track:6eomr7dBfWTGdRHuPwJFU6", "id": "TROCBGU14735BF0753"}, {"foreign_release_id": "spotify:album:1AAI2vNGAwA7DhCmEyYAwU", "catalog": "spotify", "foreign_id": "spotify:track:2NBB9erm0zzcM6i41Nrbux", "id": "TRDMBVL144D0F3D96F"}], "artist_id": "ARH6W4X1187B99274F", "id": "SOHJOLH12A6310DFE5"}]}}
Can someone point me in the right direction as to what I am overlooking please.
Any help guidance and suggestions is appreciated. My end state is that I can get the spotify track id so I can build my own playlist programmaticly. If there is a better way I am open to suggestions
Looking at the response you've got from The Echo Nest's API, the track URI is located in response.songs[0].tracks[0].foreign_id. So the documentation is correct, it's just that it didn't cover the response object that the songs array lives inside.
Hope this helps!