A Python library for interfacing with the Trimet Web API.
Note: An ApplicationID key is necessary to use the web API. This can be obtained here.
Other than the examples here, the submodules under temirt.app.*
are good usage
examples in actual code.
import temirt
temirt.api.application_id = 'YOUR_API_KEY_HERE'
result = temirt.api.arrivals([ 10577 ]) # Mt. Hood Ave MAX Stop
# There should only be one location because the query only contained one
# stop id.
location = result['locations'][0]
print "Stop %s: %s" % (location.location_id, location.description)
for arrival in result['arrivals']:
print "Route %s arriving at %s (%s)" % (arrival.route_number, result.estimated_arrival, result.status)
# Note: When result.status = 'scehduled' (i.e. no estimated available),
# estimated_arrival seems to be equal to scheduled_arrival
import temirt
temirt.api.application_id = 'YOUR_API_KEY_HERE'
result = temirt.api.detours([ 77 ]) # Only detours affecting Route 77
for detour in result['detours']:
print "Detour: %s" % detour.description
print " -- starts at %s" % detour.begin
print " -- ends at %s" % detour.end
Copyright 2011 Brandon Sandrowicz brandon@sandrowicz.org
See LICENSE file.
This project is in no way associated with Trimet. It is my own personal project.