Transit API Wrapper¶
This documentation explains the methods of the Transit
object. For the specific fields on the objects returned by these methods,
see the official documentation.
-
class
penn.transit.
Transit
(bearer, token)[source]¶ The client for Transit. Used to make requests to the API.
Parameters: - bearer – The user code for the API
- token – The password code for the API
Usage:
>>> from penn import Transit >>> trans = Transit('MY_USERNAME_TOKEN', 'MY_PASSWORD_TOKEN')
-
apc
(start_date, end_date)[source]¶ Return all APC data packets in date range
Parameters: - start_date – The starting date for the query.
- end_date – The end date for the query.
>>> import datetime >>> today = datetime.date.today() >>> trans.apc(today - datetime.timedelta(days=1), today))
-
mdt
(start_date, end_date)[source]¶ Return all MDT data packets in date range
Parameters: - start_date – The starting date for the query.
- end_date – The end date for the query.
>>> import datetime >>> today = datetime.date.today() >>> trans.mdt(today - datetime.timedelta(days=1), today))
-
stoptimes
(start_date, end_date)[source]¶ Return all stop times in the date range
Parameters: - start_date – The starting date for the query.
- end_date – The end date for the query.
>>> import datetime >>> today = datetime.date.today() >>> trans.stoptimes(today - datetime.timedelta(days=1), today)
-
transapc
(start_date, end_date)[source]¶ Return detail of boardings, alightings, by vehicle and stop, including the passenger load leaving the stop (this is only for vehicles equipped with APC hardware)
Parameters: - start_date – The starting date for the query.
- end_date – The end date for the query.
>>> import datetime >>> today = datetime.date.today() >>> trans.transapc(today - datetime.timedelta(days=1), today))