Translink Zend Framework API

Translink is the local public transit provider for beautiful Vancouver, Canada. The system consists of Buses, Boats and Trains. Translink released an Iphone app some time ago that allows the lookup of bus information. Michael Weisman was kind enough to write about the “hidden” api that is used by the Iphone app to preform AJAX calls.

The Zend Framework based API that I have written duplicates the functionality described on Micheal’s page and exposes the API functionality to PHP applications.

Please keep in mind that as this is an unofficial API, Translink may not want their data being used without their permission. Please contact Translink before making use of this API on a production site.

Example Usage

$translink = new Zext_Service_Translink();
 
//Get the route directions for the 135
$directions = $translink->getRouteDirections('135');
Zend_Debug::dump($directions);
 
//Get the east-bound stops for the 135
$stops = $translink->getRouteStops('135', 'east');
Zend_Debug::dump($stops);
 
//Get the details for an arbitrary stop
Zend_Debug::dump($translink->getStopDetails(51845));
 
//get the latitude and longitude for a stop
Zend_Debug::dump($translink->getStopLocation(51845));
 
//get the stops near a given latitude and longitude
Zend_Debug::dump($translink->getLocationStops(49.25344,-123.167895));

Download & Install

Download the following file:

Zext_Service_Translink

Add it to your library path (same folder that Zend of the Zend framework resides in) if you have autoloading enabled.

I will try to respond to any problems in the comments.