Skip to content

Instantly share code, notes, and snippets.

@nulltask
Created February 22, 2014 05:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nulltask/9149287 to your computer and use it in GitHub Desktop.
Save nulltask/9149287 to your computer and use it in GitHub Desktop.
WASABEAT API Tutorial
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<style>
body {
font-family: 'Helvetica Neue';
margin: 50px;
}
</style>
<!-- Documentation: http://developers.wasabeat.com -->
<!-- $ php -S localhost:8080 -->
<!-- Diagram: https://cacoo.com/diagrams/jfC4OLtFxERrVVdj -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.js"></script>
<script>
$(function() {
$.getJSON("http://api.wasabeat.com/v1/tracks/search?bpm=100..125&tonality=12a&genre_id=900,901,902&count=5&page=1")
.done(function(data) {
data.tracks.forEach(function(track) {
console.log(track);
var $track = $('<div>' +
'<p>Title: ' + track.title + ' (' + track.mix_title + ')</p>' +
'</div>').appendTo('body');
var audio = new Audio();
audio.controls = true;
audio.src = track.urls.sample;
$(audio).appendTo($track);
var image = new Image();
image.src = track.images.larger;
$(image).appendTo($track);
});
});
});
</script>
</head>
<body>
<h1>WASABEAT API Tutorial</h1>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment