Public transport services can be great sources of live or near-live data to use when building out an application or trying some new front end technology. For years my usual go to API when I want to play with something like this has been the BART (Bay Area Rapid Transit) train API. I love working with this API because it provides data about train movements through the network and information about each station. It’s also free to sign up for here.
I decided I wanteed to build some projects out that used a more local data source, so I took a look at what the local tram company Nottingham Express Transit and bus company Nottingham City Transport offer in the way of data services. All of the tram stops and many of the bus stops have live departure screens. Here’s my local bus stop and its display:
There must be some sort of data feed driving these, but I wasn’t able to find a way that anyone could get at this data via an API. The same applied to the tram network. So, I decided I’d use the age old technique of screen scraping to build a small API that would tell me which buses are coming, when they’re expected to arrive, and to be able to do some basic filtering of the data. For example, I might want to see only buses expected in the next 10 minutes.