Skip to content

jkchen2/NexTriPy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

NexTriPy

A Python 3.6+ NexTrip API wrapper.

This wrapper provides coverage of all of the endpoints available and respects the caching requests as stated on the NexTrip API reference.

Click here for the wrapper documentation, and here for the API documentation.

Usage

This wrapper was written to fulfill a specific demo. Given a route, stop, and direction, it will print the number of minutes remaining until the next bus leaves (or nothing if no bus is available).

Click here for a web-based demo.

$ python nextrip.py "Express - Target - Hwy 252 and 73rd Av P&R - Mpls" "Target North Campus Building F" "south"
4 Minutes

$ python nextrip.py "METRO Blue Line" "Target Field Station Platform 1" "south"
57 Minutes

$ python nextrip.py "Nonexistent Route" "Target Field Station Platform 1" "south"
Error: Route not found

Installation

If you have git installed:

pip install --upgrade git+https://github.com/jkchen2/NexTriPy.git

Without git:

pip install --upgrade https://github.com/jkchen2/NexTriPy/tarball/master

Example

# Create a NexTrip wrapper object
from nextrip import NexTrip
nt = NexTrip()

# METRO Blue cardinal directions
dirs = nt.directions(901)

# Get stops in the first direction provided
stops = nt.stops(901, dirs[0]['Value'])

# Print the last stop's code and name
print('{0[Value]}: {0[Text]}'.format(stops[-1]))

For a more extensive example, see the wrapper documentation, the demo function source, and the demo server source.

See the server branch for more information on the demo API server.

Releases

No releases published

Packages

No packages published

Languages