It is sad you have to code it, in Prague this is provided directly by Prague Transit Authority which is operating the trams/buses/subway/funicular/ferries and it has also current information about delays and each vehicle
https://mapa.pid.cz/?filter=&zoom=15.1&lon=14.4272&lat=50.08...