Migrate to Distance Matrix API from Google maps distance API

The Distance Matrix API
Introduction

This document will guide you through the different request and response parameters of Distance Matrix API and how you can extract data analogous to the Google Distance Matrix service from Distance Matrix API with the same accuracy, but for the more affordable and fair price.

Distance Matrix request
Google:
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>
Distancematrix.ai:
GET

https://api.distancematrix.ai/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>
Distance Matrix example request
Google:
GET

https://maps.googleapis.com/maps/api/distancematrix/json?origins=51.4822656,-0.1933769&destinations=Westminster Abbey, Westminster, London SW1P 3PA, UK&key=<your_access_token>
Distancematrix.ai:
GET

https://api.distancematrix.ai/maps/api/distancematrix/json?origins=51.4822656,-0.1933769&destinations=Westminster Abbey, Westminster, London SW1P 3PA, UK&key=<your_access_token>
Required & Response parameters

Parameters in a request (part of the URL) is the same in both cases:

  1. list of origin locations (source <longitude,latitude> location coordinates or address) separated with vertical bar "|").
  2. list of destination locations (source <longitude,latitude> location coordinates or address) separated with vertical bar "|").
  3. key (your access token authorized to access the resource).

Response in JSON format (is the same in both cases):

  • The unit of value of durations is second.
  • The unit of value of distances is meter.
  • Meant for car routing to get the duration considering live traffic.
  • The coordinates pairs on which route is to be calculated. Minimum two pairs needed.

Distance Matrix example response

Google:
GET

{
    "destination_addresses": [
        "Westminster Abbey, 20 Deans Yd, London SW1P 3PA, United Kingdom"
    ],
    "origin_addresses": [
        "Chapel, London SW6 1BA, UK"
    ],
    "rows": [
        {
            "elements": [
                {
                    "distance": {
                        "text": "7.8 km",
                        "value": 7847
                    },
                    "duration": {
                        "text": "24 mins",
                        "value": 1481
                    }
                }
            ]
        }
    ],
    "status": "OK"
}
Distancematrix.ai:
GET

{
    "destination_addresses": [
        "Westminster Abbey, 20 Deans Yd, London SW1P 3PA, United Kingdom"
    ],
    "origin_addresses": [
        "Chapel, London SW6 1BA, UK"
    ],
    "rows": [
        {
            "elements": [
                {
                    "distance": {
                        "text": "7.8 km",
                        "value": 7847
                    },
                    "duration": {
                        "text": "24 mins",
                        "value": 1481
                    },
                    "origin": "51.4822656,-0.1933769",
                    "destination": "Westminster Abbey, Westminster, London SW1P 3PA, UK",
                    "status": "OK"
                }
            ]
        }
    ],
    "status": "OK"
}
FAQ

Is there a difference between how can Google API calculate distance and the API by Distancematrix.ai?

How does Google maps API calculate distance and how it differs from Distancematrix.ai API?
Google maps distance API uses a combination of data sources, including its own database of maps and road networks, satellite imagery, and user-submitted data to calculate distance and travel time. Google Maps API also factors in real-time traffic data and other variables such as road closures, construction, and accidents to provide accurate distance and travel time estimates.
Distancematrix.ai API also uses real-time traffic data to provide up-to-date information on travel times and delays. Our product utilizes statistical data on road congestion in different regions to predict travel times. We obtain this information from public traffic data sources and employ our algorithms to compute accurate travel time estimates.
While both Google Maps API and Distancematrix.ai API provide accurate distance and travel time estimates, there may be some differences in the specific calculations due to the differences in their algorithms and data sources. 

Can I use the Distancematrix.ai API as I use Google Maps API distance between two points?

Yes, you can use Distancematrix.ai API to calculate the distance between two points and obtain travel time estimates, similar to how you would use Google Maps API distance between two points. 
Similar to the Google Maps API get distance between two points, it can be used to retrieve the driving distance and travel time between two locations in an application. Distancematrix.ai API may be the best choice for logistics and route optimization due to its main features in providing a matrix of distances between multiple origins and destinations. 
And if you are looking for an API distance between two addresses, it is one of the main features of our API.
Moreover, the migration is really easy, you don’t even need to rewrite the code. Please check out our documentation

How does the Google API for distance calculation compare to Distancematrix.ai?

The Google API for distance calculation and Distancematrix.ai are both powerful tools for developers to calculate the distance and travel time between two points in an application. The Google API is well-known and widely used. Distancematrix.ai API is not so well-known yet, however, it also provides developers with a reliable and well-documented tool. 
The Google API is a paid service, with pricing based on the number of requests made. Distancematrix.ai offers a Free plan with limited requests per month, making it a good choice for developers on a budget. Furthermore, for those who have tested the tool and are prepared for ongoing use, Distancematrix.ai provides a Growth plan with a post-payment system similar to Google's. 
So the choice between the two will depend on the specific needs and budget of the developer.

No prepayment is needed.
Start for free and get instant access to all Distancematrix.ai products and features