The purpose of this project was to build an approximation of a Massachusetts Bay Transportation Authority train departure board using the powerful MBTA v3 Developer API. It's currently hosted on Heroku here.
The MBTA's API includes a number of interesting endpoints and features for retrieving near real-time data for trains and buses throughout the MBTA system. Among its coolest features:
-
Data is formatted using the JSONAPI standard, which makes parsing relations between resources easier (especially when leveraging one of several language-specific client libraries. I used jsonapi-datastore).
-
For some endpoints, it includes out-of-the box support for event streaming using the JavaScript Event Source API.
I decided to build this in React with create-react-app, as that's the framework I am most familiar with and it's relatively straightforward. It has a lightweight Express server for running on Heroku.
At the moment, the departure board includes:
-
Departure Time, Destination, Train Number and Status for pending MBTA Commuter Rail departures from South Station in downtown Boston, Massachusetts.
-
Live updates on all "reset" events
-
A simple live clock updated with setTimeout