Overview
The Distance Matrix API is an HTTP API for calculating the distance and duration of routes. The Distance Matrix calculates all possible combinations for the origin and destination points. For example, you can use the API to find the restaurant that is closest to the point of origin.
The calculated travel time for a section always accounts for current traffic conditions and the traffic forecast.
To send API requests, get an API key.
There are two variants of the Distance Matrix API available Synchronous and Asynchronous.
Synchronous API
- The maximum size of the matrix is 100 items.
- Maximum requests per second (RPS): 5. If the limit is exceeded, some requests will be rejected with the HTTP 429 status.
- You get charged for each combination of origin and destination point in a request. E.g. request with 3 origins and 5 destinations has 15 combinations.
- Single request per matrix.
To generate more complex matrices, you can divide them into multiple queries or you can opt in to use our Asynchronous API.
Asynchronous API
- The maximum size of the matrix is 25 million items.
- Maximum requests per second (RPS): 5. If the limit is exceeded, some requests will be rejected with the HTTP 429 status.
- Several requests need to be made per matrix:
- Initiate a long-running operation to compute the matrix.
- Wait for the operation to complete by polling the status of the operation.
- Retrieve the resulting matrix once the operation has completed.