Accessing Spotify Metadata API from within a Spotify app?

后端 未结 2 1148
失恋的感觉
失恋的感觉 2021-01-15 19:24

I want to run Spotify searches from within a Spotify app (to find tracks for an artist, for which I do not have a Spotify URI, only the name).

I have not found func

相关标签:
2条回答
  • 2021-01-15 20:06

    This is not the finest way to solve your problem. There is a direct API for searching within your app. See Juan's solution.

    But you could also talk to ws.spotify.com directly when you add the domain to your app's manifest.json.

    "RequiredPermissions": ["http://ws.spotify.com" ]

    e.g. http://ws.spotify.com/search/1/track.json?q=kaizers+orchestra, see their Developer Site. The response contains the header "Access-Control-Allow-Origin: *", so you should be able to query from within your app.

    0 讨论(0)
  • 2021-01-15 20:11

    You can use sp.core.search

    sp.core.search("query",
        {onSuccess: function(result) {
            // parse result
            }
        }
    );
    

    sp.core.getMetadata if you have the uri

        sp.core.getMetadata("uri", {
            onSuccess: function(data){
                console.debug(data);
            },
            onFailure: function(){
                    //...
            },
        });
    
    0 讨论(0)
提交回复
热议问题