API

104 views
Skip to first unread message

Paul Morganthall

unread,
Aug 16, 2022, 7:29:56 PM8/16/22
to MBTA Developers
I am new to GTFS, but old to programming and APIs. I'd like to get the schedule for a whole trip.

The API documentation for Schedule says I can get the schedule for a whole trip via
/schedule?filter[trip]=TRIP_ID

That sounds perfect for my needs, but no matter what trip_id I provide (including none), that call always returns the message:
Resource not found

I'm guessing that's a typo, and maybe the resource should be schedules? I tried
but that returns an empty data field. I got the same result with several other trip IDs.

I think that is a valid trip_id since I get useful data from a call to

Since I am new to this, I'm fine with RTFM links of any kind. Also it was not clear to me where to report issues, if the documented call to /schedule really is a typo.

thanks!
—paul






Message has been deleted

Paul Morganthall

unread,
Aug 16, 2022, 7:50:52 PM8/16/22
to MBTA Developers
DOH! I forgot to edit the subject before saving the message.
Subject: getting the schedule for a whole trip

Paul Morganthall

unread,
Aug 17, 2022, 12:10:09 PM8/17/22
to MBTA Developers
I think I figured out my issue. The call to /schedules works just fine, but I was testing with inactive trips, so there was no schedule data.

Perhaps I should have started with my current goal, in case there is a RTFM example out there. I'm trying to construct a table of stations and times, much like the Fitchburg timetable. As I wrote that sentence, I realized there is probably a solution somewhere in dotcom.

[more details on my learning, you can probably skip the rest of this message]

I think my empty data problem was my lack of understanding. I was mostly focused on the Fitchburg Commuter Rail line. I think my test trip of CR-525671-427 is inactive, and CR-525671-427-LeoWachuEarly returns nice schedule data.

What I think I learned: trips described in the feed might have active schedules, or they might not – perhaps they're there for past or upcoming schedules.

What might help future me: try more examples, on different lines and different times. Also try a call against the sample schedule with well known inputs and outputs, to enhance my understanding.

What I am still wondering: is there an indicator that a trip is currently active? Or I should try getting a schedule and if data is empty, it is not active?

—paul

Developer at MBTA

unread,
Aug 30, 2022, 5:43:33 PM8/30/22
to MBTA Developers
Hi Paul,

It looks like you figured out your issue, but thanks for asking the question (and then providing follow-up information). I can see a deficiency in our documentation.

I believe what you were running into is that with the `/schedules` endpoint, if no `filter[date]` is provided, it defaults to "today". So the trip you referenced is actually active (and at this moment https://api-v3.mbta.com/schedules?filter[trip]=CR-525671-427 will return data) because it's a weekday trip. However, if you click that link on the weekend, you will see empty data. You can also explicitly set a date like https://api-v3.mbta.com/schedules?filter[trip]=CR-525671-427&filter[date]=2022-08-30 . Our documentation does not mention that without a date provided it defaults to the current day, so we will update that!

> I'm guessing that's a typo, and maybe the resource should be schedules

Yes, thank you! We will update.

> What I am still wondering: is there an indicator that a trip is currently active? Or I should try getting a schedule and if data is empty, it is not active?

Exactly, a trip won't appear in our API if it never runs during the current rating, so it will always be "active" on some dates. But the way to tell if it's active on a given date is to make the query, and if the data is empty, that means it's not running on that particular date.

Best,

Gabe | Developer @ MBTA
Reply all
Reply to author
Forward
0 new messages