getting langitude and lattitude along the road

I want an api that gives all the coordinates(lat,lang) of a particular route, in an array, given by the map when starting and ending location coordinates are given. (along the road)
ex: start location (x1,y1)
end location(x2,y2)
it should return an array [[x1,y1],[x11,y11],[x12,y12],…[x2,y2]]
where all the coordinates lie on the road route.:slight_smile: