Skip to main content

No project description provided

Project description

pymbta3

Python wrapper for the MBTA v3 API

Install

pip install pymbta3

Usage

To get data from the MBTA API, import the library and call the object with your API key. The API Key may also be stored in the environment variable MBTA_API_KEY.

from pymbta3 import Alerts

at = Alerts(key=YOUR_API_KEY_HERE)

# Find all alerts affecting Alewife
alerts = at.get(stop='place-alfcl')

# Find the short header for the alert
for alert in alerts['data']:
    print(alert['attributes']['short_header'])

Multiple values can be passed in for most filters.

Alerts affecting Orange and Red lines

alerts = at.get(route=['Orange', 'Red'])

Alerts affecting parking or Wheelchair use

alerts = at.get(activity=['PARK_CAR', 'USING_WHEELCHAIR'])

Include other data

Return the stop data along with routes

from pymbta3 import Routes

rt = Routes(key=YOUR_API_KEY_HERE)

# Find all Route data for the Red Line
routes = rt.get(route='Red', include='stops')

API Methods Implented

  • Alerts
  • Routes
  • Stops
  • Vehicles
  • Predictions
  • Schedules

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pymbta3-0.0.4.dev0.tar.gz (5.2 kB view hashes)

Uploaded Source

Built Distribution

pymbta3-0.0.4.dev0-py3-none-any.whl (5.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page