bsandrow / temirt

A Python library for accessing the Trimet Web API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

temirt

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.

Arrivals

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

Detours

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

Other Implementations

Credits

Copyright 2011 Brandon Sandrowicz brandon@sandrowicz.org

See LICENSE file.

Disclaimer

This project is in no way associated with Trimet. It is my own personal project.

About

A Python library for accessing the Trimet Web API


Languages

Language:Python 100.0%