MBTA APImbta.com ↗
Access real-time MBTA subway, bus, and commuter rail departures, service alerts, stop details, and route schedules for Greater Boston via a simple REST API.
What is the MBTA API?
This API exposes 7 endpoints covering the full MBTA network — subway, bus, and commuter rail — across Greater Boston. Use get_stop_departures to retrieve real-time and scheduled departure predictions for any stop, including arrival and departure times, trip headsigns, and route identifiers. Companion endpoints return route lists, stop-level accessibility data, parking, fare facilities, and active service alerts.
No input parameters required.
curl -X GET 'https://api.parse.bot/scraper/d20edddc-f498-4ec2-afaf-f3b075eef2af/get_subway_lines' \ -H 'X-API-Key: $PARSE_API_KEY'
Typed, relational, agent-ready
A generated client with real types, enums, and the links between objects — the structure a flat JSON response can't carry. Autocompletes in your editor and reads cleanly to coding agents.
- Fully typed · autocompletes
- Objects link to objects
- Typed errors & pagination
Typed Python client. Set up the SDK in your uv project, then pull this API’s typed client:
uv add parse-sdk uv run parse init uv run parse add --marketplace mbta-com-api
uv run parse add --marketplace pulls a pinned snapshot of this canonical API — it won’t change underneath you. To customize it, subscribe and swap to your own copy.
from parse_apis.mbta_transit_api import MBTA, SubwayLine, Route, Stop, StopInfo, Departure, Alert, Direction
mbta = MBTA()
# List all subway lines
for line in mbta.subwaylines.list():
print(line.id, line.name, line.url)
# Get route details for the Red Line southbound
red = mbta.route(id="Red")
detail = red.details(direction_id=Direction.SOUTHBOUND)
print(detail.stop_tree.starting_nodes, detail.stop_tree.edges)
# Get station info for South Station
station = mbta.stop(id="place-sstat").info()
print(station.name, station.municipality, station.latitude, station.longitude)
# List departures from South Station
for departure in mbta.stop(id="place-sstat").departures.list():
print(departure.departure_time, departure.platform_stop_id, departure.schedule_id)
# List alerts for Red Line
for alert in mbta.route(id="Red").alerts.list():
print(alert.id, alert.header, alert.severity, alert.effect)
Retrieve all MBTA subway lines. Returns each line's ID, display name, and schedule URL. The subway network includes Red, Orange, Blue, Green, and Mattapan lines.
No input parameters required.
{
"type": "object",
"fields": {
"lines": "array of subway line objects with id, name, and url"
},
"sample": {
"data": {
"lines": [
{
"id": "Red",
"url": "https://www.mbta.com/schedules/Red",
"name": "Red Line"
},
{
"id": "Mattapan",
"url": "https://www.mbta.com/schedules/Mattapan",
"name": "Mattapan Line"
},
{
"id": "Orange",
"url": "https://www.mbta.com/schedules/Orange",
"name": "Orange Line"
},
{
"id": "Blue",
"url": "https://www.mbta.com/schedules/Blue",
"name": "Blue Line"
},
{
"id": "Green",
"url": "https://www.mbta.com/schedules/Green",
"name": "Green Line"
}
]
},
"status": "success"
}
}About the MBTA API
Route and Stop Discovery
Three list endpoints cover the MBTA's main service types: get_subway_lines returns all subway lines with their IDs and schedule URLs, get_bus_routes covers Silver Line, crosstown, and local bus routes, and get_commuter_rail_lines returns all commuter rail lines (e.g. CR-Fitchburg). Each object in those arrays includes an id suitable for passing directly to get_route_details or get_route_alerts.
Route Details and Stop Topology
get_route_details accepts a route_id (e.g. Red, 1, CR-Fitchburg) and an optional direction_id (0 or 1). The response includes a stop_tree with a starting_nodes array and a by_id map — each stop entry carries station features, accessibility information, parking details, and connections to other lines. route_stop_lists provides an ordered stop sequence for the route, and other_route_stops lists stops at shared stations served by additional routes.
Real-Time Departures and Stop Info
get_stop_departures takes a stop_id (e.g. place-sstat for South Station, place-harsq for Harvard Square) and returns an array of departure objects. Each includes arrival_time, departure_time, a trip object with headsign, direction_id, and id, plus the route.id and platform_stop_id. get_stop_info returns static station data for the same stop IDs: name, address, municipality, lat/lon, accessibility features, parking lots, fare facilities, bike storage, and child stop IDs.
Service Alerts
get_route_alerts accepts a comma-separated list of route IDs (e.g. Red,Orange) and returns current alerts. Each alert object includes header, description, effect, cause, severity, priority, active_period, informed_entity, and lifecycle. This makes it straightforward to surface disruptions alongside departure data in any transit-facing application.
The MBTA API is a managed, monitored endpoint for mbta.com — not a raw scraper you maintain. Every endpoint is automatically health-checked on a schedule, and when mbta.com changes and a check fails, the API is automatically queued for repair and re-verified. It is built to keep working as the site underneath it changes.
This isn't an official mbta.com API — it's an independent, maintained REST wrapper over public data. Where the source has no official API (or only a limited one), Parse gives you a stable contract over a source that never promised one, and keeps it current. Need a new endpoint or field? You can revise it yourself in plain English and the agent rebuilds it against the live site in minutes — contributing the change back to the shared API is free.
Will this API break when the source site changes?+
Is this an official API from the source site?+
Can I fix or extend this API myself if I need a new endpoint or field?+
What happens if I call an endpoint that has an issue?+
- Display real-time next-departure boards for any MBTA subway or bus stop using
get_stop_departures - Build a commute planner that cross-references departure times with active service alerts from
get_route_alerts - Show accessible station details — elevator availability, parking, fare facilities — from
get_stop_info - Map all stops along a subway or commuter rail line using the ordered stop lists from
get_route_details - Identify transfer points between lines using the
connectionsdata in thestop_treeresponse - Power a service-disruption notification system by polling
get_route_alertsfor severity and active_period changes - Enumerate all MBTA bus routes and their schedule URLs for a static transit reference tool
| Tier | Price | Credits/month | Rate limit |
|---|---|---|---|
| Free | $0/mo | 100 | 5 req/min |
| Hobby | $30/mo | 1,000 | 20 req/min |
| Developer | $100/mo | 5,000 | 100 req/min |
One credit = one API call regardless of which marketplace API you call. Exceeding the rate limit returns a 429 response. Authenticate with the X-API-Key header.
Does the MBTA have an official developer API?+
What does `get_stop_departures` return, and how is it different from a static schedule?+
get_stop_departures returns both real-time predictions and scheduled departures for a given stop. Each departure object includes arrival_time, departure_time, the trip's headsign and direction_id, and the route.id. When live vehicle data is available, the times reflect current predictions rather than the fixed timetable.Does `get_route_details` cover ferry or other non-rail/bus services?+
Can I retrieve trip or vehicle position data — for example, a bus's current GPS location?+
Are service alerts returned for all route types, or only certain ones?+
get_route_alerts works with any route ID from the subway, bus, or commuter rail lists — pass a single ID or a comma-separated set like Red,Orange. The response fields include effect, cause, severity, priority, and active_period, so you can filter by urgency or time window in your own application logic.