You could take a look at this question - specifically the answer from Robert van t Hof giving a link to the Google maps directions api
Alternatively look at this Google api link