

Real-time UK Bus Data Ruby Gem - maxehmookau
https://github.com/maxehmookau/UkBuses

======
UnoriginalGuy
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.

~~~
tomaisthorpe
In Leeds, First Bus do give real-time info. Wonder why it's different here...

~~~
UnoriginalGuy
Do they have competition in Leeds?

Either way, the local council could have forced them to.

~~~
thehodge
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.

------
joshmcmillan
This looks really nice (and helpful!), however:

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...](http://www.tfl.gov.uk/assets/downloads/businessandpartners/tfl-
live-bus-and-river-bus-arrivals-api-documentation.pdf))

~~~
oakesm9
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?

~~~
maxehmookau
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.

------
csmattryder
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!

~~~
maxehmookau
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 :)

~~~
coob
TFL provide proper APIs

[http://www.tfl.gov.uk/businessandpartners/syndication/defaul...](http://www.tfl.gov.uk/businessandpartners/syndication/default.aspx)

~~~
maxehmookau
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.

~~~
blocking_io
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.

------
blocking_io
I recommend that you do not use this. Traveline provide an official API with
up to 180,000 free requests in a six month period.

<http://travelinedata.org.uk/nextbuses.htm>

~~~
maxehmookau
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.

~~~
blocking_io
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.

~~~
maxehmookau
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.

~~~
blocking_io
_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.

------
k-mcgrady
Does this work with all bus services in the UK? I can't find a list of which
are supported.

~~~
blocking_io
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.

