how to receive ordered list of stops

94 views
Skip to first unread message

Igor K

unread,
Jan 29, 2021, 10:10:42 AM1/29/21
to MBTA Developers
Hi, how to receive ordered list of stops for any particular routes/lines (in the same order as train/bus pass them)?
stops?route=${route} returns list without any order.

Thanks

Developer at MBTA

unread,
Feb 1, 2021, 4:12:47 PM2/1/21
to MBTA Developers
Hello,

Routes do not necessarily have a single ordering of stops that every trip follows. For example, the Red Line has the Ashmont and Braintree branches, and many bus routes have "variants" that skip or add stops. We call these Route Patterns — groups of trips that share the same route, direction, and stops. Route patterns have a `representative_trip` relationship that gives you one of the trips, arbitrarily, and trips then have a `stops` relationship which is ordered by stop sequence (equivalent to calling `/schedules` with a `filter[trip]`, sorting by `stop_sequence`, and mapping each schedule to its related `stop`).

The appropriate way to deal with route patterns will depend on your app. MBTA.com, for example, has a route pattern selector for bus routes (click the down-pointing triangle just above the map). Note this uses the `typicality` field of route patterns to decide which pattern to start on, and to initially hide "uncommon" patterns; you can read about that field in the RoutePatternResource section of our Swagger docs.

—Developer@MBTA
Reply all
Reply to author
Forward
0 new messages