trip_id changes over time, best practice for game to fetch a valid trip_id?

121 views
Skip to first unread message

Nelson Correia

unread,
Apr 1, 2021, 10:02:34 AM4/1/21
to MBTA Developers
Hello Everyone, thank you for permitting me to join the group.

I am currently working on a personal project to help my son learn how to read analog clocks. He loves riding the Red Line and so I am using the API to build a game as way to make the learning process fun for him.

After taking some time off from the project, I learned that the request string was no longer valid. My understanding, at this point, is that the trip_ids expire over time.

Is there a best practice to fetch a valid trip_id automatically, so that the game can run without scheduled adjustments? Thank you.

Developer at MBTA

unread,
Apr 6, 2021, 3:30:27 PM4/6/21
to MBTA Developers
Hi,

You're correct that trip IDs are not stable over time, since of course the scheduled service on a line changes over time, which necessitates adding or removing trips.

If you just want to fetch any single valid trip on the Red Line, you can use the `route` filter on the `/trips` endpoint (e.g. /trips?filter[route]=Red&page[limit]=1). Similarly, you can filter the `/schedules` and `/predictions` endpoints by route if you'd like to directly get a stop time for the game without going through trips.

Route IDs are stable over time unless the route itself is eliminated — unlikely, in the case of the Red Line, but if you wanted to avoid hard-coding any specific ID you could request `/routes` and pick one (this endpoint has no required filters).

Hope this helps,
—Developer@MBTA

Nelson Correia

unread,
Apr 7, 2021, 11:45:13 AM4/7/21
to MBTA Developers
Hello Developer @ MBTA,

Thank you so much for the response. This is great! It takes much of the guess work out.

On a side note, there's another conversation that I would like to vote up:


Adding announcements to the game would definitely level up the fun factor.

Michael G

unread,
Apr 9, 2021, 10:10:33 AM4/9/21
to MBTA Developers

Thank you for supporting my post! Hopefully we will get them soon. 

Nelson Correia

unread,
May 9, 2023, 12:38:07 AM5/9/23
to MBTA Developers
Hi Developer@MBTA,

It works! So after a number of life changes and a concentrated effort in activating the basic functionality of this game, I can say the majority of remaining concerns are centered around UI/UX.

I used a combination of routePattern and filter[date] to generate the starting data and, then, refined it through the schedule endpoint to get stop data to build out the game elements.

Here's a link to the game:

Here's a demo video:

MBTA Rush v1.0.0

Anthony Blake

unread,
May 21, 2023, 6:33:16 PM5/21/23
to MBTA Developers
how do u fetch the data usindatapng.png
Reply all
Reply to author
Forward
0 new messages