Each bus, trolley and tram has a gps device. The data seems to be refreshed after ~10 second intervals. Not sure if an API exists to create other apps based on the data.
Estonia's capital's public transport displayed live on a map
soiduplaan.tallinn.ee