Hi there,
As you've probably figured out, there isn't necessarily such a thing as "the" stops/shape for a given route, since many routes (especially bus routes) have multiple patterns of service, or don't visit the same stops in each direction. There is, however, a better way than looking at individual trips: we group trips together into "route patterns", where all the trips in a route pattern have the same stops/shape. Route patterns themselves have a descriptive name and other attributes that may be useful — check under "RoutePatternResource" in
the documentation.
The relationships are like this:
- Route has many route_patterns
- RoutePattern has many trips
- RoutePattern has one representative_trip
- Trip has one shape and many stops
The
representative_trip is just one trip chosen arbitrarily from the pattern's
trips, which allows you to access the shape and stops more conveniently if you only care about those. We actually have an example of this on our
Best Practices page (section "Nested includes"), where we fetch a route plus all of its patterns and their shapes in one request. You could expand on this to also fetch the stops of each pattern.
—Developer@MBTA