This guide describes how to migrate apps that use either Directions API or Distance Matrix API to using the Routes API. For details on the Routes API, see product overview.
Update the REST API endpoints
Update your code to use the new Routes API endpoints
From Directions API
Directions API | https://maps.googleapis.com/maps/api/directions/outputFormat?parameters |
Routes API | https://routes.googleapis.com/directions/v2:computeRoutes |
From Distance Matrix API
Distance Matrix API | https://maps.googleapis.com/maps/api/distancematrix/outputFormat?parameters |
Routes API | https://routes.googleapis.com/distanceMatrix/v2:computeRouteMatrix |
Convert URL parameters to use an HTTPS request body
With Directions API and Distance Matrix API, you
pass configuration properties as URL parameters to an HTTP GET
request. For
example, for the Directions API:
https://maps.googleapis.com/maps/api/directions/outputFormat?parameters
With the Routes API, you pass parameters in a request body or in headers
as part of an HTTP POST
request. For examples, see:
Convert waypoints represented as encoded polylines to intermediate waypoints
Specifying waypoints as encoded polylines is available in the Directions API to fit a large number of waypoints in the URL limit of 8192 characters. This feature is not necessary in the Routes API because waypoints can be transmitted in the REST or gRPC requests body as intermediate waypoints.
Convert existing parameters to Routes API parameters
The following table lists parameters in the Directions API and Distance Matrix API that have been renamed or modified, or parameters that are not supported in the GA release. Update your code if you are using any of these parameters.
Routes or Distance matrix parameter | Routes API parameter | Notes |
---|---|---|
alternatives |
computeAlternativeRoutes |
|
arrival_time |
Not available because TRANSIT mode not available. |
|
avoid |
routeModifiers |
|
copyrights |
Not included in the response. You must include the following statement when displaying the results to your users:
For example:
|
|
departure_time |
departureTime |
|
distance |
distanceMeters |
Distance is only available in meters. |
duration_in_traffic |
|
Removed in the Routes API, use duration . For more
information, see
Functionality changes for the new
Routes API above. |
language |
languageCode |
Supported for Compute Routes only. |
mode |
travelMode |
Added support for
|
region |
regionCode |
|
status |
Not available. Use the HTTP response codes for errors reported by the API. See Handle request errors for more information. | |
traffic_model |
Not available. | |
transit_mode |
Not available because TRANSIT mode not available. |
|
transit_routing_preference |
Not available because TRANSIT mode not available. |
|
units |
Not available for route matrix. | |
waypoints |
intermediates |
Removed support for encoded polylines. |
optimize=true for waypoints |
Not available. |