Unofficial BART API Docs

Written by Trent Wiles. Source is available on GitHub.

An unofficial replacement for BART's Legacy API, created because the official version does not function as intended. Data is scraped from BART.gov, and returned here in JSON format.

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

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 or VPN software.

Reading Response JSON

Due to their length, some responses may be truncated to save space. A truncation will be indicated by three to four dots (”….”). Data following these dots is typically similar to what came before it.

Contact

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

Routes

Base URL: bart.trentwil.es


/api/v1/getPredictions/<station>

Returns the latest predictions for a station. “estimates” may be blank if there are no trains running, due to an alert or the time.

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": "Pittsburg/Bay Point",
		  "lineColor": "Yellow",
		  "estimates": [
			{
			  "formatted": "8 car, 3 door train",
			  "doors": 3,
			  "cars": 8,
			  "timeFormatted": "Leaving",
			  "time": 0
			}
		  ]
		},
		{
		  "lineTerminus": "Richmond",
		  "lineColor": "Orange",
		  "estimates": [
			{
			  "formatted": "6 car, 3 door train",
			  "doors": 3,
			  "cars": 6,
			  "timeFormatted": "8 min",
			  "time": 8
			},
			....
		  ]
		},
		{
		  "lineTerminus": "Richmond",
		  "lineColor": "Red",
		  "estimates": [
			{
			  "formatted": "6 car, 3 door train",
			  "doors": 3,
			  "cars": 6,
			  "timeFormatted": "16 min",
			  "time": 16
			},
			....
		  ]
		},
		{
		  "lineTerminus": "Berryessa",
		  "lineColor": "Orange",
		  "estimates": [
			{
			  "formatted": "6 car, 3 door train",
			  "doors": 3,
			  "cars": 6,
			  "timeFormatted": "8 min",
			  "time": 8
			},
			....
		  ]
		},
		{
		  "lineTerminus": "Millbrae",
		  "lineColor": "Red",
		  "estimates": [
			{
			  "formatted": "6 car, 3 door train",
			  "doors": 3,
			  "cars": 6,
			  "timeFormatted": "13 min",
			  "time": 13
			},
			....
		  ]
		},
		{
		  "lineTerminus": "SF Airport",
		  "lineColor": "Yellow",
		  "estimates": [
			{
			  "formatted": "8 car, 3 door train",
			  "doors": 3,
			  "cars": 8,
			  "timeFormatted": "6 min",
			  "time": 6
			},
			...
		  ]
		},
		{
		  "lineTerminus": "Antioch",
		  "lineColor": "Yellow",
		  "estimates": [
			{
			  "formatted": "8 car, 3 door train",
			  "doors": 3,
			  "cars": 8,
			  "timeFormatted": "8 min",
			  "time": 8
			},
			....
		  ]
		},
		{
		  "lineTerminus": "Pittsburg/Bay Point",
		  "lineColor": "Yellow",
		  "estimates": [
			{
			  "formatted": "8 car, 3 door train",
			  "doors": 3,
			  "cars": 8,
			  "timeFormatted": "19 min",
			  "time": 19
			},
			....
		  ]
		}
	  ]
	}

Error Response

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

/api/v1/getStations

No parameters. Returns all station names and their API abbreviations.

Successful Response

Notice: As of 10/1/2024, stations no longer contain the names of the cities they are in. For instance, Ashby station is now listed as “Ashby”, where it was once listed as "Ashby (Berkeley)”.

A typo was also corrected, changing stationAbreviation to stationAbbreviation.

GET https://bart.trentwil.es/api/v1/getStations
	
	{
	  "error": false,
	  "stations": [
		{
		  "stationName": "12th St. Oakland City Center",
		  "stationAbbreviation": "12TH"
		},
		{
		  "stationName": "16th St. Mission",
		  "stationAbbreviation": "16TH"
		},
		{
		  "stationName": "19th St. Oakland",
		  "stationAbbreviation": "19TH"
		},
		{
		  "stationName": "24th St. Mission",
		  "stationAbbreviation": "24TH"
		},
		....
	  ]
	}
	...

/api/v1/getStation/<station>

Return data on a BART station provided on the website.

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. Returns all BART service alerts.

GET https://bart.trentwil.es/api/v1/getAlerts
	
	{
	  "error": false,
	  "currentAlerts": [
		{
		  "message": "Service Alert: BART trains are delayed by up to 10 minutes due to..."
		},
		....
	  ],
	  "elevatorAlerts": [
		{
		  "station": "COLS",
		  "station_full_name": "Coliseum",
		  "location_in_station": "Concourse/ParkingLot - Tunnel",
		  "reason": "Major Repair",
		  "service_return_date": "10/02/2024"
		},
		....
	  ],
	  "escalatorAlerts": [
		{
		  "station": "CAST",
		  "station_full_name": "Castro Valley",
		  "location_in_station": "Platform - Norbridge Ave (South End) - Down Direction",
		  "reason": "Repair",
		  "service_return_date": "10/04/2024"
		},
		{
		  "station": "CIVC",
		  "station_full_name": "Civic Center/UN Plaza",
		  "location_in_station": "Platform - 7th & Market St - Up Direction",
		  "reason": "Modernization",
		  "service_return_date": "12/31/2024"
		},
		....
	  ]
	}

/api/v1/getNews

No parameters. Returns links to news articles on the BART website from the last year.

{
	  "error": false,
	  "data": [
		{
		  "date": "10.01.24",
		  "title": "Ridership Watch: daily updates related to riders returning to BART",
		  "url": "https://www.bart.gov/news/articles/2023/news20230729"
		},
		{
		  "date": "09.30.24",
		  "title": "Take transit to Fleet Week; BART running longer trains for the weekend (10/12 & 10/13)",
		  "url": "https://www.bart.gov/news/articles/2024/news20240930-1"
		},
		{
		  "date": "09.30.24",
		  "title": "Take BART + Muni to Hardly Strictly at Golden Gate Park this weekend (10/4 - 10/6)",
		  "url": "https://www.bart.gov/news/articles/2024/news20240930-0"
		},
		....
	  ]
	}

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. See “contact” above.