Unofficial BART API Docs

An unofficial replacement for BART's Legacy API, created because the official version does not function as intended.

Ratelimits

As of right now, the API does not have enforced ratelimiting. However, it is kindly asked that you follow these limits when using the API. Failure to do so may result in an IP block from the service.

RouteRatelimit
getPredictions4 requests per minute
getStations2 requests per minute
getStation4 requests per minute
getAlerts4 requests per minute
getSchedule2 requests per minute

Caching

The API uses Varnish cache to reduce the load on BART’s website. This table describes the time responses will be cached.

RouteCache Time
getPredictions15 seconds
getStations3600 seconds
getStation3600 seconds
getAlerts500 seconds
getSchedule500 seconds

The age and x-cache headers are used to show whether a response has been cached. Age displays the age in seconds an item has been stored on the cache, while x-cache will display MISS for a uncached response, and HIT for a cached response.

Only responses with a “200 OK” HTTP status code will be cached.

If you have a compelling reason to bypass the cache, you can append a random query string (ie. ?foo=bar) to the end of all URLs. Please do not do this excessively. IP addresses that preform more than 25 ratelimit bypasses an hour may be blocked.

Logging

For security and product improvement, the following information is logged after all requests, and is stored with up to 30 days:

If you would not like your IP address to be logged, consider using Tor.

Site Health

Below is a measure of the API’s health and basic metrics.

Cache Hit/Miss RatioCache HitsCache MissesCache Space Used (Bytes)
0.89415589184473.91 MB

Contact

If you have any questions, feedback, or complaints, please contact me@trentwil.es.

Routes

Base URL: bart.trentwil.es


/api/v1/getPredictions/<station>

ParameterData TypeDescription
stationStringAbbreviation of the station, case does not matter.

Successful Response Example

GET https://bart.trentwil.es/api/v1/getPredictions/12TH
	
	{
	  "error": false,
	  "station": "12th St. Oakland City Center",
	  "estimates": [
		{
		  "lineTerminus": "Berryessa",
		  "lineColor": "Green",
		  "estimates": [
			{
			  "formatted": "6 car, 3 door train",
			  "doors": 3,
			  "cars": 6,
			  "timeFormatted": "8 min",
			  "time": 8
			},
			{
			  "formatted": "6 car, 3 door train",
			  "doors": 3,
			  "cars": 6,
			  "timeFormatted": "25 min",
			  "time": 25
			},
	...

Error Response

GET https://bart.trentwil.es/api/v1/getPredictions/bad_data
	
	{
	  "error": true,
	  "message": "Invalid station name"
	}

/api/v1/getStations

No parameters

Successful Response

GET https://bart.trentwil.es/api/v1/getStations
	
	{
	  "stations": [
		{
		  "stationName": "12th St. Oakland City Center",
		  "stationAbreviation": "12TH"
		},
		{
		  "stationName": "16th St. Mission (SF)",
		  "stationAbreviation": "16TH"
		},
		{
		  "stationName": "19th St. Oakland",
		  "stationAbreviation": "19TH"
		},
		{
		  "stationName": "24th St. Mission (SF)",
		  "stationAbreviation": "24TH"
		},
		{
		  "stationName": "Ashby (Berkeley)",
		  "stationAbreviation": "ASHB"
		},
		{
		  "stationName": "Antioch",
		  "stationAbreviation": "ANTC"
		},
	...

/api/v1/getStation/<station>

ParameterData TypeDescription
stationStringAbbreviation of the station, case does not matter.

Successful Response

GET https://bart.trentwil.es/api/v1/getStation/ROCK
	
	{
	  "address": "5660 College Avenue, Oakland, CA 94618",
	  "description": "Named for local rock outcroppings formed by the Hayward Fault, the Rockridge neighborhood is a vibrant residential neighborhood, retail and commercial district in Oakland.",
	  "map": "https://www.bart.gov/sites/default/files/documents/station/Rockridge.pdf",
	  "image": "https://www.bart.gov/sites/default/files/styles/station_intro_image/public/images/station/FOF%20Rockridge_07_MJA_08022021.jpg?itok=RCulyBoa",
	  "lines": [
		{
		  "line": "Yellow",
		  "name": "Antioch ⟷ SFIA/Millbrae"
		}
	  ]
	}

Error Response

GET https://bart.trentwil.es/api/v1/getStation/ABCD
	
	{
	  "error": true,
	  "message": "Invalid station name"
	}

/api/v1/getAlerts

No parameters

GET https://bart.trentwil.es/api/v1/getAlerts
	
	{
	  "currentAlerts": [
		"Service Alert: BART is recovering from an earlier problem. There is a 10-minute delay on the Richmond Line in all directions due to earlier police activity at Berkeley station."
	  ],
	  "plannedAlerts": [
		{
		  "message": "Bus Bridge Alert: Hazardous tree removal and track work between Pleasant Hill and Concord on 2 non-consecutive weekends (next work weekend 10/28-29",
		  "url": "https://www.bart.gov/news/articles/2023/news20230913"
		},
		{
		  "message": "BART's reimagined schedule starts September 11th aimed at increasing ridershi",
		  "url": "https://www.bart.gov/news/articles/2023/news20230427"
		},
		{
		  "message": "BART launches new safety initiative to remove potentially dangerous tree",
		  "url": "https://www.bart.gov/news/articles/2023/news20230712"
		}
	  ],
	  "escalatorAlerts": [
		{
		  "station": "Civic Center/UN Plaza",
		  "location": "Street - 8th & Market St - Up Direction",
		  "reason": "Major Repair",
		  "returnDate": "12/01/2023"
		},
		{
		  "station": "Civic Center/UN Plaza",
		  "location": "Platform - 7th & Market St - Down Direction",
		  "reason": "Modernization",
		  "returnDate": "11/27/2023"
		}
	  ],
	  "elevatorAlerts": [
		{
		  "station": "Hayward",
		  "location": "Platform - SF/Richmond",
		  "reason": "Evaluating",
		  "returnDate": "10/22/2023"
		}
	  ]
	}

/api/v1/getSchedule/<station>/<month>/<day>/<year>/<time>/<amPM>

ParameterData TypeDescription
stationStringAbbreviation of the station, case does not matter.
monthIntMonth, 1 through 12
dayIntDay, 1 through 31, depending on the month, ex. 12
yearInt
timeStringStandard time, must be in the format 00:00, ex. 05:00
amPMStringAM or PM

Successful Response Example

GET https://bart.trentwil.es/api/v1/getSchedule/12TH/10/24/2023/06:00/PM
	
	{
	  "north": [
		{
		  "line": "Yellow",
		  "terminus": "Pittsburg / Bay Point",
		  "time": "06:00 PM"
		},
		{
		  "line": "Red",
		  "terminus": "Richmond",
		  "time": "06:02 PM"
		}
	  ],
	  "south": [
		{
		  "line": "Yellow",
		  "terminus": "San Francisco International Airport",
		  "time": "06:06 PM"
		},
		{
		  "line": "Orange",
		  "terminus": "OAK Airport / Berryessa/North San Jose",
		  "time": "06:09 PM"
		},
		{
		  "line": "Yellow",
		  "terminus": "San Francisco International Airport",
		  "time": "06:15 PM"
		}
	  ]
	}

Error Response

GET https://bart.trentwil.es/api/v1/getSchedule/ROCK/30/94/2423/06:00/AM
	
	{
	  "error": true,
	  "message": "BART website returned a non-200 status code. Check back later."
	}
GET https://bart.trentwil.es/api/v1/getSchedule/ABCD/30/94/2423/06:00/AM
	
	{
	  "error": true,
	  "message": "Invalid station name"
	}

General Errors

The following are error message that may occur when a server error happens, or the BART website fails.

{
	  "error": true,
	  "message": "Internal error/BART website error"
	}
{
	  "error": true,
	  "message": "Route not found"
	}

Additionally, you may see HTML errors like these:

If these occur, please report them to the site’s owner.