Puffbox’s Project MyTube: hooray for APIs

A few days ago, I bought an iPod Touch; and I can finally understand the fuss. I didn’t really want it; I’m not short of portable media players, and my Android phone gave me a perfectly good touchscreen to play with. But I’m very excited about mobile-optimised web interfaces at the moment, and felt I needed an iPod/iPhone to do some proper testing (as opposed to educated guesswork).

I’ve been especially blown away by the quality of videos streamed from YouTube. For example, I’m a big ice hockey fan – and the NHL (the big league in North America) is kind enough to put full highlights of every game on YouTube. But as you can probably guess, a flying puck isn’t easy to see in a heavily pixellated non-HD video stream. It’s a completely different story on the iPod Touch – crystal clear.

But – unless I’ve missed it? – there’s no easy way in the built-in YouTube applications, either on the iPod or Android, to log into your YouTube account and see your various ‘subscriptions’. On the face of it, it’s an extraordinary omission. Subscriptions are effectively your personalised EPG, allowing you to cut through the chaos, and get to the content you want. Isn’t that exactly what you want/need? So I did it myself.

If you go to mytube.puffbox.co.uk, you’ll see an intro page with a dropdown list of various YouTube channels: these are being called in dynamically via Javascript, from the puffboxtv account on YouTube, courtesy of Google’s astonishingly comprehensive API. (I got the list of HMG YouTube channels from Steph’s digitalgovuk catalogueding!) When you choose a channel from the dropdown, it makes a further API call, drawing a list of the last 10 videos posted to that account, with upload dates and thumbnails. Click on a title, and you’ll see the clip description, plus an embedded player. On a normal browser, the clip will play on the page; on an iPhone/iPod or Android unit, it’ll play in the native YouTube app, full-screen. The ‘back’ button in the top left corner (not the browser back button!) returns you to the list of videos.

That’s pretty cool… but here’s the really clever bit. If you have made your YouTube subscriptions publicly visible, you can call your own favourite channels into the dropdown – go to http://mytube.puffbox.co.uk/?account=yourname and you should see a familiar list. I should stress, my site never holds any personal information: it’s all coming in dynamically from YouTube.

As with most of my experimental stuff, it comes with zero guarantees. There are rough edges, and it could be a little prettier. But here’s the important point: I knocked this together in 24 hours*, thanks principally to (a) Google’s wonderful API and (b) the free JQuery javascript library to process the responses.

Coincidentally, as I was putting the finishing touches to the site, I came across Charles Arthur’s piece in today’s Guardian about the Home Office crime mapping problems – which concluded thus:

The Free Our Data campaign thinks the practices outlined in the memo do not go far enough: what external developers especially are looking for is pure data feeds of events, rather than static maps… Ironically, the police’s efforts to meet the deadlines might be better aimed at producing those data feeds with time, location and crime form data which could then be used by external developers – who would be able to produce maps more quickly than in-house efforts.

I couldn’t agree more – and I hope my efforts over the last 24 hours prove the point. I’m amazed by how easy (relatively speaking) such things are becoming. The common thread across all the really successful web 2.0 properties is the availability of an API, allowing developers to work their own unique magic. As I’ve said before… Government needs to recognise this, and get in the API game. Not just as a ‘nice to have’, but as an absolute priority.

* 24 hours? Well, put it this way. It was working perfectly in Firefox, Safari (desktop and mobile), Chrome, Android… but not IE. It’s taken me the best part of a day to make it work in IE, and I still can’t really understand what I’ve done differently to finally make it work. Opera’s acting really strangely, but I’ve spent long enough playing with it for now.

5 thoughts on “Puffbox’s Project MyTube: hooray for APIs

  1. That’s rather nice. Think I might do my bit for the economy with an iPhone purchase in January…

    One for the case study presentation showing how people can re-present government content in new formats thanks to the social web, methinks. Nice one.

  2. Very glad to read this!
    (1) You’ve finally bought an Apple gadget
    (2) You’re an ice hockey fan (so something other than WordPress that we’re both fans of!)

Comments are closed.