What does block_C47-255_schedBasedVehicle mean in the vehicle id field?

29 views
Skip to first unread message

Rene Adaimi

unread,
Mar 3, 2022, 2:54:40 PMMar 3
to MBTA Developers
Hello,

Sometimes when I query predictions I get back that the vehicle id is "block_C47-255_schedBasedVehicle", instead of a vehicle number like "y1234". This id can't be queried on the /vehicles api as well.

Sample query (today at 14:50): https://api-v3.mbta.com/predictions?filter[route]=47&filter[stop]=11803&filter[trip]=50263049

Sample response:
{"data":[{"attributes":{"arrival_time":"2022-03-03T15:37:54-05:00","departure_time":"2022-03-03T15:37:54-05:00","direction_id":0,"schedule_relationship":null,"status":null,"stop_sequence":22},"id":"prediction-50263049-11803-22","relationships":{"route":{"data":{"id":"47","type":"route"}},"stop":{"data":{"id":"11803","type":"stop"}},"trip":{"data":{"id":"50263049","type":"trip"}},"vehicle":{"data":{"id":"block_C47-255_schedBasedVehicle","type":"vehicle"}}},"type":"prediction"}],"jsonapi":{"version":"1.0"}}

Any help is appreciated.
Thank you,

Developer at MBTA

unread,
Mar 10, 2022, 2:13:24 PMMar 10
to MBTA Developers
Hi, thanks for bringing this issue to our attention. These "non-existent" vehicles should not be appearing in the data, and these are actually predictions with no vehicle attached. You can see this more clearly if you add include=vehicle to your query — the lookup of the vehicle fails and the relationship is set to null. We will be working to fix this.

Some general reminders for using the API:
  • IDs returned in an API response are not guaranteed to be valid in a later request: your code needs to handle the possibility of the data not existing anymore. For example, the vehicle referenced by a prediction could have stopped tracking (and thus disappeared from the data) between the time you requested the predictions and the time you look up the vehicle. Where possible, we recommend using the include parameter to get all the data you need in a single response, at a single moment in time.
  • All IDs should be considered opaque: you should not rely on being able to extract any information from an ID. For example, if you need the rider-visible "number" of a bus, use the label attribute of the Vehicle resource.
—Developer@MBTA
Reply all
Reply to author
Forward
0 new messages