GTFS-RT Trip updates

STIB: brussels metro, tram and bus operator

Format
GTFS-RT
Updates
On request, from the latest vehicle-trip snapshot (every 20 seconds)
curl -H "Authorization: Bearer $MOBILITYTWIN_TOKEN" -o gtfs-rt-trip-update.pb "https://api.mobilitytwin.brussels/stib/gtfs-rt-trip-update"

Predicted arrivals for STIB/MIVB as a standard GTFS Realtime feed, built from vehicle-trip. Produced by MobilityTwin.Brussels, not an official STIB feed.

One TripUpdate per trip that has a vehicle on it: the delay measured at the last stop the vehicle called at is applied to every stop still ahead of it (arrival and departure carry both delay and absolute time). Trips with no vehicle on them are left out rather than declared on time, and there are no cancellations: the source has no signal for them.

A binary GTFS Realtime message (Protocol Buffers). Decode it with gtfs-realtime-bindings.

Parameters

NameMeaning
start_timestampStart of the range, in Unix seconds or ISO 8601. Without any timestamp, the last hour is used; with only one, the hour starting or ending at it.
end_timestampEnd of the range, in Unix seconds or ISO 8601.

Python example

import requests
from google.transit import gtfs_realtime_pb2

from datetime import datetime

url = "https://api.mobilitytwin.brussels/stib/gtfs-rt-trip-update"

data = requests.get(url, headers={
        'Authorization': 'Bearer [MY_API_KEY]'
}).content

feed = gtfs_realtime_pb2.FeedMessage()
feed.ParseFromString(data)

# Predicted arrival at the next stops of every trip with a vehicle on it
for entity in feed.entity:
    update = entity.trip_update
    upcoming = [(s.stop_id, datetime.fromtimestamp(s.arrival.time).strftime("%H:%M"))
                for s in update.stop_time_update[:3]]
    print(f"Trip {update.trip.trip_id} ({update.delay:+d} s): {upcoming}")