BART Arrivals app - API and JSON response

I just made an app, BART Arrivals, that may be useful to those of you who commute regularly on the San Francisco BART (bay area rapid transit) system. Select a station you’re interested in and press Submit. You’ll get a list of the trains that will be arriving soon at that station. (here’s a link to a copy of the app)

https://x.thunkable.com/copy/fbdfe3e59157191e3338758469be66dd


Here are some notes and details about its development.

  1. The map is just for show. It starts with San Francisco at the splash page but upon selection of a station, it displays a new map with the station’s location at its center. But because I’m displaying the map, I had to obtain and store the latitude and longitude coordinates of each station while I was building the list of stations for the list viewer.
  2. The API request for the etd (estimate time of departure) function, shown below, requires the station location (aka. origin) to be supplied as an ABBREVIATION (not name), so I had to also save the abbreviaton In the list building step above.

http://api.bart.gov/api/etd.aspx?cmd=etd&orig=MCAR&key=

  1. The biggest challenge for me was in navigating the JSON response. Below you can see the same returned response at various levels of detail. Image 1, with practically all nodes collapsed, shows that there’s a one-entry array in station #0, named “MacArthur”, nicknamed “MCAR” (with a collapsed etd node), because my app can only request one station at a time. Image 2 reveals that 4 routes (ie. etd) are passing through that station. Image 3 shows that the first route (etd #0), whose destination is “Antioch”, has a 10-car train arriving in 18 minutes, in estimate #0. There are 2 more trains on that route (estimate #1 and #2) which are arriving much later (not shown). There are 3 more routes (etd #1, #2 and #3, all shown collapsed), that also need to be processed.
  2. Below is the block diagram showing the processing of the etd (estimated time of departure) command.

    Enjoy!
4 Likes

Thanks for sharing @manyone!

Is this just an app for fun or are you thinking about publishing it?

i did it for fun - and also, so i could learn thunkable and how to use a web api. i believe there are a few apps out there that already do this, maybe not in this form. Plus there are a few areas that could be improved, automatic location sensing, limiting number of entries displayed per route, handling of delayed trains,etc. which i had no time to include. i’m hoping some people can use this to understand how to navigate structured data in JSON form more easily by mapping the tree to the block commands in thunkable.

2 Likes

Awesome - thanks! I’ve updated the title here to reflect this and (hopefully) make it easier to search and find for folks in the future.

Thanks again for sharing - this is a great resource to have!

1 Like

@manyone, this is really cool! Good for you! Great work! Thanks for sharing!

:open_hands: :diamond_shape_with_a_dot_inside: :fire:

2 Likes