Skip to content

jbarciauskas/mbtaapi3

Repository files navigation

mbtaapi

MBTA service API. https://www.mbta.com

This Python package is automatically generated by the Swagger Codegen project:

Requirements.

Python 2.7 and 3.4+

Installation & Usage

pip install

If the python package is hosted on Github, you can install directly from Github

pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git

(you may need to run pip with root permission: sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git)

Then import the package:

import mbtaapi 

Setuptools

Install via Setuptools.

python setup.py install --user

(or sudo python setup.py install to install the package for all users)

Then import the package:

import mbtaapi

Getting Started

Please follow the installation procedure and then run the following:

from __future__ import print_function
import time
import mbtaapi
from mbtaapi.rest import ApiException
from pprint import pprint
# create an instance of the API class
api_instance = mbtaapi.AlertApi()
page_offset = 56 # int | Offset (0-based) of first element in the page (optional)
page_limit = 56 # int | Max number of elements to return (optional)
sort = 'sort_example' # str | Results can be [sorted](http://jsonapi.org/format/#fetching-sorting) by the id or any `/data/{index}/attributes` key. Assumes ascending; may be prefixed with '-' for descending  | JSON pointer | Direction | `sort`     | |--------------|-----------|------------| | `/data/{index}/attributes/active_period` | ascending | `active_period` | | `/data/{index}/attributes/active_period` | descending | `-active_period` | | `/data/{index}/attributes/banner` | ascending | `banner` | | `/data/{index}/attributes/banner` | descending | `-banner` | | `/data/{index}/attributes/cause` | ascending | `cause` | | `/data/{index}/attributes/cause` | descending | `-cause` | | `/data/{index}/attributes/created_at` | ascending | `created_at` | | `/data/{index}/attributes/created_at` | descending | `-created_at` | | `/data/{index}/attributes/description` | ascending | `description` | | `/data/{index}/attributes/description` | descending | `-description` | | `/data/{index}/attributes/effect` | ascending | `effect` | | `/data/{index}/attributes/effect` | descending | `-effect` | | `/data/{index}/attributes/effect_name` | ascending | `effect_name` | | `/data/{index}/attributes/effect_name` | descending | `-effect_name` | | `/data/{index}/attributes/header` | ascending | `header` | | `/data/{index}/attributes/header` | descending | `-header` | | `/data/{index}/attributes/informed_entity` | ascending | `informed_entity` | | `/data/{index}/attributes/informed_entity` | descending | `-informed_entity` | | `/data/{index}/attributes/lifecycle` | ascending | `lifecycle` | | `/data/{index}/attributes/lifecycle` | descending | `-lifecycle` | | `/data/{index}/attributes/service_effect` | ascending | `service_effect` | | `/data/{index}/attributes/service_effect` | descending | `-service_effect` | | `/data/{index}/attributes/severity` | ascending | `severity` | | `/data/{index}/attributes/severity` | descending | `-severity` | | `/data/{index}/attributes/short_header` | ascending | `short_header` | | `/data/{index}/attributes/short_header` | descending | `-short_header` | | `/data/{index}/attributes/timeframe` | ascending | `timeframe` | | `/data/{index}/attributes/timeframe` | descending | `-timeframe` | | `/data/{index}/attributes/updated_at` | ascending | `updated_at` | | `/data/{index}/attributes/updated_at` | descending | `-updated_at` | | `/data/{index}/attributes/url` | ascending | `url` | | `/data/{index}/attributes/url` | descending | `-url` |   (optional)
api_key = 'api_key_example' # str | Key for API access.  Without api_key, requests will be tracked by IP address and have stricter rate limit. [Register for a key](/register)  (optional)
include = 'include_example' # str | Relationships to include.  * `stops` * `routes` * `trips` * `facilities`  The value of the include parameter **MUST** be a comma-separated (U+002C COMMA, \",\") list of relationship paths. A relationship path is a dot-separated (U+002E FULL-STOP, \".\") list of relationship names. [JSONAPI \"include\" behavior](http://jsonapi.org/format/#fetching-includes)    (optional)
filter_activity = 'BOARD,EXIT,RIDE' # str | Filter to alerts for only those activities (`/data/{index}/attributes/informed_entity/activities/{activity_index}`) matching.  Multiple activities **MUST** be a comma-separated (U+002C COMMA, \",\") list.  An activity affected by an alert.  | Value                | Description                                                                                                                                                                                                                                                                       | |----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `\"BOARD\"`            | Boarding a vehicle. Any passenger trip includes boarding a vehicle and exiting from a vehicle.                                                                                                                                                                                    | | `\"BRINGING_BIKE\"`    | Bringing a bicycle while boarding or exiting.                                                                                                                                                                                                                                     | | `\"EXIT\"`             | Exiting from a vehicle (disembarking). Any passenger trip includes boarding a vehicle and exiting a vehicle.                                                                                                                                                                      | | `\"PARK_CAR\"`         | Parking a car at a garage or lot in a station.                                                                                                                                                                                                                                    | | `\"RIDE\"`             | Riding through a stop without boarding or exiting.. Not every passenger trip will include this -- a passenger may board at one stop and exit at the next stop.                                                                                                                    | | `\"STORE_BIKE\"`       | Storing a bicycle at a station.                                                                                                                                                                                                                                                   | | `\"USING_ESCALATOR\"`  | Using an escalator while boarding or exiting (should only be used for customers who specifically want to avoid stairs.)                                                                                                                                                           | | `\"USING_WHEELCHAIR\"` | Using a wheelchair while boarding or exiting. Note that this applies to something that specifically affects customers who use a wheelchair to board or exit; a delay should not include this as an affected activity unless it specifically affects customers using wheelchairs.  |   ## Special Values  * If the filter is not given OR it is empty, then defaults to [\"BOARD\", \"EXIT\", \"RIDE\"]. * If the value `\"ALL\"` is used then all alerts will be returned, not just those with the default activities.  ## Accessibility  The default activities cover if boarding, exiting, or riding is generally affected for all riders by the alert. If ONLY wheelchair using riders are affected, such as if a ramp, lift, or safety system for wheelchairs is affected, only the `\"USING_WHEELCHAIR\"` activity will be set. To cover wheelchair using rider, filter on the defaults and `\"USING_WHEELCHAIR\"`: `filter[activity]=USING_WHEELCHAIR,BOARD,EXIT,RIDE`.  Similarly for riders with limited mobility that need escalators, `\"USING_ESCALATOR\"` should be added to the defaults: `filter[activity]=USING_ESCALATOR,BOARD,EXIT,RIDE`.   (optional) (default to BOARD,EXIT,RIDE)
filter_route_type = 'filter_route_type_example' # str | Filter by route type https://developers.google.com/transit/gtfs/reference/routes-file (optional)
filter_direction_id = 'filter_direction_id_example' # str | Filter by direction of travel along the route.  The meaning of `direction_id` varies based on the route. You can programmatically get the direction names from `/routes` `/data/{index}/attributes/direction_names` or `/routes/{id}` `/data/attributes/direction_names`.     (optional)
filter_route = 'filter_route_example' # str | Filter by `/data/{index}/relationships/route/data/id`. Multiple `/data/{index}/relationships/route/data/id` **MUST** be a comma-separated (U+002C COMMA, \",\") list. (optional)
filter_stop = 'filter_stop_example' # str | Filter by `/data/{index}/relationships/stop/data/id`. Multiple `/data/{index}/relationships/stop/data/id` **MUST** be a comma-separated (U+002C COMMA, \",\") list. (optional)
filter_trip = 'filter_trip_example' # str | Filter by `/data/{index}/relationships/trip/data/id`. Multiple `/data/{index}/relationships/trip/data/id` **MUST** be a comma-separated (U+002C COMMA, \",\") list. (optional)
filter_facility = 'filter_facility_example' # str | Filter by `/data/{index}/relationships/facility/data/id`. Multiple `/data/{index}/relationships/facility/data/id` **MUST** be a comma-separated (U+002C COMMA, \",\") list. (optional)

try:
    # 
    api_response = api_instance.api_web_alert_controller_index(page_offset=page_offset, page_limit=page_limit, sort=sort, api_key=api_key, include=include, filter_activity=filter_activity, filter_route_type=filter_route_type, filter_direction_id=filter_direction_id, filter_route=filter_route, filter_stop=filter_stop, filter_trip=filter_trip, filter_facility=filter_facility)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling AlertApi->api_web_alert_controller_index: %s\n" % e)

Documentation for API Endpoints

All URIs are relative to https://localhost

Class Method HTTP request Description
AlertApi api_web_alert_controller_index GET /alerts
AlertApi api_web_alert_controller_show GET /alerts/{id}
FacilityApi api_web_facility_controller_index GET /facilities
FacilityApi api_web_facility_controller_show GET /facilities/{id}
PredictionApi api_web_prediction_controller_index GET /predictions
RouteApi api_web_route_controller_index GET /routes
RouteApi api_web_route_controller_show GET /routes/{id}
ScheduleApi api_web_schedule_controller_index GET /schedules
ShapeApi api_web_shape_controller_index GET /shapes
ShapeApi api_web_shape_controller_show GET /shapes/{id}
StopApi api_web_stop_controller_index GET /stops
StopApi api_web_stop_controller_show GET /stops/{id}
TripApi api_web_trip_controller_index GET /trips
TripApi api_web_trip_controller_show GET /trips/{id}
VehicleApi api_web_vehicle_controller_index GET /vehicles
VehicleApi api_web_vehicle_controller_show GET /vehicles/{id}

Documentation For Models

Documentation For Authorization

All endpoints do not require authorization.

Author

developer@mbta.com

About

Auto-generated Python library for MBTA-v3 API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors