Using MTA Real-time Feeds for station arrivals feature

307 views
Skip to first unread message

Ryan O'Connor

unread,
May 31, 2018, 10:26:53 AM5/31/18
to mtadeveloperresources
Hello,

I’m a junior at Chaminade HS in Mineola. I am looking to add an upcoming arrivals feature to our school’s iOS app, which will show trains coming soon only for Mineola. Ideally, this will be similar to the TrainTime iOS app’s “Arrival Countdown” feature, with times, stops, etc. Warning: sorry for the novice questions.

There are a few things that I would like clarification for:

1. From what I understand, the arrival track of the train is not available to developers?
2. As the GTFS real-time feed only has identifiers in it, does this mean I need to download the static GTFS schedule information as well, and reference it? This seems excessive, given that I need to search through thousands of lines of data just to get the stop time and final destination. The real-time feed also does not appear to have stops listed, so I would also have to cross check with the stops data to see if is stops at Mineola, stop #42.
3. In the usage guidelines, it says that developers must self-host the data. Does this mean that I need to implement some kind of cache so that the MTA feed is only called when the data is, say, one minute old?

Thanks!

Jeremy Baron

unread,
May 31, 2018, 10:56:01 AM5/31/18
to mtadevelop...@googlegroups.com
Hi!

On Thu, May 31, 2018 at 10:25 AM, Ryan O'Connor <rob...@optonline.net> wrote:
> 1. From what I understand, the arrival track of the train is not available to developers?

see https://groups.google.com/d/msg/mtadeveloperresources/OWI2FCBQ1BQ/2FQ4c_LjAgAJ
from Patrick and the rest of the thread after that. coincidentally
uses Mineola as an example.

> 2. As the GTFS real-time feed only has identifiers in it, does this mean I need to download the static GTFS schedule information as well, and reference it? This seems excessive, given that I need to search through thousands of lines of data just to get the stop time and final destination. The real-time feed also does not appear to have stops listed, so I would also have to cross check with the stops data to see if is stops at Mineola, stop #42.

yes, this is how GTFS realtime works AFAIK. same with the subway
feeds. (although the Bus real time system SIRI is set up more like
what you are looking for, you can query the upcoming arrivals for a
specific bus stop)

> 3. In the usage guidelines, it says that developers must self-host the data. Does this mean that I need to implement some kind of cache so that the MTA feed is only called when the data is, say, one minute old?

30 second cache should be sufficient but I think this means your app
can't directly access MTA feed at all. you have to host a cached copy
yourself somewhere and then your app uses your copy. (so you hit the
MTA download once every 30 secs not once per open app per 30 seconds)

this is really silly+unnecessary because it's serving the exact same
payload to every user and it seems MTA (or at least acquia) is already
using Varnish. so no server side number crunching required if you
ignore API keys. vs. SIRI (Bus real time) where API keys make a bit
more sense because there API clients are actually making the server
side do work that is much more likely to be a cache miss.

-Jeremy

Ryan O'Connor

unread,
May 31, 2018, 12:54:15 PM5/31/18
to mtadeveloperresources
Thanks for the detailed response Jeremy. I took a look at that thread, and they mentioned the “Departures TrainTime API”. Is that the same things as the GTFS
-RT feed, or a different one? From what it sounded like, the Departures API singles in on one station, which is what I’m looking for.

-Ryan

Patrick O'Hara

unread,
Jun 1, 2018, 1:25:38 PM6/1/18
to MTA Developer Resources Google Group

If you’re looking for the status of upcoming trains at just one station, I would strongly recommend ditching the GTFS-RT feed entirely and going straight to the TrainTime Departures feed.  The LIRR’s GTFS-RT feed is useful if you already have a program setup that works with the GTFS-RT specification and you just want to extend that to the LIRR, but otherwise the feed in its current form now is fairly useless.

The TrainTime Departures feed will get you the upcoming trains and their ETA, track, and remaining stops for a particular station, and it won’t be wrong more often than it’s right.  And you won’t have to deal with the static GTFS files at all (unless you want to provide arrival times of trains, since the feed just lists the stops).  This would probably be your best bet.

…patrick…

--

You received this message because you are subscribed to the Google Groups "mtadeveloperresources" group.

To unsubscribe from this group and stop receiving emails from it, send an email to mtadeveloperreso...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages