Returning all child stops for a route

Skip to first unread message

Omar Fernandez

Nov 17, 2020, 12:59:01 PM11/17/20
to MBTA Developers
Hello All!

I have a need to list all of the stops for each "Light Rail" (type 0) and “Heavy Rail” (type 1). 

I've been struggling to find the right API call that will provide the appropriate information. 

This is the url that has gotten me the closest: '[route_type]=0,1&include=route

However, when I tally up the stops for each route, they don't match that of the actual line according to the mbta website.

Can someone please assist?

Andrew Ferreira

Nov 18, 2020, 11:12:54 AM11/18/20
to MBTA Developers
Looks like you want to be able to get the stations of each subway line (Red, Green, Blue, Orange) exactly as they are presented to the public. 

A GTFS stop could be a station, a platform, a station entrance or exit, a boarding location, or even any generic location within a station.  It is important to note that the GTFS stop data structure does not contain any route information.  

Also, your query above does not return any route data.  The MBTA documentation states: "Note that route can only be included if filter[route] is present and has exactly one /data/{index}/relationships/route/data/id."  That is, you'll get included route data when you're asking for the stops on a specific route.

So to get what you want, you'll have to first ask for routes of type 0 and 1, and then ask for the stops of each route.  When you get all the stop objects for a route, you need to cast out those you aren't interested in.  When looking for a top-level station, I check for a null parent_station field.  NOTE: There is a location_type field in the stops query, but I've had trouble using that as a filter.

Other things to be aware of:  The Mattapan Trolley is a separate light-rail route (not part of the red line). The Green Line is actually comprised of numerous routes.  The Red Line is one route even though it has two branches. The Silver Line (all variations) are bus routes and will not be found in a query for route types 0,1.

Hope this helps,


Omar Fernandez

Nov 24, 2020, 2:21:20 PM11/24/20
Thanks for responding Andrew.

I understand the explanation and agree.

However, I’ve had issues with the route ID portion of the url for the stops endpoint. Can you please provide an example of putting the route ID in the url?

— Omar 

You received this message because you are subscribed to a topic in the Google Groups "MBTA Developers" group.
To unsubscribe from this topic, visit
To unsubscribe from this group and all its topics, send an email to
To view this discussion on the web visit

Developer at MBTA

Nov 24, 2020, 3:42:51 PM11/24/20
to MBTA Developers
Hi Omar,

What queries are you attempting with the route filter on the stops endpoint? To provide an example,[route]=Green-B will return all of the stops on the B branch of the Green Line. By default when filtering by route you will only get parent (top-level) stations, though when using this endpoint you should still generally consider all of Drew's advice above about top-level stops versus stops representing individual platforms or other, more-specific locations. Hopefully that helps, and please let us know if you have any additional questions.
Reply all
Reply to author
0 new messages