如何使用echonest api获取特定歌曲的spotify id

时间:2014-11-17 01:16:29

标签: api spotify spotify-app echonest

我正在尝试使用艺术家姓名和歌曲名称查询echonest并让它返回歌曲的spotify ID。目前我只能让艺术家退回。

我正在阅读文档,但这根本没有意义,我认为它可能已经过时了,并且想知道是否有人可以帮助我。

以下是我正在使用的文档的链接(http://developer.echonest.com/sandbox/spotify.html)API示例是最后一个的第二个:

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

艺术家:Radiohead 歌名:Karma警察

文档中的示例返回的内容是

songs: [
{
    title: "Karma Police"
    artist_name: "Radiohead"
    id: "SOHJOLH12A6310DFE5"
    tracks: [
              {
              "catalog": "spotify",
              "foreign_id": "spotify:track:3L7BcXHCG8uT92viO6Tikl",
              "id": "TRAVAWH13386461C1A"
              }    
           ]
  }
]   

我正在努力获得spotify:track:NUMBER_HERE

但是当我在浏览器中实际运行api时,我会得到完全不同的东西。

我得到了

{"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"}]}}

有人可以指出我正确的方向,我正在忽略。

感谢任何帮助指导和建议。我的最终状态是我可以获得spotify轨道ID,因此我可以通过编程方式构建自己的播放列表。如果有更好的方式,我愿意接受建议

1 个答案:

答案 0 :(得分:2)

查看您从Echo Nest的API获得的响应,跟踪URI位于 response.songs [0] .tracks [0] .foreign_id。所以文档是正确的,它只是没有覆盖歌曲阵列所在的响应对象。

希望这有帮助!