0
votes

Is there any live fiddles with the Play Button and / or Metadata API implemented and working? (Outside of within native Spotify of course)

Looking at meta-documentation here: https://developer.spotify.com/technologies/web-api/search/


I am unable to create an environment, where I see anything; to poke around and try things with the code / API. I would love to just be able to create a sandbox seeing anything to work on top of. But the documentation seems to hardly exist.


Essentially; I am hopping to combine; https://developer.spotify.com/technologies/widgets/spotify-play-button/

With Meta-Search.

I understand I can see with this syntax: http://ws.spotify.com/search/1/track.json?q=artist:foo+fighters

But how to get a search in front of it; and spit it out after? This seems like a middle component I'm not sure what to do with.

I would simply like to create a search bar >> from that search bar you can enter an Artist >> this taps Spotify >> and spits out artist's playlists to listen to.

I would later on, like to go back in and create a filter to only spit out artist in which are having an event or concert within a specific area.

1

1 Answers

1
votes

This question doesn't necessarily relate to Spotify's Web API, but rather using a server side script to retrieve information from a Web API and passing that result out to a view. As answered in a similar question, the API doesn't support CORS or JSONP. And since you can't make XMLHttpRequests to different domains, you'd have to make server side scripts to make HTTP requests to the Web API. As the similar post said, you could do this in a number of languages, e.g. PHP, Python, Java or JavaScript.

A JavaScript solution could be to run Node with an Express webserver, that uses needle to make HTTP requests to the Web API, and passing the results from that request to the browser view.

Something like,

var express = require('express');
var app = express();
var needle = require('needle');

// Handle requests for http://localhost:3000/<some-artist-name>
app.get('/:artistname', function(req, res) {

  // Make request to Spotify's Web API for some artist name
  needle.get('http://ws.spotify.com/search/1/artist?q=artist:' + req.params.artistname, function(error, response, body) {

    // Most popular artist from search results
    var artistURI = body.artists[0];

    // Send a Spotify Play Button iframe for the artist URI
    res.send("<iframe src='https://embed.spotify.com/?uri=" + artistURI + "' width='300' height='380' frameborder='0' allowtransparency='true'></iframe>"); 

  });  
});

app.listen(3000);

Please see this as inappropriately detailed pseudo code, and just as an example of what it may look like using Node with these two particular modules. You've got lots of choices to go with.