API: Is it possible to fetch an entire trip's schedule, with stop times while querying for a single stop?

71 views
Skip to first unread message

Kirill Birger

unread,
Sep 19, 2023, 9:22:20 PM9/19/23
to MBTA Developers
I'm working on a project where I want to track upcoming commuter rail schedules based on a destination station. Ultimately, I want to get the time of the next several trains from a departure station. I'm trying to query schedules that contain a certain stop, and I can add "trip.stops" to the include list, but that will only give me a list of the stops themselves, and not times. With this approach, I would have to make several additional requests, to get a set of schedules for each schedule in the original request.

Is there a better approach?

Here's an example of what I'm starting with right now:
/schedules?include=stop.name,trip.name,trip.stops&filter[date]=2023-09-19&filter[direction_id]=0&filter[min_time]=16:00&filter[stop]=XXXXXX

It seems like I should be able to use a nested include to get this, but I can't quite figure out what it would be. It seems like I want schedule.trip.schedule, but that doesn't work.


Here's an example use case: I have two stations near my home, and some trains go to both, while others only go to one. There are too many routes and even route_patterns to be meaningful. I want to know my next few trains to go home that go to any acceptable station, but I want to know when they depart from the origin station.


Reply all
Reply to author
Forward
0 new messages