Last.fm API Summary
in under 2 minutes

David Whiting
Music Tech Fest Hack Camp - 18th May 2011

Last.fm API is great for hacks because...

Public API

Last.fm Public API

HTTP webmethods to access catalogue, events, charts and recommendations.

Examples

Get information about the artist "Demoscene Time Machine":
To do this:

artist.getinfo({
    artist:  "Demoscene Time Machine",
    api_key: "202ece1f999e55ce1c3aaabbbad6ae40",
    format:  "json"})

We need to hit this URI:
http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=Demoscene+Time+Machine&api_key=202ece1f999e55ce1c3aaabbbad6ae40&format=json

Examples

Get the current hyped track chart:
http://ws.audioscrobbler.com/2.0/?method=chart.gethypedtracks&api_key=202ece1f999e55ce1c3aaabbbad6ae40&format=json

Get the current top "electro house" artists:
http://ws.audioscrobbler.com/2.0/?method=tag.getweeklyartistchart&tag=electro+house&api_key=202ece1f999e55ce1c3aaabbbad6ae40&format=json

JQuery example
$.get(
  "http://ws.audioscrobbler.com/2.0/?",
  {
    method:  "chart.gethypedtracks",
    api_key: "202ece1f999e55ce1c3aaabbbad6ae40",
    format:  "json"
  },
  function(response) {
    // do something useful with response here
  }
});

Full documentation at www.last.fm/api

Radio stations

Radio

Radio Query Language (RQL)

It's really easy:
Experimental Features:

Radio Query Language (RQL)

How to play

Base64 encode it, then insert in the URL "lastfm://rql/{base64encodedRQL}"

If you have a Last.fm client installed, opening this link will play your radio station

This URL is also a valid input to the radio.tune() API method (if you want to write your own client)

Real-time data

Cyclone - Shiny brand new (experimental) realtime data API


var q2 = new lfmc_TopFeed('track')
.setSize(5)
.onData(function(list) {
    //present list data here
});
        

Cyclone - full details at http://hackdaynode.last.fm

Prizes

If you need help: