Distance Matrix API | Travel Time & Distance

Guidelines for Developers
Before you begin
It is an HTTP API service that is designed to calculate all possible combinations between the starting point and the destination and allows you to consider traffic congestion and a specific mode of transport. This travel time API is available anywhere in the world and ensures a similar level of accuracy and response with the best analogs.

In this Distance Matrix API documentation, you can find an introduction for the product using and reference material on the available parameters.

What can you do with the Distance Matrix API?

This product ensures developers with a calculation of travel time and distance between some points. So, different types of delivery & courier services like food, goods, and medicine delivery have significant benefits from their use. Besides, you can use our API in route planning, logistics, and transportation, as well as in software development, real estate, and home and business services.

In particular, the product is critically helpful for taxi applications. It allows calculating the car delivery time while respecting traffic jams and congestion.

To choose the shortest route of the food delivery service from cafes and restaurants, our travel time API calculates the delivery time from each restaurant to the customer's address considering the road congestion.

Why use Distance Matrix API?

You can use our product to find the destination point closest to the origin point or for any other purpose. The API will return a duration and distance on each element's fastest or shortest route. In turn, each element is an origin-destination pair.

This solution works worldwide and is available for driving, walking, bicycling, and transit travel modes.

If real-time traffic does not affect your business significantly, you can save time and increase the product's performance by using its version without traffic monitoring. For large calculating volume, you can consider our Asynchronous Distance Matrix API.

How to use Distance Matrix API

You give input data (addresses or coordinates) for which you want to make an estimation. You will receive an answer in JSON format, and the response will contain information about the duration of each constructed route section. The calculated travel time for a route section always accounts for the current traffic conditions and the traffic forecast.

For example, there are three starting locations A, B, and C, and three destination locations E, B, and D. The Distance API returns the matrix of durations in seconds and distances in meters between the locations. It does not return route geometries.
origins \ destinations
E
B
D
A
A to E
A to B
A to D
B
B to E
B to B = 0
B to D
C
C to E
C to B
C to D
The time and distance between points may not be symmetric since the routes may differ by direction due to one-way streets or turn restrictions. For example, A to B may have a different duration than B to A.

The following sections ensure you with more detailed information based on Distance Matrix API examples.

Request Parameters

The Distance Matrix API request was created specifically to be similar to the Google Distance Matrix API request format. You can get more information on the Migrate to Distancematrix.ai API page.
A Distance Matrix API request takes the following form:
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>
Copied!
A Distance Matrix API request example:
GET:
https://api.distancematrix.ai/maps/api/distancematrix/json?origins=51.4822656,-0.1933769&destinations=51.4994794,-0.1269979&key=<your_access_token>
Copied!

Required Parameters

origins — a starting point for calculating travel distance and time. You can supply one or more locations separated by the pipe character (|) in the form of an address or latitude/longitude coordinates:
1. If you pass an address, the service geocodes the string and converts it to a latitude/longitude coordinate to calculate the distance. This coordinate may be different from that returned by the Geocoding API, for example, a building entrance rather than its center.
Show example
Hide example
Example request with addresses:
GET:
https://api.distancematrix.ai/maps/api/distancematrix/json?origins=Westminster Abbey, 20 Deans Yd, Westminster, London SW1P 3PA, United Kingdom&destinations=St John's Church, North End Rd, Fulham, London SW6 1PB, United Kingdom&key=<your_access_token>
Copied!
Response
BODY
{
    "destination_addresses": [
        "St John's Church, North End Rd, London SW6 1PB, United Kingdom"
    ],
    "origin_addresses": [
        "Westminster Abbey, 20 Deans Yd, London SW1P 3PA, United Kingdom"
    ],
    "rows": [
        {
            "elements": [
                {
                    "distance": {
                        "text": "7.3 km",
                        "value": 7346
                    },
                    "duration": {
                        "text": "23 mins",
                        "value": 1401
                    },
                    "origin": "Westminster Abbey, 20 Deans Yd, Westminster, London SW1P 3PA, United Kingdom",
                    "destination": "St John's Church, North End Rd, Fulham, London SW6 1PB, United Kingdom",
                    "status": "OK"
                }
            ]
        }
    ],
    "status": "OK"
}
Copied!
2. If you pass latitude/longitude coordinates, they are used unchanged to calculate distance. Ensure that no space exists between the latitude and longitude values.
Show example
Hide example
Example request with coordinates:
GET:
https://api.distancematrix.ai/maps/api/distancematrix/json?origins=51.4822656,-0.1933769&destinations=51.4994794,-0.1269979&key=<your_access_token>
Copied!
Response
BODY
{
    "destination_addresses": [
        "Westminster Abbey, London SW1P 3PA, UK"
    ],
    "origin_addresses": [
        "Chapel, London SW6 1BA, UK"
    ],
    "rows": [
        {
            "elements": [
                {
                    "distance": {
                        "text": "7.6 km",
                        "value": 7567
                    },
                    "duration": {
                        "text": "22 mins",
                        "value": 1359
                    },
                    "origin": "51.4822656,-0.1933769",
                    "destination": "51.4994794,-0.1269979",
                    "status": "OK"
                }
            ]
        }
    ],
    "status": "OK"
}
Copied!
  • destinations — one or more locations to use as the final destination for calculating travel distance and time. The options for the destination parameter are the same as for the original parameter, as described above.
  • key — the API key of your application.

Optional Parameters

  • mode (defaults to driving) — specifies the mode of transport to use when calculating distance. Valid values and other request details are specified in the Travel Modes section of this document.
  • language — a language that is used to return results.
    • See the list of supported languages.
    • If language is not supplied, the API attempts to use the preferred language as specified in the Accept-Language header, or the native language of the domain from which the request is sent.
    • The API does its best to provide a street address that is readable for both the user and locals. To achieve that goal, it returns street addresses in the local language, transliterated to a script readable by the user if necessary, observing the preferred language. All other addresses are returned in the preferred language. Address components are all returned in the same language, which is chosen from the first component.
    • If a name is not available in the preferred language, the API uses the closest match.
    • The preferred language has a small influence on the set of results that the API chooses to return, and the order in which they are returned. The geocoder interprets abbreviations differently depending on language, such as the abbreviations for street types, or synonyms that may be valid in one language but not in another. For example, utca and tér are synonyms for street in Hungarian.
Show languages
Hide languages
Language Code
Language
Language Code
Language
af
Afrikaans
ja
Japanese
sq
Albanian
kn
Kannada
am
Amharic
kk
Kazakh
am
Arabic
km
Khmer
hy
Armenian
ko
Korean
az
Azerbaijani
ky
Kyrgyz
eu
Basque
lo
Lao
be
Belarusian
lv
Latvian
bn
Bengali
lt
Lithuanian
bs
Bosnian
mk
Macedonian
bg
Bulgarian
ms
Malay
my
Burmese
ml
Malayalam
ca
Catalan
mr
Marathi
zh
Chinese
mn
Mongolian
zh-CN
Chinese (Simplified)
ne
Nepali
zh-HK
Chinese (Hong Kong)
no
Norwegian
zh-TW
Chinese (Traditional)
pl
Polish
hr
Croatian
pt
Portuguese
cs
Czech
pt-BR
Portuguese (Brazil)
da
Danish
pt-PT
Portuguese (Portugal)
nl
Dutch
pa
Punjabi
en
English
ro
Romanian
en-AU
English (Australian)
ru
Russian
en-GB
English (Great Britain)
sr
Serbian
et
Estonian
si
Sinhalese
fa
Farsi
sk
Slovak
fi
Finnish
sl
Slovenian
fil
Filipino
es
Spanish
fr
French
es-419
Spanish (Latin America)
fr-CA
French (Canada)
sw
Swahili
gl
Galician
sv
Swedish
ka
Georgian
ta
Tamil
de
German
te
Telugu
el
Greek
th
Thai
gu
Gujarati
tr
Turkish
iw
Hebrew
uk
Ukrainian
hi
Hindi
ur
Urdu
hu
Hungarian
uz
Uzbek
is
Icelandic
vi
Vietnamese
id
Indonesian
zu
Zulu
it
Italian


  • avoid — introduces restrictions to the route. Valid values are specified in the Restrictions section of this document. Only one restriction can be specified.
  • units — specifies the unit system to use when expressing distance as text. See the Unit Systems section of this document for more information.
  • arrival_time — specifies the desired time of arrival for transit requests, in seconds since midnight, January 1, 1970, UTC. You can specify either departure_time or arrival_time, but not both. Note that arrival_time must be specified as an integer.
Show example
Hide example
Request example with arrival_time:
GET:
https://api.distancematrix.ai/maps/api/distancematrix/json?origins=51.507033,-0.1277161&destinations=52.486243,-1.890401&arrival_time=now&transit_mode=bus&mode=transit&key=<your_access_token>
Copied!
Response
BODY
{
    "destination_addresses": [
        "Raw Network, Sherborne B16 8FN, United Kingdom"
    ],
    "origin_addresses": [
        "Giaralis Karavasilis Tsavdaridis, 49 The Mall, London N14 6LR, United Kingdom"
    ],
    "rows": [
        {
            "elements": [
                {
                    "distance": {
                        "text": "166.4 km",
                        "value": 166409
                    },
                    "duration": {
                        "text": "4 hour 2 mins",
                        "value": 14524
                    },
                    "origin": "51.507033,-0.1277161",
                    "destination": "52.486243,-1.890401",
                    "status": "OK"
                }
            ]
        }
    ],
    "status": "OK"
}
Copied!
  • departure_time — a desired time of the departure. You can specify the time as an integer in seconds since midnight, January 1, 1970, UTC. Alternatively, you can specify a value of now, which sets the departure time to the current time (correct to the nearest second). The departure_time must be set to the current time or some time in the future. It cannot be in the past. Results for a given request may vary over time due to the changes in the road network, updated average traffic conditions, and the distributed nature of the service. Results may also vary between nearly-equivalent routes at any time or frequency. The departure time may be specified in two cases:
    • For requests where the travel mode is transit: You can optionally specify one of departure_time or arrival_time. If neither time is specified, the departure_time defaults to now (that is, the departure time defaults to the current time).
    • For requests where the travel mode is driving: You can specify the departure_time to receive a route and trip duration (response field: duration_in_traffic) that take traffic conditions into account. The departure_time must be set to the current time or some time in the future. It cannot be in the past.
* Note: If departure time is not specified, choice of route and duration are based on road network and average time-independent traffic conditions. Results for a given request may vary over time due to changes in the road network, updated average traffic conditions, and the distributed nature of the service. Results may also vary between nearly-equivalent routes at any time or frequency.
Show example
Hide example
Example request with departure_time:
GET:
https://api.distancematrix.ai/maps/api/distancematrix/json?origins=51.507033,-0.1277161&destinations=52.486243,-1.890401&departure_time=now&key=<your_access_token>
Copied!
Response
BODY
{
    "destination_addresses": [
        "Raw Network, Sherborne B16 8FN, United Kingdom"
    ],
    "origin_addresses": [
        "Giaralis Karavasilis Tsavdaridis, 49 The Mall, London N14 6LR, United Kingdom"
    ],
    "rows": [
        {
            "elements": [
                {
                    "distance": {
                        "text": "207.3 km",
                        "value": 207323
                    },
                    "duration": {
                        "text": "2 hour 27 mins",
                        "value": 8844
                    },
                    "duration_in_traffic": {
                        "text": "2 hour 29 mins",
                        "value": 8968
                    },
                    "origin": "51.507033,-0.1277161",
                    "destination": "52.486243,-1.890401",
                    "status": "OK"
                }
            ]
        }
    ],
    "status": "OK"
}
Copied!
  • traffic_model (defaults to best_guess) — specifies the assumptions to use when calculating time in traffic. This setting affects the value returned in the duration_in_traffic field in the response, which contains the predicted time in traffic based on historical averages. The traffic_model parameter may only be specified for requests where the travel mode is driving, and where the request includes a departure_time. The available values for this parameter are:
    • best_guess (default) indicates that the returned duration_in_traffic should be the best estimate of travel time given what is known about both historical traffic conditions and live traffic. Live traffic becomes more important the closer the departure_time is to now.
    • pessimistic indicates that the returned duration_in_traffic should be longer than the actual travel time on most days, though occasional days with particularly bad traffic conditions may exceed this value. Affects the field in the distance_in_traffic_model response, returning the shortest route.
    • optimistic indicates that the returned duration_in_traffic should be shorter than the actual travel time on most days, though occasional days with particularly good traffic conditions may be faster than this value. Affects the field in the distance_in_traffic_model response, returning the shortest route.
Show example
Hide example
Example request with traffic_model:
GET:
https://api.distancematrix.ai/maps/api/distancematrix/json?origins=51.507033,-0.1277161&destinations=52.486243,-1.890401&traffic_model=pessimistic&departure_time=now&key=<your_access_token>
Copied!
Response
BODY
{
    "destination_addresses": [
        "Raw Network, Sherborne B16 8FN, United Kingdom"
    ],
    "origin_addresses": [
        "Giaralis Karavasilis Tsavdaridis, 49 The Mall, London N14 6LR, United Kingdom"
    ],
    "rows": [
        {
            "elements": [
                {
                    "distance": {
                        "text": "207.3 km",
                        "value": 207323
                    },
                    "duration": {
                        "text": "2 hour 27 mins",
                        "value": 8844
                    },
                    "duration_in_traffic": {
                        "text": "4 hour 0 mins",
                        "value": 14400
                    },
                    "distance_in_traffic_model": {
                        "text": "118 miles",
                        "value": 189274
                    },
                    "origin": "51.507033,-0.1277161",
                    "destination": "52.486243,-1.890401",
                    "status": "OK"
                }
            ]
        }
    ],
    "status": "OK"
}
Copied!
  • transit_mode — specifies one or more preferred modes of transit. This parameter may only be specified for requests where the mode is transit. The parameter supports the following arguments:
    • bus indicates that the calculated route should prefer travel by bus.
    • subway indicates that the calculated route should prefer travel by subway.
    • train indicates that the calculated route should prefer travel by train.
    • tram indicates that the calculated route should prefer travel by tram and light rail.
    • rail indicates that the calculated route should prefer travel by train, tram, light rail, and subway. This is equivalent to transit_mode=train|tram|subway.
Show example
Hide example
Request example with transit_mode:
GET:
https://api.distancematrix.ai/maps/api/distancematrix/json?origins=51.507033,-0.1277161&destinations=52.486243,-1.890401&transit_mode=bus|train|tram|subway&mode=transit&departure_time=now&key=<your_access_token>
Copied!
Response
BODY
{
    "destination_addresses": [
        "Raw Network, Sherborne B16 8FN, United Kingdom"
    ],
    "origin_addresses": [
        "Giaralis Karavasilis Tsavdaridis, 49 The Mall, London N14 6LR, United Kingdom"
    ],
    "rows": [
        {
            "elements": [
                {
                    "distance": {
                        "text": "207.3 km",
                        "value": 207323
                    },
                    "duration": {
                        "text": "2 hour 27 mins",
                        "value": 8844
                    },
                    "duration_in_traffic": {
                        "text": "2 hour 29 mins",
                        "value": 8968
                    },
                    "origin": "51.507033,-0.1277161",
                    "destination": "52.486243,-1.890401",
                    "status": "OK"
                }
            ]
        }
    ],
    "status": "OK"
}
Copied!

Travel Modes

For the calculation of distances, you may specify the transportation mode to use. By default, distances are calculated for the driving mode. The following travel modes are supported:
  • driving (default) indicates distance calculation using the road network.
  • walking requests distance calculation for walking via pedestrian paths & sidewalks (where available).
  • bicycling requests distance calculation for bicycling via bicycle paths & preferred streets (where available).
  • transit requests distance calculation via public transit routes (where available). If you set the mode to transit you need specify either a departure_time or an arrival_time. If neither time is specified, the departure_time defaults to now (that is, the departure time defaults to the current time). You need also include a transit_mode.
Show example
Hide example
Example request with travel modes:
GET:
https://api.distancematrix.ai/maps/api/distancematrix/json?origins=51.4822656,-0.1933769&destinations=51.4994794,-0.1269979&mode=walking&departure_time=now&key=<your_access_token>
Copied!
Response
BODY
{
    "destination_addresses": [
        "Westminster Abbey, London SW1P 3PA, UK"
    ],
    "origin_addresses": [
        "Chapel, London SW6 1BA, UK"
    ],
    "rows": [
        {
            "elements": [
                {
                    "distance": {
                        "text": "5.7 km",
                        "value": 5699
                    },
                    "duration": {
                        "text": "1 hour 12 mins",
                        "value": 4379
                    },
                    "origin": "51.4822656,-0.1933769",
                    "destination": "51.4994794,-0.1269979",
                    "status": "OK"
                }
            ]
        }
    ],
    "status": "OK"
}
Copied!

Traffic Information

Traffic information is used when all the following apply (these are the conditions required to receive the duration_in_traffic field in the Distance Matrix response):
  • The travel mode parameter is driving, or it is not specified (driving is the default travel mode).
  • The request includes a valid departure_time parameter. The departure_time can be set to the current time or some other time.
Optionally, you can include the traffic_model parameter in your request to specify the assumptions to use when calculating time in traffic.
Show example
Hide example
Example request with traffic information:
GET:
https://api.distancematrix.ai/maps/api/distancematrix/json?origins=51.4822656,-0.1933769&destinations=51.4994794,-0.1269979&mode=driving&departure_time=now&key=<your_access_token>
Copied!
Response
BODY
{
    "destination_addresses": [
        "Westminster Abbey, London SW1P 3PA, UK"
    ],
    "origin_addresses": [
        "Chapel, London SW6 1BA, UK"
    ],
    "rows": [
        {
            "elements": [
                {
                    "distance": {
                        "text": "7.6 km",
                        "value": 7567
                    },
                    "duration": {
                        "text": "22 mins",
                        "value": 1359
                    },
                    "duration_in_traffic": {
                        "text": "23 mins",
                        "value": 1395
                    },
                    "origin": "51.4822656,-0.1933769",
                    "destination": "51.4994794,-0.1269979",
                    "status": "OK"
                }
            ]
        }
    ],
    "status": "OK"
}
Copied!

Restrictions

Distances may be calculated that adhere to certain restrictions. Restrictions are indicated by the use of the avoid parameter and an argument to that parameter indicating the restriction to avoid. The following restrictions are supported:
  • avoid=tolls
  • avoid=highways
  • avoid=ferries
  • avoid=indoor
* Note: the addition of restrictions does not preclude routes that include the restricted feature; it simply biases the result to more favorable routes.
Show example
Hide example
Example request with restrictions:
GET:
https://api.distancematrix.ai/maps/api/distancematrix/json?origins=51.4822656,-0.1933769&destinations=51.4994794,-0.1269979&mode=driving&departure_time=now&avoid=ferries&key=<your_access_token>
Copied!
Response
BODY
{
    "destination_addresses": [
        "Westminster Abbey, London SW1P 3PA, UK"
    ],
    "origin_addresses": [
        "Chapel, London SW6 1BA, UK"
    ],
    "rows": [
        {
            "elements": [
                {
                    "distance": {
                        "text": "7.6 km",
                        "value": 7567
                    },
                    "duration": {
                        "text": "22 mins",
                        "value": 1359
                    },
                    "duration_in_traffic": {
                        "text": "26 mins",
                        "value": 1568
                    },
                    "origin": "51.4822656,-0.1933769",
                    "destination": "51.4994794,-0.1269979",
                    "status": "OK"
                }
            ]
        }
    ],
    "status": "OK"
}
Copied!

Unit Systems

Distance Matrix results contain text within distance fields to indicate the distance of the calculated route. The unit system to use can be specified:
  • units=metric (default) returns distances in kilometers and meters.
  • units=imperial returns distances in miles and feet.
Show example
Hide example
Example request with unit system:
GET:
https://api.distancematrix.ai/maps/api/distancematrix/json?origins=51.4822656,-0.1933769&destinations=51.4994794,-0.1269979&departure_time=now&units=imperial&key=<your_access_token>
Copied!
Response
BODY
{
    "destination_addresses": [
        "Westminster Abbey, London SW1P 3PA, UK"
    ],
    "origin_addresses": [
        "Chapel, London SW6 1BA, UK"
    ],
    "rows": [
        {
            "elements": [
                {
                    "distance": {
                        "text": "4.7 mi",
                        "value": 7567
                    },
                    "duration": {
                        "text": "22 mins",
                        "value": 1359
                    },
                    "duration_in_traffic": {
                        "text": "26 mins",
                        "value": 1568
                    },
                    "origin": "51.4822656,-0.1933769",
                    "destination": "51.4994794,-0.1269979",
                    "status": "OK"
                }
            ]
        }
    ],
    "status": "OK"
}
Copied!
* Note: this unit system setting only affects the text displayed within distance fields. The distance fields also contain values which are always expressed in meters.

Response example

The response contains an array of rows objects, each row containing one origin paired with each destination. Each element of the object in the array contains the properties of a single route variant. For the detailed description of elements, see the section Distance Matrix Response Elements.
Response
BODY
{
    "destination_addresses": [
        "Westminster Abbey, London SW1P 3PA, UK"
    ],
    "origin_addresses": [
        "Chapel, London SW6 1BA, UK"
    ],
    "rows": [
        {
            "elements": [
                {
                    "distance": {
                        "text": "7.6 km",
                        "value": 7567
                    },
                    "duration": {
                        "text": "22 mins",
                        "value": 1359
                    },
                    "origin": "51.4822656,-0.1933769",
                    "destination": "51.4994794,-0.1269979",
                    "status": "OK"
                }
            ]
        }
    ],
    "status": "OK"
}
Copied!

Distance Matrix Response Elements

Distance Matrix responses contain the following root elements:
  • status contains metadata on the request. See Status Codes below.
  • origin_addresses contain an array of addresses as returned by the API from your original request. These are formatted by the geocoder and localized according to the language parameter passed with the request.
  • destination_addresses contain an array of addresses returned by the API from your initial request. As with origin_addresses, these are localized if appropriate.
  • rows contain an array of elements, which in turn contain status, duration, and distance element.

Status Codes

The status fields within the response object contain the status of the request and may contain useful debugging information. The Distance Matrix API returns a top-level status field with information about the request in general, as well as a status field for each element field with information about that particular origin-destination pairing.

Top-level Status Codes

  • OK indicates the response contains a valid result.
  • INVALID_REQUEST indicates that the provided request was invalid.
  • MAX_ELEMENTS_EXCEEDED indicates that the product of origin and destination exceeds the per-query limit.
  • OVER_DAILY_LIMIT indicates any of the following:
    • The API key is missing or invalid.
    • Billing has not been enabled on your account.
    • A self-imposed usage cap has been exceeded.
    • The provided method of payment is no longer valid (for example, a credit card has expired).
  • OVER_QUERY_LIMIT indicates the service has received too many requests from your application within the allowed time period.
  • REQUEST_DENIED indicates that the service denied the use of the Distance Matrix service by your application.
  • UNKNOWN_ERROR indicates a Distance Matrix request could not be processed due to a server error. The request may succeed if you try again.

Element-level Status Codes

  • OK indicates the response and contains a valid result.
  • NOT_FOUND indicates that the origin and/or destination of this pairing could not be geocoded.
  • ZERO_RESULTS indicates that no route could be found between the origin and destination.
  • MAX_ROUTE_LENGTH_EXCEEDED indicates that the requested route is too long and cannot be processed.
  • UNKNOWN_ERROR indicates a Distance Matrix request could not be processed due to a server error. The request may succeed if you try again.

Error Messages

When the top-level status code is other than OK, there may be an additional error_message field within the Distance Matrix response object. This field contains more detailed information about the reasons behind the given status code.

Rows

When the Distance Matrix API returns results, it places them within a JSON row array. Even if no results are returned (such as when the origins and/or destinations don't exist), it still returns an empty array.

Rows are ordered according to the values in the origin parameter of the request. Each row corresponds to an origin, and each element within that row corresponds to a pairing of the origin with a destination value.

Each row array contains one or more element entries, which in turn contain the information about a single origin-destination pairing.

Elements

The information about each origin-destination pairing is returned in an element entry. An element contains the following fields:
  • status: See Status Codes for a list of possible status codes.
  • duration: The length of time it takes to travel this route, expressed in seconds (the value field) and as text.
  • duration_in_traffic: The length of time it takes to travel this route, based on current and historical traffic conditions.
  • distance: The total distance of this route, expressed in meters (value) and as text. The textual value uses the unit system specified with the unit parameter of the original request, or the origin's region.
  • distance_in_traffic_model: The shortest distance needed to travel this route, based on current and historical traffic conditions.
FAQ

How to use distance API?

Using a distance API like Distancematrix.ai is typically a straightforward process. Here are the basic steps for using the API:

  • Register to the platform and obtain an API key. The API key is a unique identifier that allows you to access the API.
  • Choose your API product: The Distancematrix.ai API provides several methods for different types of distance calculations, such as distance between two points, distance matrix for multiple origins and destinations, and travel time estimates. Choose the best way to use the API that suits your needs.
  • Set your parameters: Depending on the product you choose, you will need to set parameters such as the origins and destinations (in the form of addresses or lat-long coordinates), transportation mode (driving, walking, etc.), and other options such as avoiding tolls or highways.
  • Send your request: Once you have set your parameters, you can send a request to the API distance matrix using your API key. The API will process your request and return the distance results and travel times in the format specified in your request.
  • Cache and use the results: Finally, you can parse the results returned by the API and use them in your application or website. The API can return results in JSON, which can be easily converted into various formats, including XML and CSV.

The specific steps for using the Distancematrix.ai API may vary depending on your programming language or framework. However, we provide detailed Distance Matrix API documentation and sample code to help you get started.

What is the difference between an API distance matrix and other APIs?

API distance matrix, map distance API, and direction matrix API are all types of APIs that provide distance-related data, but they have some peculiarities.
An API distance matrix is designed to calculate the distances between multiple origins and destinations. It provides a matrix of distances that can be used to calculate travel time or optimize routes for delivery or logistics. This type of API is useful for businesses that need to plan and optimize travel routes or logistics operations.

A map distance API, on the other hand, provides distance-related data for a specific geographic area, such as the distance between two points on a map. This type of API is useful for applications that need to display distance-related data on a map, such as a fitness tracker or a travel app.

A direction matrix API, such as Google Maps Directions API, provides turn-by-turn directions between two or more points. It includes information such as the distance, estimated travel time, and the route to take. This type of API is useful for applications that require navigation or routing capabilities, such as a ride-sharing app or a GPS device.

In summary, while distance matrix API, map distance API, and direction matrix API all provide distance-related data, they are optimized for different use cases. The Distance Matrix API by Distancematrix.ai currently includes distance matrix and geocoding products. We don't provide maps or directions solutions right now. However, you can use the data in your business to optimize travel routes or logistics operations, this data is for applications that need to display distance-related data on a map, and for applications that require navigation or routing capabilities.

Easy to integrate the Distance Matrix API
Start
How to migrate to DistanceMatrix
No prepayment is needed.
Start for free and get instant
access to all Distancematrix.ai
products and features