« Back to the api page

How to use the API with JSON:

This is a simple way to use the myspace events API using jQuery and some javascript. For a demo check out this Tumblr blog. It's fairly easy.

Demo:

Code:

This can be used in every html page with the use of jQuery. Include jQuery, copy & paste this in your document or tumblr and replace the myspace id in the url with your bands myspace id. The example updates a <ul> with the id 'shows'.

<script type="text/javascript">
function date(ts)
{
    /* do anything with the date you want, the date is formatted in a timestamp. */
    var date = new Date(ts);    
    return date.toDateString();
}

$(document).ready(function(){
    
    $.getJSON("http://myspace.jochemschutte.nl/api/?format=json&myspace_id=4459262&limit=5&callback=?", function(data){
        $.each(data, function(i,item){
            $("#shows").append("<li><strong> " + date(item.date) + "</strong> " + item.city + ", " + item.venue + "</li>");
        });
    });  
      
});
</script>

The JSON call

http://myspace.jochemschutte.nl/api/?format=json&myspace_id=4459262&limit=1&callback=?