BART APIbart.gov ↗
Get live BART train departure estimates, station codes, and service alerts. 3 endpoints covering all Bay Area Rapid Transit stations in real time.
What is the BART API?
The BART API provides 3 endpoints for real-time Bay Area Rapid Transit data: station listings with abbreviated codes, live platform-level departure estimates via get_departures, and current service alerts including elevator and escalator outages. Every departure response includes destination, estimated times, and car counts, making it suitable for building transit displays, commute tools, or service-monitoring integrations.
No input parameters required.
curl -X GET 'https://api.parse.bot/scraper/a3c68648-205d-4b57-a97b-b4d0bf6edcab/get_stations' \ -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 bart-gov-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.
"""Walkthrough: BART Real-Time Departures API — bounded, re-runnable."""
from parse_apis.bart_real_time_departures_api import Bart, StationCode, StationNotFound
client = Bart()
# List all stations — each has a name and code for further lookups.
for station in client.stations.list(limit=5):
print(station.name, station.code)
# Drill into one station's real-time departures via constructible resource.
embr = client.station(code=StationCode.EMBR)
board = embr.departures()
print(board.station_name, board.updated)
for platform in board.platforms:
print(platform.name)
for dep in platform.departures:
print(f" {dep.destination}: {dep.estimates[0].time}, {dep.estimates[0].cars}")
# Fetch system-wide alerts and advisories in one call.
alerts = client.alertreports.fetch()
print(alerts.as_of)
for sa in alerts.current_service_alerts:
print(sa.type, sa.message[:80])
for eq in alerts.escalator_alerts:
print(eq.station, eq.location, eq.reason)
# Typed error handling for an invalid station code.
try:
bad = client.station(code="ZZZZ")
bad.departures()
except StationNotFound as exc:
print(f"Station not found: {exc.station_code}")
print("exercised: stations.list / station.departures / alertreports.fetch / StationNotFound")
Fetch the list of all BART stations and their abbreviated codes. Each station has a human-readable name and a short code (e.g. 'EMBR' for Embarcadero). These codes are required input for get_departures.
No input parameters required.
{
"type": "object",
"fields": {
"stations": "array of station objects each containing name (string) and code (string)"
},
"sample": {
"data": {
"stations": [
{
"code": "12TH",
"name": "12th St. Oakland City Center"
},
{
"code": "EMBR",
"name": "Embarcadero"
},
{
"code": "MONT",
"name": "Montgomery St."
}
]
},
"status": "success"
}
}About the BART API
Station Lookup and Departure Estimates
Start with get_stations to retrieve the full list of BART stations. Each object in the response includes a name (e.g. "Embarcadero") and a code (e.g. EMBR). These codes are required as the station_code parameter for get_departures. Passing an unrecognized or malformed code to get_departures returns a stale_input error, so always source codes from get_stations rather than hardcoding them.
Real-Time Platform Departures
get_departures accepts a single required parameter, station_code, and returns a station_name, an updated timestamp, and a platforms array. Each platform object contains a name and a departures array whose entries include the destination and estimates — the per-train countdown values and car counts. This structure mirrors how BART displays information on its own departure boards, organized by direction and platform.
Alerts and Advisories
get_alerts requires no inputs and returns a snapshot of the current system status as of an as_of timestamp. The response separates content into six arrays: current_service_alerts (each with a type and message), planned_service_advisories, elevator_alerts, escalator_alerts, planned_elevator_advisories, and planned_escalator_advisories. Elevator and escalator alert objects include station, station_code, location, reason, and estimated_return, which is useful for accessibility-aware routing tools. Planned advisory objects carry a description and a url for further detail.
The BART API is a managed, monitored endpoint for bart.gov — not a raw scraper you maintain. Every endpoint is automatically health-checked on a schedule, and when bart.gov 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 bart.gov 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?+
- Build a real-time departure board app for a specific station using get_departures platform and estimates data
- Send push notifications when elevator or escalator outages are reported at a commuter's home station via get_alerts elevator_alerts
- Display next-train countdowns on a smart home display by polling get_departures for a saved station_code
- Aggregate planned_service_advisories from get_alerts to surface weekend or holiday schedule changes to users
- Cross-reference escalator_alerts with station_code to warn wheelchair or mobility-aid users before they travel
- Monitor current_service_alerts messages in get_alerts to detect active disruptions and surface them in a commute app
- Enumerate all valid station codes once from get_stations to populate a station picker UI without hardcoding values
| 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.