Real-time MBTA transit predictions for Boston-area subway, bus, commuter rail, and ferry. Query departure times, search stops/routes, check service alerts, and run a live dashboard. Use when asked about Boston transit, T schedules, when to leave for the train, or MBTA service status.
Query real-time MBTA predictions via the v3 API.
```bash
export MBTA_API_KEY=your_key_here # Free at https://api-v3.mbta.com/portal
pip install requests pyyaml flask # flask only needed for dashboard
```
```bash
cd skills/mbta
python scripts/mbta.py next --stop place-alfcl # Alewife
python scripts/mbta.py next --stop place-harsq --route Red # Harvard, Red Line only
python scripts/mbta.py stops --search "Porter"
python scripts/mbta.py stops --search "Kendall"
python scripts/mbta.py routes # All routes
python scripts/mbta.py routes --type rail # Subway only
python scripts/mbta.py routes --type bus # Buses
python scripts/mbta.py alerts # All alerts
python scripts/mbta.py alerts --route Red # Red Line alerts
python scripts/mbta.py departures --config config.yaml
python scripts/mbta.py dashboard --config config.yaml --port 6639
```
Edit `config.yaml` to set up your stops:
```yaml
panels:
- title: "My Station"
walk_minutes: 5 # Filter out trains you can't catch
services:
- label: "Red Line"
destination: "to Alewife"
route_id: "Red"
stop_id: "place-harsq"
direction_id: 0 # 0 or 1 for direction
limit: 3
```
Key fields:
```bash
python scripts/mbta.py stops --search "Davis"
python scripts/mbta.py routes --type rail
```
Add `--json` for machine-readable output:
```bash
python scripts/mbta.py next --stop place-alfcl --json
python scripts/mbta.py departures --config config.yaml --json
```
| Station | Stop ID |
|---------|---------|
| Alewife | place-alfcl |
| Harvard | place-harsq |
| Kendall/MIT | place-knncl |
| Park Street | place-pktrm |
| South Station | place-sstat |
| North Station | place-north |
| Back Bay | place-bbsta |
| Downtown Crossing | place-dwnxg |
**"When's the next Red Line train?"**
```bash
python scripts/mbta.py next --stop place-alfcl --route Red
```
**"Should I leave now to catch the T?"**
Check departures against their walk time. If next train is ≤ walk_minutes, say "leave now!"
**"Are there any delays on the Orange Line?"**
```bash
python scripts/mbta.py alerts --route Orange
```
**"What buses go to Harvard?"**
```bash
python scripts/mbta.py stops --search "Harvard"
python scripts/mbta.py next --stop <stop_id>
```
Leave a review
No reviews yet. Be the first to review this skill!