Dublin Bus route statuses

I’ve thrown together a little hack that gives current Dublin Bus route status information in JSON format.

Endpoint: http://rossduggan.ie/stuff/bus/

Simply calling the endpoint will return a JSON object of all bus routes and their associated statuses.

Append ?route=x to the endpoint and you’ll get just the results for the route specified (or what it thinks you mean if it doesn’t understand the route):

GET http://rossduggan.ie/stuff/bus/?route=15

You’ll get something like this:

{
	"status":"Operating on normal route.",
	"match":
		{
			"exact":"15"
		}
}

If you look for one of the routes that Dublin Bus merge together (for whatever reason; 42A and 42B are like this):

GET http://rossduggan.ie/stuff/bus/?route=42a

You’ll get:

{
	"status":"Unable to serve Edenmore or Harmondstown. Operating via Springdale Rd and Tonlagee Rd.",
	"match":
		{
			"closest":"42a\/b"
		}
}

The reason for this is because I threw this together in about 30 minutes as an excuse to familiarize myself with XPath, and I thought some error handling would be better than no error handling :)

Once the bad weather goes away this will probably break since Dublin Bus will change the layout of their notices, but I’ll try to keep it functional for as long as I can. I have a horrible feeling the data source is being copied and pasted by whomever is maintaining it from an old copy of MS Word into a WYSIWYG editor for the dublinbus.ie homepage.

In usage:

I pushed this out on Twitter at about 7:30pm, and by about 10:00pm @walmc had already thrown together a neat little node.js growl notifier using it!

This entry was posted in Codetry. Bookmark the permalink. Both comments and trackbacks are currently closed.

One Comment

  1. Posted January 13, 2011 at 5:18 pm | Permalink

    Nice. FYI you might be inetersted in these folks. Still very early days at the moment.
    http://opendata.ie/