Overview

The BART API provides real-time train arrival predictions, station information, and service advisories for the Bay Area Rapid Transit system in the San Francisco Bay Area. It is an excellent beginner-friendly API because it requires only a free API key and returns straightforward XML or JSON data. Developers building commute apps, transit displays, or local Bay Area tools will find it especially useful.

Beginner Tip

Use the special API key 12345678 for testing during development as it works without registration. When you are ready to go live, register for a real key at api.bart.gov for production use.

Available Data

The kind of data this API exposes, based on its documentation. We could not call the endpoint to confirm the exact field names.

prediction result with confidence score
input name or text
statistical data

Example Response

Illustrative shape only — we were not able to call this endpoint (it requires credentials or exposes no public sample URL), so the fields below show the kind of data this API returns rather than a recorded response.

JSON Response · Illustrative
{
  "route": "Line 1",
  "origin": "Station A",
  "destination": "Station B",
  "departure": "08:30",
  "arrival": "09:15",
  "status": "On Time",
  "delays_min": 0
}

Field Reference

name Full name of the origin station.
abbr Station abbreviation code used in API requests.
etd List of estimated time of departure objects grouped by destination.
estimate.minutes Minutes until the train departs; Leaving means the train is at the platform now.
estimate.platform Platform number where the train will arrive.
estimate.length Number of cars in the train consist.

Implementation Example

Calls a real endpoint of this API. Replace any placeholder credentials with your own key.

Request
const url = "http://api.bart.gov/api/etd.aspx?cmd=etd&orig=EMBR&key=MW9S-E7SL-26DU-VV8V&json=y";
// Replace headers or query params with the values required by this API.
const response = await fetch(url, {
  headers: {
  "X-API-Key": "YOUR_API_KEY"
  }
});
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();
console.log(data);

What Can You Build?

Note: These code examples are AI-generated and unverified. Always refer to the official API documentation for accurate usage.

Common Errors & Troubleshooting

Generated guidance based on this API's documentation, not observed by us. Treat it as a starting point and check against the provider's own error reference.

No predictions returned The station abbreviation is incorrect or service is not running at that time.
Use the /api/stn.aspx?cmd=stns endpoint to retrieve the valid list of station abbreviations.
XML returned instead of JSON The json=y parameter was omitted from the request.
Append json=y to your request URL to receive a JSON response instead of XML.
Invalid API key error Expired or incorrect API key supplied.
Use the demo key MW9S-E7SL-26DU-VV8V for testing or register for a free key at api.bart.gov.

Metadata Score Breakdown

Estimated from metadata — endpoint not independently tested

This score is estimated from observable metadata — HTTPS support, authentication model, declared CORS, and documentation reachability — because the API requires authentication or exposes no publicly testable endpoint. The five-signal breakdown is only shown for live-tested APIs.

Metadata estimate · endpoint not independently tested

Technical Specifications

Auth API Key
HTTPS NO
CORS UNKNOWN
Category Transportation
Difficulty Intermediate
Listing details not endpoint-verified

Related Tags

Similar APIs

View All →