blog

Tracking BART Trains with Gravwell

May 5, 2022 5:00:00 AM / By John Floren

We publish a lot of networking-focused information on this blog, but Gravwell is really a very flexible tool for analyzing any sort of data. To demonstrate this, we occasionally go out looking for interesting public APIs and build a demo around them. In this case, I'm going to use Gravwell Flows to fetch data from the Bay Area Rapid Transit (BART) public API and build a few dashboards around it!

Polling the API

The BART agency is kind enough to provide a free API key for anyone to use as long as you pinky-swear to play nice. With that in hand, it was trivial to build a flow that hits several API endpoints every minute:

bart-flow

The flow consists of four HTTP nodes, each performing a GET request on a different API endpoint. The response comes back as a JSON blob, which is perfect for passing directly into the Ingest node:

bart-ingest

Once the flow is in operation, it's simply a matter of querying the data and extracting interesting components, such as the number of trains currently in service:

bart-count-text

bart-count-chart

Building Dashboards

With BART data flowing into the system, the next obvious step is to build some dashboards around it. The status dashboard shows general system status and a list of stations:

status-dashboard

I also built an investigative dashboard for a single station and an actionable to trigger it when text is selected. I can select a station from the station list:

bart-actionable

Clicking "Check departures" takes me straight to the appropriate dashboard for that station, where I can see that the Concord station has a train leaving toward SFO in 4 minutes:

concord-station

Conclusion

Gravwell is not just for network data! You can use it to analyze just about anything you can get ingested. With the newly released Flows with Gravwell v.5 Orion, it's easier than ever to do the ingesting. Fellow developer Fritz has even built a Flow to check Best Buy's API to see if they have any PS5 consoles in stock (Read that here https://www.gravwell.io/blog/flows-best-buy-api-help-get-sony-ps5).

If you want to try out Gravwell Flows today with any public API, get your free Gravwell Community Edition licenses by clicking on the button below.

Request a CE License

Once you are up and running, stop by our Discord and share questions or your build's success with the team:

John Floren
Written by John Floren
John's been writing Go since before it was cool and developing distributed systems for almost as long.
TOP