Hack the Tube
Yesterday we featured a roundup of iPhone London Underground apps. Today I’m going to show you how to hack the Tube yourself.
Tube Updates API
Tube Updates is an API by Ben Dodson that provides access to TFL data on Tube updates. You can get data in either XML or JSON. Here’s the full documentation: API Documentation - Tube Updates.
Accessing the API is simple, just request the format and lines:
http://api.tubeupdates.com/?method=get.status&lines=central,hammersmithcity,victoria&format=xml
Ruby Example
Here’s a Ruby example to get you started:
This provides a simple way of accessing the API. Just create a TubeUpdates object and pass an array of station names. The station names are in the API documentation:
all- Wildcard for all linesbakerloo- Bakerloo Linecentral- Central Linecircle- Circle Linedistrict- District Linedocklands- Docklands (note: DLR will always return a status of ‘unknown’ as TFL doesn’t give it a status)hammersmithcity- Hammersmith & City Linejubilee- Jubilee Linemetropolitan- Metropolitan Linenorthern- Northern Linepiccadilly- Piccadilly Linetube- Wildcard for all tube lines (excludes DLR)victoria- Victoria Linewaterloocity- Waterloo & City Line
There’s no error handling in my example, so you might like to add this. It could form a create Rails plugin for a web site or service.
JavaScript Widget Example
If you’re writing a Mac OS Dashboard widget or Google Homepage Gadget you’ll need to use their API to request data. For example, Mac OS Widgets require network access to be enabled in Widget Attributes:

This basic example shows how to use Prototype.js to fetch data and show it in a Dashboard list UI element:
You can download the full example here: TubeStatus.zip

