Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Commuter rail predictions

82 views
Skip to first unread message

Jeff Lopes

unread,
Aug 19, 2023, 4:58:17 PM8/19/23
to MBTA Developers
Hello again,

I noticed that the V3 API only returns commuter rail predictions for upcoming trips for the originating stop. It would be helpful to get predictions for every stop on the trip, even if the trip hasn't begun. Is that possible?

Here's a current example from the API that shows a single prediction for upcoming trip CR-595947-1611.

HTTP GET /mbta/predictions?filter%5Broute%5D=CR-Needham&include=trip,vehicle,vehicle.trip&X-Api-Key=REDACTED

{
  "data": [
    {
      "attributes": {
        "arrival_time": null,
        "departure_time": "2023-08-19T17:15:00-04:00",
        "direction_id": 0,
        "schedule_relationship": null,
        "status": "On time",
        "stop_sequence": 0,
        "track": null
      },
      "id": "prediction-CR-595947-1611-NEC-2287-0",
      "relationships": {
        "route": {
          "data": {
            "id": "CR-Needham",
            "type": "route"
          }
        },
        "stop": {
          "data": {
            "id": "NEC-2287",
            "type": "stop"
          }
        },
        "trip": {
          "data": {
            "id": "CR-595947-1611",
            "type": "trip"
          }
        },
        "vehicle": {
          "data": null
        }
      },
      "type": "prediction"
    },
    {
      "attributes": {
        "arrival_time": "2023-08-19T16:50:22-04:00",
        "departure_time": null,
        "direction_id": 1,
        "schedule_relationship": null,
        "status": null,
        "stop_sequence": 110,
        "track": null
      },
      "id": "prediction-CR-595946-1610-NEC-2287-110",
      "relationships": {
        "route": {
          "data": {
            "id": "CR-Needham",
            "type": "route"
          }
        },
        "stop": {
          "data": {
            "id": "NEC-2287",
            "type": "stop"
          }
        },
        "trip": {
          "data": {
            "id": "CR-595946-1610",
            "type": "trip"
          }
        },
        "vehicle": {
          "data": {
            "id": "1813",
            "type": "vehicle"
          }
        }
      },
      "type": "prediction"
    }
  ],
  "included": [
    {
      "attributes": {
        "bearing": 89,
        "carriages": [],
        "current_status": "IN_TRANSIT_TO",
        "current_stop_sequence": 110,
        "direction_id": 1,
        "label": "1813",
        "last_updated": "2023-08-19T16:45:26-04:00",
        "latitude": 42.34769058227539,
        "longitude": -71.07286834716797,
        "occupancy_status": null,
        "speed": 6.7,
        "updated_at": "2023-08-19T16:45:26-04:00"
      },
      "id": "1813",
      "links": {
        "self": "/vehicles/1813"
      },
      "relationships": {
        "route": {
          "data": {
            "id": "CR-Needham",
            "type": "route"
          }
        },
        "stop": {
          "data": {
            "id": "NEC-2287",
            "type": "stop"
          }
        },
        "trip": {
          "data": {
            "id": "CR-595946-1610",
            "type": "trip"
          }
        }
      },
      "type": "vehicle"
    },
    {
      "attributes": {
        "bikes_allowed": 1,
        "block_id": "",
        "direction_id": 1,
        "headsign": "South Station",
        "name": "1610",
        "wheelchair_accessible": 1
      },
      "id": "CR-595946-1610",
      "links": {
        "self": "/trips/CR-595946-1610"
      },
      "relationships": {
        "route": {
          "data": {
            "id": "CR-Needham",
            "type": "route"
          }
        },
        "route_pattern": {
          "data": {
            "id": "CR-Needham-d774fb34-1",
            "type": "route_pattern"
          }
        },
        "service": {
          "data": {
            "id": "SPR23-S-Sa-1-Sc5",
            "type": "service"
          }
        },
        "shape": {
          "data": {
            "id": "9860001",
            "type": "shape"
          }
        },
        "vehicle": {
          "data": {
            "id": "1813",
            "type": "vehicle"
          }
        }
      },
      "type": "trip"
    },
    {
      "attributes": {
        "bikes_allowed": 1,
        "block_id": "",
        "direction_id": 0,
        "headsign": "Needham Heights",
        "name": "1611",
        "wheelchair_accessible": 1
      },
      "id": "CR-595947-1611",
      "links": {
        "self": "/trips/CR-595947-1611"
      },
      "relationships": {
        "route": {
          "data": {
            "id": "CR-Needham",
            "type": "route"
          }
        },
        "route_pattern": {
          "data": {
            "id": "CR-Needham-a6552e0a-0",
            "type": "route_pattern"
          }
        },
        "service": {
          "data": {
            "id": "SPR23-S-Sa-1-Sc5",
            "type": "service"
          }
        },
        "shape": {
          "data": {
            "id": "9860002",
            "type": "shape"
          }
        },
        "vehicle": {
          "data": null
        }
      },
      "type": "trip"
    }
  ],
  "jsonapi": {
    "version": "1.0"
  }
}

Thanks,

Jeff
Reply all
Reply to author
Forward
0 new messages