Get the bus route distance

Sure, you can used OSRM or valhalla or graphopper or any other routing engine.
It depends on how often you want to do that and whether you want to do that manually or automated.
I guess all of them allow specifying start, stop and intermediate points in the URL.
But buses aren’t cars with respect to height, weight, length, access restrictions.

Brouter allows creating and modifying a profile, taking those topics into account. I haven’t tried that yet, so i can’t say anything about how complicated this can be.