This looks pretty neat, could see some good applications being built with this over the Google Maps API!
One thing to note, is that I can't see whether the Gem handles the source being 403/404'd for example, is that something that is handled by the source?
And it was great reading the code, I'm new to Ruby and currently writing my first Gem, it looks like a highly viable route for bus tracking (no pun intended!), very pretty code!
Currently not no. The data is scraped from a site and not read from a nicely formatted API. This is definitely a todo though. Add an issue or better yet, add a pull request :)
Only for London. While that may appeal to many people, most people in the UK don't live in TFL's area. Traveline are much harder to get API data out of.
You can email them to ask for a test API key up to 1000 hits a day. If you sign a contract you can use 180,000 API hits every six month period for free. Beyond that there is a cost of £1.50 per 1000 API hits.
http://transportapi.com/ has real time public transport data available everywhere it's provided in the UK, with a much simpler API than other sources (eg SIRI XML feeds from network operators).
TFL is London only though. It will only provide information for a small part of the UK. Is there an API which provides live data for all of the UK in one?
Not AFAIK. I've attempted to get data out of Brighton & Hove buses before. But again, they represent a tiny minority of the UK population. Traveline's data is the closest I've come to blanket coverage.
As mentioned above. London provides this data, which is great. But me (and the majority of people in the UK) don't live in London. This data is held by Traveline who do not make their data publicly available. As to the ethics, I do not know. I'm not commercialising this as a product, I do not intend to make money from it. As for them being 'unsuspecting'. We live in a age where data is free. They should open up their data or scraping is inevitable.
Unfortunately the local First Bus monopoly doesn't provide real-time data, even though they have WiFi on all their buses (so therefore adding real-time location-data would likely be trivial - if they don't have it privately already, which I strongly suspect they do).
From what I've been told they don't provide this data because they don't want people to figure out how late their services run, and that information could also be used by local councils to do performance analysis (since local council subsidies their services massively, making competition impossible, assuming competition could get a licence at all).
Basically the local bus company acts in a selfish way and we all get to stand in the rain for an extra ten minutes as a direct result of that.
Sadly not massively, the local arriva service is lacking and there is centre bus which seems to be running sheds with wheels. First have a good 80% of the routes in Leeds.
It will give you information for any bus stop, but not all of them have realtime data. Some use the timetable. You can ask Traveline for a list of areas where there is realtime data. For some reason the information is not published.
I would recommend that you don't use that. This data should be open. It should be quickly accessible. I don't want to have to email someone to ask permission to access data that should be freely available. There's no reason this data shouldn't be more easily available and that's what this gem does. Though I admit, web scraping is never the best way to access data.
Traveline are paying another company to extract and normalise the data from the myriad of real time data feeds different bus companies use. Of course, ideally they would all be using open standards. But they aren't. I don't understand why you feel entitled to data which costs Traveline money to produce.
Everyone is entitled to this data. The fact buses are late where I live are a given, if I asked traveline to give me the data so that I could measure how late my buses are, they would decline. Opening data can only help to increased accountability which can only lead to better services for customers. If your data brings your company in to disrepute and your way of fixing that is to hide the data, you're doing it wrong.
if I asked traveline to give me the data so that I could measure how late my buses are, they would decline
No they would not. They will give the data to anyone. They didn't even want my name before they gave me test access of up to 1000 API hits a day (which would be sufficient for the personal usage you describe). The data itself is provided under the open government licence which allows you to do pretty much anything you want with it. As far as I can tell, there are no restrictions beyond this on what applications are allowed to use the API. Really, you should email them and ask them. I got a very quick response.
23 comments
[ 1.5 ms ] story [ 102 ms ] threadOne thing to note, is that I can't see whether the Gem handles the source being 403/404'd for example, is that something that is handled by the source?
And it was great reading the code, I'm new to Ruby and currently writing my first Gem, it looks like a highly viable route for bus tracking (no pun intended!), very pretty code!
http://www.tfl.gov.uk/businessandpartners/syndication/defaul...
http://travelinedata.org.uk/nextbuses.htm
What are the ethics surrounding scraping unsuspecting websites, these days? Have you seen the proper TfL APIs? (http://www.tfl.gov.uk/assets/downloads/businessandpartners/t...)
From what I've been told they don't provide this data because they don't want people to figure out how late their services run, and that information could also be used by local councils to do performance analysis (since local council subsidies their services massively, making competition impossible, assuming competition could get a licence at all).
Basically the local bus company acts in a selfish way and we all get to stand in the rain for an extra ten minutes as a direct result of that.
Either way, the local council could have forced them to.
http://travelinedata.org.uk/nextbuses.htm
No they would not. They will give the data to anyone. They didn't even want my name before they gave me test access of up to 1000 API hits a day (which would be sufficient for the personal usage you describe). The data itself is provided under the open government licence which allows you to do pretty much anything you want with it. As far as I can tell, there are no restrictions beyond this on what applications are allowed to use the API. Really, you should email them and ask them. I got a very quick response.