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

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.2.dev0.tar.gz (4.5 kB view details)

Uploaded Source

File details

Details for the file pymbta3-0.0.2.dev0.tar.gz.

File metadata

  • Download URL: pymbta3-0.0.2.dev0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.0

File hashes

Hashes for pymbta3-0.0.2.dev0.tar.gz
Algorithm Hash digest
SHA256 2a2c6459472c656071e95ff892112b828050a89f551d5cfe552a44175e515990
MD5 339f41dd499a7a08dfb8f5858bbaf152
BLAKE2b-256 3db50887ea1b289b6c6a809e788cbcdfc8e4f68955a96a54de5acb409f8f7bd3

See more details on using hashes here.

Supported by

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