streaming updates -- and what gets updated?

72 views
Skip to first unread message

Matthew Miller

unread,
Mar 4, 2022, 4:15:52 PM3/4/22
to MBTA Developers
Hi everyone! I'm working on a home project to make my own personal predictions screen for the bus (and soon green line!) stops near me. To do this, I'm using the streaming API. using:


... which sees to work. I see add, update, and remove events for (at least) predictions, trips, vehicles, and alerts. But in the docs,  I noticed this:

If you’re using the “include” parameter to fetch related resources, only the primary resource will be tracked for updates. For this reason, you likely want to use vehicles, predictions, or alerts as the primary resource type. The included resources will be combined with the primary resources as a part of the “reset” event.

Hmmm. Am I missing relevant updates by doing it this way? Should I open separate connections for each primary resource I want updates on?

Thanks!

Developer at MBTA

unread,
Mar 24, 2022, 2:41:48 PM3/24/22
to MBTA Developers
Hi there,

When using the streaming API, you will receive updates to all included resources whenever the primary resource is updated (in the query you posted, the primary resource is `predictions`). So, you will get the latest vehicle and alert data when predictions update, but not independently of a predictions update. If you want to get streaming updates for resources as soon as they are updated, you will need a separate query for each primary resource.

—Developer@MBTA

Reply all
Reply to author
Forward
0 new messages