MBTA service API. https://www.mbta.com Source code: https://github.com/mbta/api
This Python package is automatically generated by the OpenAPI Generator project:
- API version: 3.0
- Package version: 1.0.0
- Build package: org.openapitools.codegen.languages.PythonClientCodegen For more information, please visit https://groups.google.com/forum/#!forum/massdotdevelopers
Python 2.7 and 3.4+
If the python package is hosted on a repository, you can install directly using:
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 openapi_clientInstall 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 openapi_clientPlease follow the installation procedure and then run the following:
from __future__ import print_function
import time
import openapi_client
from openapi_client.rest import ApiException
from pprint import pprint
configuration = openapi_client.Configuration()
# Configure API key authorization: api_key_in_header
configuration.api_key['x-api-key'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['x-api-key'] = 'Bearer'
configuration = openapi_client.Configuration()
# Configure API key authorization: api_key_in_query
configuration.api_key['api_key'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['api_key'] = 'Bearer'
# Defining host is optional and default to http://localhost
configuration.host = "http://localhost"
# Enter a context with an instance of the API client
with openapi_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = openapi_client.AlertApi(api_client)
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)
fields_alert = 'fields_alert_example' # str | Fields to include with the response. Multiple fields **MUST** be a comma-separated (U+002C COMMA, \",\") list. Note that fields can also be selected for included data types: see the [V3 API Best Practices](https://www.mbta.com/developers/v3-api/best-practices) for an example. (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. Multiple `route_type` **MUST** be a comma-separated (U+002C COMMA, \",\") list. (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)
filter_id = '1,2' # str | Filter by multiple IDs. Multiple IDs **MUST** be a comma-separated (U+002C COMMA, \",\") list. (optional)
filter_banner = 'true' # str | When combined with other filters, filters by alerts with or without a banner. **MUST** be \"true\" or \"false\". (optional)
filter_datetime = '2018-05-09T13:06:00-04:00' # str | Filter to alerts that are active at a given time (ISO8601 format). Additionally, the string \"NOW\" can be used to filter to alerts that are currently active. (optional)
filter_lifecycle = 'filter_lifecycle_example' # str | Filters by an alert's lifecycle. **MUST** be a comma-separated (U+002C COMMA, \",\") list. (optional)
filter_severity = 'filter_severity_example' # str | Filters alerts by list of severities. **MUST** be a comma-separated (U+002C COMMA, \",\") list. Example: filter[severity]=3,4,10 returns alerts with severity levels 3, 4 and 10. (optional)
try:
api_response = api_instance.api_web_alert_controller_index(page_offset=page_offset, page_limit=page_limit, sort=sort, fields_alert=fields_alert, 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, filter_id=filter_id, filter_banner=filter_banner, filter_datetime=filter_datetime, filter_lifecycle=filter_lifecycle, filter_severity=filter_severity)
pprint(api_response)
except ApiException as e:
print("Exception when calling AlertApi->api_web_alert_controller_index: %s\n" % e)
All URIs are relative to http://localhost
- ActivePeriod
- Alert
- AlertResource
- AlertResourceAttributes
- AlertResourceRelationships
- AlertResourceRelationshipsFacility
- AlertResourceRelationshipsFacilityData
- AlertResourceRelationshipsFacilityLinks
- Alerts
- BadRequest
- BadRequestErrors
- BadRequestSource
- Facilities
- Facility
- FacilityProperty
- FacilityResource
- FacilityResourceAttributes
- FacilityResourceRelationships
- Forbidden
- ForbiddenErrors
- InformedEntity
- Line
- LineResource
- LineResourceAttributes
- Lines
- LiveFacilities
- LiveFacility
- LiveFacilityResource
- LiveFacilityResourceAttributes
- NotFound
- NotFoundErrors
- NotFoundSource
- PredictionResource
- PredictionResourceAttributes
- PredictionResourceRelationships
- PredictionResourceRelationshipsAlerts
- PredictionResourceRelationshipsAlertsData
- PredictionResourceRelationshipsAlertsLinks
- PredictionResourceRelationshipsRoute
- PredictionResourceRelationshipsRouteData
- PredictionResourceRelationshipsRouteLinks
- PredictionResourceRelationshipsSchedule
- PredictionResourceRelationshipsScheduleData
- PredictionResourceRelationshipsScheduleLinks
- PredictionResourceRelationshipsStop
- PredictionResourceRelationshipsStopData
- PredictionResourceRelationshipsStopLinks
- PredictionResourceRelationshipsTrip
- PredictionResourceRelationshipsTripData
- PredictionResourceRelationshipsTripLinks
- PredictionResourceRelationshipsVehicle
- PredictionResourceRelationshipsVehicleData
- PredictionResourceRelationshipsVehicleLinks
- Predictions
- Route
- RoutePattern
- RoutePatternResource
- RoutePatternResourceAttributes
- RoutePatternResourceRelationships
- RoutePatternResourceRelationshipsRepresentativeTrip
- RoutePatternResourceRelationshipsRepresentativeTripData
- RoutePatternResourceRelationshipsRepresentativeTripLinks
- RoutePatterns
- RouteResource
- RouteResourceAttributes
- Routes
- ScheduleResource
- ScheduleResourceAttributes
- ScheduleResourceRelationships
- ScheduleResourceRelationshipsPrediction
- ScheduleResourceRelationshipsPredictionData
- ScheduleResourceRelationshipsPredictionLinks
- Schedules
- SchedulesLinks
- Service
- ServiceIncluded
- ServiceLinks
- ServiceResource
- ServiceResourceAttributes
- Services
- Shape
- ShapeResource
- ShapeResourceAttributes
- ShapeResourceRelationships
- ShapeResourceRelationshipsStops
- ShapeResourceRelationshipsStopsData
- ShapeResourceRelationshipsStopsLinks
- Shapes
- Stop
- StopResource
- StopResourceAttributes
- StopResourceRelationships
- StopResourceRelationshipsParentStation
- StopResourceRelationshipsParentStationData
- StopResourceRelationshipsParentStationLinks
- Stops
- TooManyRequests
- TooManyRequestsErrors
- Trip
- TripResource
- TripResourceAttributes
- TripResourceRelationships
- TripResourceRelationshipsRoutePattern
- TripResourceRelationshipsRoutePatternData
- TripResourceRelationshipsRoutePatternLinks
- TripResourceRelationshipsService
- TripResourceRelationshipsServiceData
- TripResourceRelationshipsServiceLinks
- TripResourceRelationshipsShape
- TripResourceRelationshipsShapeData
- TripResourceRelationshipsShapeLinks
- Trips
- Vehicle
- VehicleResource
- VehicleResourceAttributes
- VehicleResourceRelationships
- Vehicles
- Type: API key
- API key parameter name: x-api-key
- Location: HTTP header
- Type: API key
- API key parameter name: api_key
- Location: URL query string