After I wrote about the hoops I had to jump through to get Amazon’s API to output JSON (via XSLT), Tom detailed a way of avoiding JSON by using XML-RPC. That’s very kind of him but the truth is that:
- I like dealing with JSON and
- the XSL transformation is done by Amazon, not me; that wouldn’t be the case if I used XML-RPC.
Anyway, having successfully created a Huffduffer-Amazon bridge using machine tags, I thought I’d do a little more hacking. Instead of restricting the mashup love to Amazon, I figured that Last.fm would be the perfect place to pull in information for anything tagged with the music
namespace.
Last.fm has quite a full-featured API and yes, it can output JSON. To start with, I’m using the artist.getInfo
method for anything tagged with music:artist=...
, music:singer=...
or music:band=...
. Here are some examples:
- Law Low (live) by My Morning Jacket
- Let Me Know by Yeah Yeah Yeahs
- Cello Song by Nick Drake covered by José González and The Books
I’m pulling a summary of the artist’s bio, a list of similar artists and a picture of the artist in question. For maximum effect, view in Safari, the browser with the finest implementation of CSS3’s box-shadow
property.
Nice as Last.fm’s API is, it’s not without its quirks. Like most APIs, the methods are divided into those that require authentication (anything of a sensitive nature) and those that don’t (publicly available information). The method user.getInfo
requires authentication. Yet, every piece of information returned by that method is available on the public profile.
So when I wanted to find a Last.fm user’s profile picture—having figured out through Google’s Social Graph API when someone on Huffduffer has a Last.fm account—it made far more sense for me to use hKit to parse the microformatted public URL than to use the API method.
Just over two years ago, Drew delivered a superb presentation called Can Your Website Be Your API? In some situations, the answer is definitely “Yes.”
Update: It all ties together, as Julian explains on Twitter:
@adactio ha, I went to Drew’s presentation you mentioned on your blog; it made me add microformats to Last.fm in the first place :D