Sam Kennedy's blog

XML Over HTTP API for Chattanooga's CARTA Mass Transit

A few months ago I was checking out the new Bus Tracker that CARTA provides online. Even though the implementation clearly isn't perfect, I really liked what they were trying to do and to be able to access this information in some form...

Then I stumbled upon it. An XML-over-HTTP API to retrieve many types of information about CARTA's routes.

Getting a list of bus stops


http://bustracker.gocarta.org/bustime/map/getRoutePoints.jsp
Parameters: route

This returns a document with bus stops for a route. They seem to be organized into two patterns, one for each direction. The longitude and latitude and name of each bus stop is included. This could be useful for looking up which is the nearest bus stop as well as looking up bus stop IDs for use with other API methods.


Getting information about buses


http://bustracker.gocarta.org/bustime/map/getBusesForRoute.jsp
Parameters: route

This returns the live information about buses currently on the road. The route parameter seems to be optional; if omitted we seem to get all the buses. Longitude and latitude of the buses are included, nearly live from GPS units on board each bus. Other information is also included for each bus, including the bus number, the operator number, and the direction it's going.


When will the bus get here?


http://bustracker.gocarta.org/bustime/map/getStopPredictions.jsp
Parameters: stop, route

This method gives us a bit of crystal ball functionality, in the form of any number of returned "predictions", each of which consist of a bus and the number of minutes until it arrives at the stop. The stop parameter required here is an ID which can be looked up using getRoutePoints method. Remember that there is a separate stop for each direction, aka "pattern". I don't know exactly how far into the future these predictions go, but I've never observed them more than 40 minutes.


Where's the bus going?


http://bustracker.gocarta.org/bustime/map/getBusPredictions.jsp
Parameters: bus


This method is similar to the one above, except instead of giving it a stop, you give it a bus and it predicts the next stops. The bus parameter is the id taken from the getBusesForRoute method.


Now it's time to make some cool and useful web mashups... or iPhone apps... or widgets!