Migrate to DistanceMatrixAPI
If you are using Google API, migration will take less than 5 minutes, and save up to 9 times your cost.
Migrate from Google Distance Matrix API
This page will explain how to move from Google Distance Matrix API to DistanceMatrixAPI, and compare the request and response parameters of each.
In a Nutshell
All that needs to be done in the project code is to find the existing Google API snippets “https://maps.googleapis.com/maps/api/distancematrix” and replace them with “https://maps.distancematrixapi.com/maps/api/distancematrix“.
That’s it, DistanceMatrixAPI backend algorithms will take care of the rest and serve your project requests.
If you are not fully confident yet, continue reading below:
DistanceMatrixAPI:
https://maps.distancematrixapi.com
Google API:
https://maps.googleapis.com
DistanceMatrixAPI:
GET
https://maps.distancematrixapi.com/maps/api/distancematrix/json
?origins=<origin_location_1|origin_location_2|...|origin_location_n>
&destinations=<destination_location_1|destination_location_2|...|destination_location_n>
&key=<your_access_token>
Google API:
GET
https://maps.googleapis.com/maps/api/distancematrix/json
?origins=<origin_location_1|origin_location_2|...|origin_location_n>
&destinations=<destination_location_1|destination_location_2|...|destination_location_n>
&key=<your_access_token>
Migration from Google to DistanceMatrixAPI is engineered to be simple
Distance Matrix Example Request
DistanceMatrixAPI:
GET
https://maps.distancematrixapi.com/maps/api/distancematrix/json
?units=metric&origins=big ben london&destinations=48.8584,2.2945
&key=<your_access_token>
Google API:
GET
https://maps.googleapis.com/maps/api/distancematrix/json
?units=metric&origins=big ben london&destinations=48.8584,2.2945
&key=<your_access_token>
Required Inputs & Response Parameters
Parameters in the DistanceMatrix API request is similar to Google
- Single or Multiple Origin points on the map separated by the pipe character (|) or the encoded pipe character %7C
- Single or Multiple Destination points on the map separated by the pipe character (|) or the encoded pipe character %7C
- Key: your DistanceMatrixAPI access token authorized to access the service. You can get by filling the demo form here
Matrix API response in JSON or XML format, it's also the same in both cases.
- The core unit of duration (time estimate) in seconds.
- The response parameter for distance in either meters (metric) or miles (imperial)
- Default transport mode is via cars with live traffic conditions. Travel modes can be changed, please check full guide at https://distancematrixapi.com/dev/
- The elements origin/destination pairs to which fastest route is to be computed.
Distance Matrix Example Response
DistanceMatrixAPI:
{
"destination_addresses" : [ "5 Avenue Anatole France, 75007 Paris, France" ],
"origin_addresses" : [ "Westminster, London SW1A 0AA, UK" ],
"rows" : [
{
"elements" : [
{
"distance" : {
"text" : "284 mi",
"value" : 457643
},
"duration" : {
"text" : "5 hours 35 mins",
"value" : 20090
},
"status" : "OK"
}
]
}
],
"status" : "OK"
}
Google API:
{
"destination_addresses" : [ "5 Avenue Anatole France, 75007 Paris, France" ],
"origin_addresses" : [ "Westminster, London SW1A 0AA, UK" ],
"rows" : [
{
"elements" : [
{
"distance" : {
"text" : "284 mi",
"value" : 457643
},
"duration" : {
"text" : "5 hours 34 mins",
"value" : 20065
},
"status" : "OK"
}
]
}
],
"status" : "OK"
}