Transportation — entry 008 of 69
Bay Area Rapid Transit
Official real-time transit API for Bay Area Rapid Transit, covering the BART rail network across San Francisco, Oakland, and the wider East Bay. Endpoints return station lists, real-time and scheduled arrival predictions (ETD), route and schedule data, and system advisories in XML or JSON, accessed with a free shared or self-registered API key.
BART is the rapid transit system of the San Francisco Bay Area. Its legacy API gives real-time departure estimates, schedules, and station data. Every request needs a key parameter.
GreatAPIs Score
Auth quickstart
- Register for your own key at
https://api.bart.gov/api/register.aspx. The registration page is titled "BART API Key Registration". - Add the key as the
keyquery parameter on every call. - For a first test, use the public key
MW9S-E7SL-26DU-VV8V. BART prints it in its own examples athttps://api.bart.gov/docs/overview/examples.aspx. It worked in a live probe. Use your own key in production.
Your key is stored only in this browser (localStorage) and sent directly to the API — never to greatapis.
Get live departures for a station
GEThttps://api.bart.gov/api/etd.aspx?cmd=etd&orig=12th&key=MW9S-E7SL-26DU-VV8V&json=y
{"?xml":{"@version":"1.0","@encoding":"utf-8"},"root":{"@id":"1","uri":{"#cdata-section":"http://api.bart.gov/api/etd.aspx?cmd=etd&orig=12th&json=y"},"date":"09/28/2026","time":"05:03:03 PM PDT","station":[{"name":"12th St. Oakland City Center","abbr":"12TH","etd":[{"destination":"Antioch","abbreviation":"ANTC","limited":"0","estimate":[{"minutes":"11","platform":"3","direction":"North","length":"9","color":"YELLOW","hexcolor":"#ffff33","bikeflag":"1","delay":"66","cancelflag":"0","dynamicflag":"0"}]}]}],"message":""}}The etd array is truncated to its first destination, and its estimate array to its first train. The live call returned 6 destinations with 3 estimates each. The estimate object is unchanged.
Developer reference
Gotchas & limits
- Add
json=y. Without it, the same call returns XML (<?xml version="1.0" ...><root>...). - The JSON is converted from XML. The top-level key is
?xml, and the data sits underroot. Text nodes appear as#cdata-section, and every number is a string ("minutes":"12"). - BART's docs show
<minutes>Leaving</minutes>as a possible value.minutescan be the wordLeavinginstead of a number. Test for that before you parse it. - A bad key returns HTTP
400with a JSON error body:{"root":{"message":{"error":{"text":"Invalid key","details":"The api key was missing or invalid."}}}}. - A bad station code returns HTTP
400with"Invalid orig":The orig station parameter ZZZZ is missing or invalid.Station codes are the four-letter abbreviations, such as12TH. - The key sits in the URL. Do not put your own key in front-end code that you publish.