Prediction and Vehicle Locations Queries: predictions and vehicles by routes, route, trip, stop

33 views
Skip to first unread message

Tony Sherman

unread,
Jul 28, 2017, 9:44:50 AM7/28/17
to MBTA Developers
The documentation implies that this is not always available. Currently I am only concerned with the commuter rail. 

Can someone tell me what is returned when there is no predictions available. I am looking to manage API errors if the data is not there. 

(Apologies if this is already documented, I've looked but can't find it)

Stefan Wuensch

unread,
Jul 28, 2017, 10:46:46 AM7/28/17
to massdotd...@googlegroups.com
I've had to test for - and handle individually - the existence of almost every object in the feeds. I don't think you should assume that anything is guaranteed to be there. For example overnight there isn't even a 'mode' object returned, which is the root of all trips.

Personally I test for & specifically handle the lack of all the following:
- mode
- stop
- vehicle
- vehicle_label
- trip_headsign
- trip_name
- vehicle_lat
- vehicle_lon

Ideally the lack of predictions for a trip would not suppress the vehicle data in vehiclesByRoute(s) calls, but it does.

See this previous thread: <https://groups.google.com/forum/#!topic/massdotdevelopers/pbjLjOYq0BQ>


In case you want to compare data across all three CR vehicle sources (legacy feed, predictionsByRoutes, vehiclesByRoute) try:
https://sites.harvard.edu/~wuensch/T/cr-feeds.html
(If you don't care about the legacy feed that might not be relevant however.)


-- Stefan
Reply all
Reply to author
Forward
0 new messages