Skip to content

GTFS Realtime Tutorial #1: Intro to GTFS Realtime

Kelly Dunn edited this page Feb 21, 2021 · 2 revisions

The following tutorial was created by Brian Ferris:

So maybe you have heard of GTFS-realtime?

https://developers.google.com/transit/gtfs-realtime

It's a specification for exchanging real-time public transit information, developed through the partnership of a number of transit agencies, developers, and Google. Designed in the same spirit as GTFS (and with interoperability with GTFS in mind), the goal of GTFS-realtime is to bring a little bit of consistency to the current "every agency does it slightly differently" world of real-time transit data.

No matter how you slice it, however, working with real-time data is more complex than static schedule data. With that complexity in mind, I'd like to present a series of tutorials and example projects that demonstrate how to produce and consume GTFS-realtime data. Hopefully, these tutorials will show that working with GTFS-realtime is actually pretty simple and can get us all moving towards common ground around real-time public transit data.

The first tutorial in the series deal with producing real-time service alerts using GTFS-realtime. I'm really excited about the service alerts feature of the spec:

https://developers.google.com/transit/gtfs-realtime/guides/service-alerts

Service alerts capture information about changes in service (detours, delays, cancelations) in a structured way, allowing an agency to specify exactly which route, stop, and even trip is affected by a particular alert. With this structured information, we can develop applications that tell riders about just the alerts that affect their trip, and none of the alerts that don't.

How can a transit agency produce a GTFS-realtime alerts feed? I've put together a demo project that takes alert data in a custom format from an agency (specifically, SEPTA's alert feed) and walk you through how to create a GTFS-realtime alerts feed from the data. This project page includes instructions on downloading the source-code and running the project, as well as a detailed walk-through of the code where GTFS-realtime alerts are constructed. Hopefully, the project can serve as a starting point for any agency wanting to publish their service alert data.

I hope you find this useful! Stay tuned for more tutorials about working with GTFS-realtime data.