Free TTC Mobile iPhone app @ bit.ly/ttcmobile (Support)

Why can’t I access this NextBus feed of real-time GPS data, TTC?

May 7th, 2010

So I’ve been working on creating better TTC data for my various apps and I’ve been showcasing the data at apps.to, a quick GPS-enabled page (that works in all but BlackBerry) which shows the nearest routes and their stop times from a previous scraping of ttc.ca. But I’ve been seeing plenty of tweets about the NextBus webpage formatted for iPhone which is only useful if you need a 500-series street car and remember it’s there.

Remembering how in a previous post’s comments, Mike, the Director of Engineering at NextBus clarified for me how the GTFS data they offer differs necessarily from other versions published, I knew such data should be available somehow. But all they list is their predictions, which they of course have copyright over. The raw data, I remembered, was once visible from a Google Map, which I couldn’t find. But I stumbled on the URL again and decided to manually load the data, with the required referrer header:

$ curl --referer 'http://www.nextbus.com/googleMap/googleMap.jsp?a=ttc#' 'http://www.nextbus.com/service/googleMapXMLFeed?command=routeConfig&a=ttc&r=501&key=2826347560685'

Here’s the result:

<?xml version="1.0" encoding="utf-8" ?>
<body copyright="All data copyright Toronto Transit Commission 2010.">
<Error shouldRetry="false">
Your IP address 99.235.xx.xxx is not authorized to access data for agency Toronto Transit Commission. Contact [website at nextbus dot com] if you should have access to this feed.
</Error>
</body>

Please note the copyright above, in red. This shows that as should be expected, the raw data (not the predictions) are indeed copyright the TTC rather than NextBus. But of course, I get the error listed above, that I’m not authorized. I expected that, after all it was hard enough to find this feed URL.

The question I really have is, TTC, why haven’t you made any plans for an API for this data? Perhaps I should contact that projects director, whose phone number I received after a two week struggle last December. Given how I’ve scraped the TTC data already, found some problems, and would like better solutions for standardized data sharing, there should be room for mutual improvement of all our services, with all the benefits therein for TTC riders.

Next I think I’ll start writing up posts detailing my adventures scraping ttc.ca and geolocating all 1,886 timed stops. Oh and if anyone wants the database (it’s a work in progress), let me know. I’ve also got an API based on Google Protocol Buffers from when I was experimenting in BlackBerry app development (a nightmare of its own).


2 Comments, Yay! »
  • Scotty Hyndman

    Hi there,

    I would like that database. scotty.hyndman@gmail.com

    And I was able to scrape nextbus for GPS data, and wrote a little parsing library in Ruby. We should collaborate.

  • Louis

    Good news! No need to scrape for GPS data or geo-located stop data!

    I keep forgetting to write a post on this, but now you can access the NextBus API and get TTC data in GTFS format from http://www.toronto.ca/open/ as a free download.

    I’m writing scripts right now to convert the GTFS data into compact, optimized Protocol Buffers for use on multi-platform mobile apps with geolocation of bus schedules.

    But yes, indeed, we should collaborate. I’ve borrowed Proximobus and installed a copy at http://ttc-proximobus.appspot.com/ with an all-route KML feed suitable at http://bit.ly/ttcgpskml which you can even load on an iPhone by searching for that URL in the address box.