Calculate Route
Purpose
The Calculate Route service calculates a route between an origin and a destination, passing through waypoints if they are specified.
- The route will take into account factors such as current traffic and the typical road speeds on the requested day of the week and time of day.
- Information returned includes the distance, estimated travel time, and a representation of the route geometry.
- Additional routing information, such as optimized waypoint order or turn by turn instructions, is also available, depending on the options selected.
Please be aware that this document does not specify the complete request or response format. To maintain forward compatibility, you must be able to process responses with additional non-documented data fields. Our deprecation policy only covers the documented subset of these formats.
Run this endpoint
You can easily run this and other endpoints. Go to the TomTom API Explorer page and follow the directions.
Request data
HTTPS methods: GET POST
Constants and parameters enclosed in curly brackets { } must be replaced with their values.
Generic request format
The following request URL contains all of this endpoint’s respective parameters. For their details, please see the Request parameters section. In addition, this endpoint supports guidance functionality that is collectively described in the Guidance Instructions page.
https://{baseURL}/routing/{versionNumber}/calculateRoute/{routePlanningLocations}/{contentType}?key={Your_API_Key}&callback={callback}&maxAlternatives={alternativeRoutes}&alternativeType={alternativeType}&minDeviationDistance={integer}&minDeviationTime={integer}&supportingPointIndexOfOrigin={integer}&computeBestOrder={boolean}&routeRepresentation={routeRepresentation}&computeTravelTimeFor={trafficTypes}&vehicleHeading={integer}&language={language}§ionType={sectionType}&includeTollPaymentTypes={includeTollPaymentTypes}&report={effectiveSettings}&departAt={time}&arriveAt={time}&routeType={routeType}&traffic={boolean}&avoid={avoidType}&travelMode={travelMode}&hilliness={hilliness}&windingness={windingness}&vehicleMaxSpeed={vehicleMaxSpeed}&vehicleWeight={vehicleWeight}&vehicleAxleWeight={vehicleAxleWeight}&vehicleNumberOfAxles={vehicleNumberOfAxles}&vehicleLength={vehicleLength}&vehicleWidth={vehicleWidth}&vehicleHeight={vehicleHeight}&vehicleCommercial={boolean}&vehicleLoadType={vehicleLoadType}&vehicleAdrTunnelRestrictionCode={vehicleAdrTunnelRestrictionCode}&vehicleEngineType={vehicleEngineType}&constantSpeedConsumptionInLitersPerHundredkm={CombustionConstantSpeedConsumptionPairs}¤tFuelInLiters={float}&auxiliaryPowerInLitersPerHour={float}&fuelEnergyDensityInMJoulesPerLiter={float}&accelerationEfficiency={float}&decelerationEfficiency={float}&uphillEfficiency={float}&downhillEfficiency={float}&consumptionInkWhPerkmAltitudeGain={float}&recuperationInkWhPerkmAltitudeLoss={float}&constantSpeedConsumptionInkWhPerHundredkm={ElectricConstantSpeedConsumptionPairs}¤tChargeInkWh={float}&maxChargeInkWh={float}&auxiliaryPowerInkW={float}&chargeMarginsInkWh={commaSeparatedFloats}&extendedRouteRepresentation={extendedRouteRepresentation}GET URL example
Note: Line breaks are designated by ”\”.
https://api.tomtom.com/routing/1/calculateRoute/\52.50931,13.42936:52.50274,13.43872/json?\vehicleHeading=90§ionType=traffic\&report=effectiveSettings&routeType=eco\&traffic=true&avoid=unpavedRoads\&travelMode=car&vehicleMaxSpeed=120\&vehicleCommercial=false&vehicleEngineType=combustion\&key={Your_API_Key}GET curl command example
Note: Line breaks are designated by ”\”.
curl -X GET "https://api.tomtom.com/routing/1/calculateRoute/\52.50931,13.42936:52.50274,13.43872/json?\vehicleHeading=90§ionType=traffic\&report=effectiveSettings\&routeType=eco\&traffic=true&avoid=unpavedRoads&travelMode=car\&vehicleMaxSpeed=120&vehicleCommercial=false\&vehicleEngineType=combustion&key={Your_API_Key}" -H "accept:*/*"POST URL example
https://api.tomtom.com/routing/1/calculateRoute/52.50931,13.42936:52.50274,13.43872/json?key={Your_API_Key}POST curl command examples
curl -X POST "https://api.tomtom.com/routing/1/calculateRoute/52.50931,13.42936:52.50274,13.43872/json?key={Your_API_Key}" -H "Content-type:application/json" -d \'{ "supportingPoints": [ { "latitude": 52.5093, "longitude": 13.42936 }, { "latitude": 52.50844, "longitude": 13.42859 } ], "avoidVignette": [ "AUS", "CHE" ]}'curl -X POST "https://api.tomtom.com/routing/1/calculateRoute/52.50931,13.42936:52.50274,13.43872/json?key={Your_API_Key}" -H "Content-type:application/json" -d \'{ "encodedPolyline": "cvn_Io|}pAjDxC", "encodedPolylinePrecision": 5, "avoidVignette": [ "AUS", "CHE" ]}'curl -X POST "https://api.tomtom.com/routing/1/calculateRoute/52.50931,13.42936:52.511572,13.416830:52.521860,13.427642:52.50274,13.43872/json?key={Your_API_Key}" -H "Content-type:application/json" -d \'{ "legs" : [ { "routeType" : "eco", "routeStop": { "pauseTimeInSeconds": 610 } }, { "supportingPoints": [ { "latitude": 52.5093, "longitude": 13.42936 }, { "latitude": 52.50844, "longitude": 13.42859 } ] }, { "routeType": "thrilling", "windingness": "low", "hilliness": "high", "avoids": [ { "name": "tollRoads" } ] } ]}'curl -X POST "https://api.tomtom.com/routing/1/calculateRoute/52.50931,13.42936:52.511572,13.416830:52.521860,13.427642:52.50274,13.43872/json?key={Your_API_Key}" -H "Content-type:application/json" -d \'{ "legs" : [ { "routeType" : "eco", "routeStop": { "pauseTimeInSeconds": 610 } }, { "encodedPolyline": "cvn_Io|}pAjDxC", "encodedPolylinePrecision": 5 }, { "routeType": "thrilling", "windingness": "low", "hilliness": "high" } ]}'curl -X POST "https://api.tomtom.com/routing/1/calculateRoute/52.328416,13.626480:52.36428,13.508614/json?key={Your_API_Key}" -H "Content-type:application/json" -d \'{ "legs" : [ { "routeStop": { "entryPoints": [ { "latitude": 52.36443, "longitude": 13.50929 }, { "latitude": 52.38909, "longitude": 13.51781 }, { "latitude": 52.37038, "longitude": 13.52149 }, { "latitude": 52.36281, "longitude": 13.51031 } ], "preferredEntryPointIndex": 0 } } ]}'Types
The following data table describes the types that can be used in the Calculate Route service.
| Type | Description |
|---|---|
| A latitude–longitude pair (in EPSG:4326 projection) with the following constraints:
Example: |
| A |
circle | A circle with a center point and a radius (in meters). The radius must
be a positive integer, with a maximum value of 135000. |
generalizedLocation | A
|
commaSeparatedFloats | A comma-separated list of floats. |
| A date and time specified in RFC 3339 format with an optional time zone offset.
|
| A comma-separated |
| A comma-separated |
Avoid parameter possible values
Value | Description |
|---|---|
tollRoads | Avoids toll roads. |
motorways | Avoids motorways. Note: Avoiding motorways for long routes of approximately 500km+ may result in computation timeouts of the primary route or path alternatives. |
ferries | Avoids ferries. |
unpavedRoads | Avoids unpaved roads. |
carpools | Avoids routes that require use of carpool (HOV/High Occupancy Vehicle) lanes. |
alreadyUsedRoads | Avoids using the same road multiple times. |
borderCrossings | Avoids crossing country borders. |
tunnels | Avoids tunnels. |
carTrains | Avoids car trains. |
lowEmissionZones | Avoids low-emission zones. |
Request headers
The following table describes HTTP request headers that are particularly relevant for clients of the Calculate Route service.
- Required headers must be used; otherwise, the call will fail.
- Optional headers can be used to customize the request.
- The order of request headers is not important.
Optional headers | Description |
|---|---|
| Accept-Encoding | Requests that the response be compressed. |
| Content-Encoding | Specifies the compression used for the request body. Currently, only
Note: This header is optional and can only be used for
Values:
|
| Content-Type | Specifies the MIME type of the body of the request. Note: This header is required for Value: |
| Tracking-ID | Specifies an identifier for the request.
|
Base path parameters
The following tables describe the parameters that can be used in the Calculate Route service.
- Required parameters must be used; otherwise, the call will fail.
- The order of the required parameters is important and must be followed.
- Optional parameters can be used to customize the request.
| Required parameters (Base path) | Description |
|---|---|
| The base URL used to call the API.
|
| The service version number. |
| Locations through which the route is calculated. The following constraints apply:
Values: Colon-delimited |
Optional parameters | Description |
|---|---|
| The content type of the response structure.
Note: If the content type is |
Request parameters
This section presents a set of loosely connected parameters that influence the operation of the routing algorithm. While some of them are associated, the majority can be used independently of the others.
- Required parameters must be used; otherwise, the call will fail.
- Optional parameters may be used.
- The order of the request parameters is not important.
Required parameters | Description |
|---|---|
| The API key used to authorize requests to the Routing API. |
| Optional parameters | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Specifies the | ||||||||||||||||||||
| Specifies which data to report for diagnostic purposes.
Possible value is:
Default value: | ||||||||||||||||||||
| The date and time of departure from the origin point.
Default value: | ||||||||||||||||||||
| The date and time of arrival at the destination point.
The
Value: | ||||||||||||||||||||
| Specifies the type of optimization used when calculating routes.
Default value: | ||||||||||||||||||||
| Possible values are:
Depending on availability, the Routing API takes road closures and road works
into account up to 60 days in the future. | ||||||||||||||||||||
| Specifies something that the route calculation should try to avoid when
determining the route. The | ||||||||||||||||||||
| The mode of travel for the requested route.
Note that travel modes
Default value:
| ||||||||||||||||||||
| Degree of hilliness for a thrilling route.
| ||||||||||||||||||||
| Level of turns for a
| ||||||||||||||||||||
| Maximum speed of the vehicle in kilometers/hour.
Default value: | ||||||||||||||||||||
| Weight of the vehicle in kilograms.
Default value: | ||||||||||||||||||||
| Weight per axle of the vehicle in kilograms. A value of
| ||||||||||||||||||||
| Number of axles of the vehicle. A value of | ||||||||||||||||||||
| Length of the vehicle in meters, including the length of any additional
equipment, e.g., trailers, bike racks, etc. A value of | ||||||||||||||||||||
| Width of the vehicle in meters. A value of | ||||||||||||||||||||
| Height of the vehicle in meters. A value of | ||||||||||||||||||||
| Vehicle is used for commercial purposes and thus may not be allowed to
drive on some roads. | ||||||||||||||||||||
| Specifies types of cargo that may be classified as hazardous materials
and are restricted from some roads. The or ).
Use these values for routing in the USA:
Use these values for routing in all other countries:
Notes:
| ||||||||||||||||||||
| If
Notes:
Values (specify at most one):
Reference: | ||||||||||||||||||||
| Specifies whether the route calculation should try to avoid ETC-transponder-only toll roads if the vehicle does not have an ETC transponder. Possible values are:
Default value: | ||||||||||||||||||||
| Specifies the precision of coordinates in the response.
Default value: | ||||||||||||||||||||
| Specifies how to reconstruct a given polyline or individual legs.
Note: This parameter can only be used when a route or legs are provided as part
of the request by using a polyline representation format (see the Route geometry representation formats section).
Note: In any of the modes, the algorithm might relax certain restrictions near the origin and destination to offer a more sensible route instead of a no-route-found. This ensures that routes planned with our service can be reconstructed.
| ||||||||||||||||||||
| Specifies the preferred roadside for arrival at waypoints and the destination. The stop must be positioned at least two meters on the preferred side of the road,
otherwise the behavior will default to
Default value: | ||||||||||||||||||||
| Number of desired alternative routes to be calculated. The value provided:
Default value: | ||||||||||||||||||||
| When
Note: The Default value: | ||||||||||||||||||||
| All alternative routes returned will follow the reference route (see the
POST data parameters section) from
the origin point of the
0 | ||||||||||||||||||||
| All alternative routes returned will follow the reference route (see the
POST data parameters section) from
the origin point of the
0 | ||||||||||||||||||||
| Largest index in the given polyline per route
or in the joined polyline per leg (see the
POST data parameters section) for
which element with the index
Minimum value: | ||||||||||||||||||||
| Re-orders the route waypoints with a fast heuristic algorithm to reduce
the overall route length. Note that based on the heuristic nature of the
algorithm, optimality is not guaranteed. Yields the best results when used
in conjunction with
false | ||||||||||||||||||||
| Specifies the representation of the set of routes provided as a response.
Default value:
| ||||||||||||||||||||
| Specifies whether to return additional travel times using different
types of traffic information (none, historic, live) as well as the
default best-estimate travel time.
Default value: | ||||||||||||||||||||
| The directional heading of the vehicle, in degrees, starting at true north and continuing in a clockwise direction.
Maximum value: | ||||||||||||||||||||
| Specifies which of the section types is reported in the route response.
Default value:
| ||||||||||||||||||||
| Include toll payment types in the toll section. If a toll section has different toll payment types in its subsections, this toll section is split into multiple toll sections with the toll payment types. Possible values:
The value Default value: | ||||||||||||||||||||
| Specifies a list of margins in kilowatt-hours (kWh) for computing
Minimum value: | ||||||||||||||||||||
| Specifies the extended representation of the set of routes provided as a
response.
| ||||||||||||||||||||
| The
en-GB |
Deprecation notice
Consumption model parameters
Routing provides a set of parameters for describing a vehicle-specific Consumption model in detail. These parameters can be specified in a calculateRoute request.
Depending on the value of vehicleEngineType, we support two principal Consumption models:
- Combustion consumption model
- Electric consumption model
Note:
- Specifying parameters that belong to different models in the same request is an error.
- A Consumption model cannot be used with the
travelModevalues ofbicycleandpedestrian.
Using the detailed consumption model has two consequences for a calculateRoute request:
- When the parameter
routeTypeis set toeco, then the Consumption Model will be taken into account for route planning. - When
constantSpeedConsumption*is specified, the response will include eitherfuelConsumptionInLitersorbatteryConsumptionInkWh(forvehicleEngineTypeset tocombustionorelectric, respectively) as an additional field in eachsummaryelement.
Parameter constraints
In both Consumption models, explicitly specifying some parameters requires specifying some others as well. In addition, some parameters are mutually exclusive. These are the constraints:
- All parameters require
constantSpeedConsumption*to be specified by the user.- It is an error to specify any other Consumption model parameter (with the exception of
vehicleWeight) ifconstantSpeedConsumption*is not specified.
- It is an error to specify any other Consumption model parameter (with the exception of
accelerationEfficiencyanddecelerationEfficiencymust always be specified as a pair (i.e., both or none).- If
accelerationEfficiencyanddecelerationEfficiencyare specified, the product of their values must not be greater than1(to prevent perpetual motion).
- If
uphillEfficiencyanddownhillEfficiencymust always be specified as a pair (i.e., both or none).- If
uphillEfficiencyanddownhillEfficiencyare specified, the product of their values must not be greater than1(to prevent perpetual motion).
- If
consumptionInkWhPerkmAltitudeGainandrecuperationInkWhPerkmAltitudeLossmust always be specified as a pair (i.e., both or none).- If they are specified,
recuperationInkWhPerkmAltitudeLossmust not be greater thanconsumptionInkWhPerkmAltitudeGain(to prevent perpetual motion).
- If they are specified,
- If
*Efficiencyparameters are specified by the user, thenvehicleWeightmust also be specified.- When
vehicleEngineTypeiscombustion,fuelEnergyDensityInMJoulesPerLitermust be specified as well.
- When
- If
*Efficiencyparameters are specified by the user, thenconsumptionInkWhPerkmAltitudeGainandrecuperationInkWhPerkmAltitudeLosscannot be specified. maxChargeInkWhandcurrentChargeInkWhmust always be specified as a pair (i.e., both or none).
Note that if only constantSpeedConsumption* is specified, no other consumption aspects are taken into account, i.e., slopes and vehicle acceleration are not considered for consumption computations.
Selecting the Consumption model
There are two available Consumption models: Combustion and Electric.
- A model is selected by specifying the corresponding
constantSpeedConsumption*parameter and possibly further parameters that belong to the same model. - The chosen model must match the value of the
vehicleEngineTypeparameter.
Optional parameter | Description |
|---|---|
| The engine type of the vehicle. When a detailed Consumption model is
specified, it must be consistent with the value of
|
The Combustion consumption model
The Combustion consumption model is used when the vehicleEngineType value is set to combustion. The following data table describes all of the parameters that can be specified in a request using the Combustion model.
- Required parameters must be used or the call will fail.
- Optional parameters may be used.
- The order of parameters in a request is not important.
Required parameters | Description |
|---|---|
| Specifies the speed-dependent component of consumption.
Consumption rates for speeds not in the list are found as follows:
The list must contain between 1 and 25 points (inclusive), and may not contain duplicate points for the same speed.
Consumption specified for the largest speed must be greater than or equal to that of the penultimate largest speed.
Minimum value: |
Optional parameters | Description |
|---|---|
| Weight of the vehicle in kilograms.
Minimum value: |
| Specifies the current supply of fuel in liters. |
| Specifies the amount of fuel consumed for sustaining auxiliary systems
of the vehicle, in liters per hour. It can be used to specify
consumption due to devices and systems such as AC systems, radio,
heating, etc. |
| Specifies the amount of chemical energy stored in one liter of fuel in megajoules (MJ).
Minimum value: |
| Note: This must be paired with
Minimum value: |
| Note: This must be paired with
Minimum value: |
| Note: This must be paired with
Minimum value: |
| Note: This must be paired with
Minimum value: |
The Electric Consumption model
The Electric Consumption model is used when vehicleEngineType is set to electric.
The following data table describes all parameters that can be specified in a request using the Electric model.
- Required parameters must be used or the call will fail.
- Optional parameters may be used.
- The order of parameters in a request is not important.
Required parameters | Description |
|---|---|
| Specifies the speed-dependent component of consumption.
Consumption rates for speeds not in the list are found as follows:
The list must contain between 1 and 25 points (inclusive), and may not contain duplicate points for the same speed.
Minimum value: |
| Note: This is required only if any *Efficiency parameter is set.
Minimum value: |
Optional parameters | Description |
|---|---|
| Specifies the current electric energy supply in kilowatt hours (kWh). |
| Specifies the maximum electric energy supply in kilowatt hours (kWh)
that may be stored in the vehicle’s battery. |
| Specifies the amount of power consumed for sustaining auxiliary systems,
in kilowatts (kW). It can be used to specify consumption due to devices
and systems such as AC systems, radio, heating, etc. |
| Specifies the efficiency of converting electric energy into kinetic energy
when the vehicle accelerates (i.e.,
Minimum value: |
| Specifies the efficiency of converting kinetic energy into electric energy
when the vehicle decelerates (i.e.,
Minimum value: |
| Specifies the efficiency of converting electric energy into potential
energy when the vehicle gains elevation (i.e.,
Minimum value: |
| Specifies the efficiency of converting potential energy to electric
energy when the vehicle loses elevation (i.e,
Minimum value: |
| Specifies the amount of electric energy, in kWh, consumed by the vehicle when
gaining 1000 meters of elevation.
Minimum value: |
| Specifies the amount of electric energy, in kWh, gained by the vehicle when
losing 1000 meters of elevation.
Minimum value: |
Sensible values of consumption parameters
It is possible that a particular set of consumption parameters is rejected, even though it might fulfill all the explicit requirements specified above. This will happen when the value of a specific parameter, or a combination of values of several parameters, is deemed to lead to unreasonable magnitudes of consumption values.
If that happens, it most likely indicates an input error, as proper care is taken to accommodate all sensible values of consumption parameters. In case a particular set of consumption parameters is rejected, the accompanying error message will contain a textual explanation of the reason(s).
Example
To give the feeling of the magnitudes of reasonable parameter values, the following data table provides an example of sensible values for the Combustion and Electric models.
Parameter | Sensible values by model |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
POST data parameters
Some parameters can be provided using the HTTP POST method.
- The POST data should be in JSON format, see the Content-Type header.
- All POST data parameters are optional.
- It is an error to use the HTTP POST method if no POST data parameters are provided.
There is an upper limit on the total size of the POST data.
- Exceeding this limit results in a response with the response code
413, indicating invalid POST data. - Clients must not rely on the exact value of this limit.
- The current limit is 10 MB.
The supportingPoints and encodedPolyline fields, which represent a polyline using different route geometry formats, are used to reconstruct a route.
This route is then used as a reference route for route reassessment, or to calculate zero or more alternative routes.
For more information on representing route geometry formats, see the Route geometry representation formats section.
- There are two ways to pass these polyline representations: for the entire route or per leg.
- The provided polyline is used as input for route reconstruction.
- The
pointWaypointsfield is used to represent waypoints when reconstructing a route. - The alternative routes are calculated between the origin and destination points specified in the
routePlanningLocations, passing through all intermediate locations specified in thepointWaypointsfield. - If
supportingPointIndexOfOriginis not used, and bothminDeviationDistanceandminDeviationTimeare set to zero, then these origin and destination points are expected to be at (or very near) the beginning and end of the reference route, respectively. - The reference route may contain traffic incidents of type
ROAD_CLOSURE, which are ignored for the calculation of the reference route’s travel time and traffic delay.
Using supportingPointIndexOfOrigin, or setting at least one of minDeviationDistance or minDeviationTime to a value greater than zero, has the following consequences:
- The origin point of the
calculateRouterequest must be on (or very near) the input reference route.- If this is not the case, an error is returned.
- However, the origin point does not need to be at the beginning of the input reference route (it can be thought of as the current vehicle position on the reference route).
- If used,
supportingPointIndexOfOriginmust precisely indicate the location of the origin point in relation to the given polyline.
- The reference route, returned as the first route in the
calculateRouteresponse, will start at the origin point specified in thecalculateRouterequest. The initial part of the input reference route up until the origin point will be excluded from the response. - The values of
minDeviationDistanceandminDeviationTimedetermine how far alternative routes will be guaranteed to follow the reference route from the origin point onwards. - The
vehicleHeadingis ignored.
The following table describes the parameters that can be used in the Calculate Route service.
| Parameter | Description |
|---|---|
| An array of |
| A string in the
encoded polyline format,
representing the array of points to be used as input for route reconstruction. |
| The precision used to encode the polyline in the |
pointWaypoints | An array of
|
pointWaypoint | Contains one |
waypointSourceType | Denotes the source of the waypoint. Possible values:
|
supportingPointIndex | An index of an element of the given polyline that denotes the location of the waypoint on the reference route.
|
reassessmentParameterSets | An array of
|
| An array of objects with the parameters for the computation of each leg. If the parameter is such
that it is available for use in the query parameters, then its simultaneous use in the query
parameters and in the POST data is prohibited, and such a request will be returned with an error.
For an example that uses the |
| This is an array of strings. Each string should be a 3-character, ISO 3166-1, alpha-3 country code.
Note: It is an error to specify both |
| This is an array of strings. Each string should be a 3-character, ISO 3166-1, alpha-3 country code.
Note: It is an error to specify both |
| Defines areas of certain shapes that should be avoided when planning routes. Supported
shapes include |
| This is an array of objects, with a maximum of ten elements. Each object
describes an axis-aligned rectangle, defined using the fields
|
| The south-west corner of a rectangle. It is an object consisting of a
|
| The north-east corner of a rectangle. It is an object consisting of a
|
RouteStop
Optional parameters | Description |
|---|---|
pauseTimeInSecondsinteger | Specifies the waiting time at route stops (including charging time).
It must be 0 in the last leg (the destination). |
entryPointsarray of EntryPoint objects | Specifies the entry points for the stop at the end of the current leg. The route to the stop is calculated based on these entry points.
|
preferredEntryPointIndexinteger | Specifies the index of the preferred entry point. An index of 0 denotes the first entry point. Selecting an entry point as preferred does not guarantee that it will be used as the destination.
|
EntryPoint
Parameters | Description |
|---|---|
latitudefloat | The latitude of the entry point. Required. |
longitudefloat | The longitude of the entry point. Required. |
Route avoid
The route calculation will try to avoid the specified road attribute for the leg that contains it.
| Parameters | Description |
|---|---|
namestring | Specifies the name of the road attribute for route calculation to try to avoid. Possible values are listed under Avoid parameter possible values. |
{ [...], "legs":[ { "avoids":[ { "name":"motorways" } ] } ], [...]}Avoiding roads with usage-based toll collection
There is special behavior where only roads with usage-based toll collection could be avoided.
Scenario 1:
avoid = tollRoad"allowVignette": [value]
Result: Roads with usage-based toll collection are avoided. Toll roads requiring vignettes are also avoided,
except in selected countries (marked as value above) where toll roads with vignettes are allowed.
Note: In this scenario, avoidVignette has to be None.
Scenario 2:
avoid = tollRoad"avoidVignette": [value]
Result: Roads with usage-based toll collection are avoided. Toll roads requiring vignettes are allowed, except
in selected countries (marked as value above) where toll roads with vignettes are avoided.
Note: In this scenario, allowVignette has to be None.
Vignette request content example
{ "avoidVignette": ["AUS", "CHE"], "avoidAreas": { "rectangles": [ { "southWestCorner": { "latitude": 48.81851, "longitude": 2.26593 }, "northEastCorner": { "latitude": 48.90309, "longitude": 2.41115 } } ] }}Request content example
Note: For brevity, the following example may include fields that are incompatible with one another. In practice, only a subset of these fields will be used in a valid request.
{ "supportingPoints": [ {"latitude": 52.50930, "longitude": 13.42936}, {"latitude": 52.50844, "longitude": 13.42859}, {"latitude": 52.50601, "longitude": 13.42742} ], "encodedPolyline": "ogcph^_esc_GnxOf`Nvmn@fzU", "encodedPolylinePrecision": 7, "pointWaypoints": [ { "waypointSourceType": "USER_DEFINED", "supportingPointIndex": 0 }, { "waypointSourceType": "USER_DEFINED", "supportingPointIndex": 1 } ], "avoidVignette": [ "AUS", "CHE" ], "reassessmentParameterSets": [ { "auxiliaryPowerInkW": 0.3 } ], "legs": [ { "routeType": "eco", "routeStop": { "pauseTimeInSeconds": 610, "entryPoints": [ { "latitude": 52.50601, "longitude": 13.42742 } ] } }, { }, { "routeType": "short" } ]}Response data
Response headers
The following data table describes HTTP response headers of particular interest to Calculate Route service clients.
Header | Description |
|---|---|
| Access-Control-Expose-Headers | The service whitelists response headers that browsers are allowed to
access. |
| Access-Control-Allow-Origin | The service allows cross-origin resource sharing. |
| Content-Encoding | The service supports HTTP compression, if requested by the client. |
| Content-Type | The format of the response. The service supports specifying the desired
response format. See the
|
| Cache-Control | The Cache-Control general-header field is used to specify directives
that must be obeyed by all caching mechanisms along the request/response
chain. It is supported by HTTP/1.1 clients. It may not be supported by
HTTP/1.0 clients.
|
| Pragma | The Pragma general-header field is used to specify directives that might
apply to any recipient along the request/response chain. It is supported
by HTTP/1.0 clients. |
| Tracking-ID | This is an identifier for the request. If |
| Warning | This may be sent for deprecated features. |
Response codes
The following table describes HTTP response codes of particular interest to Calculate Route service clients.
Code | Meaning & possible causes |
|---|---|
200 | OK: A route or range was calculated and the body of the response contains the data for a successful response. |
400 | Bad request:
|
403 | Permission or authentication issues:
|
404 | Not Found: The requested resource could not be found, but it may be available again in the future. |
405 | Method Not Allowed: The client used an HTTP method other than GET or POST. |
408 | Request timeout: The client took too long to transmit the request. |
414 | The request URI is too long. |
415 | Unsupported media type. |
429 | Too Many Requests: Too many requests were sent in a given amount of time for the supplied API Key. |
500 | An error occurred while processing the request. Please try again later. This can also indicate that the request reached an internal computation time threshold and timed out. |
502 | Internal network connectivity issue. |
503 | Service currently unavailable. |
504 | Internal network connectivity issue. |
596 | Service not found. |
Example of a successful response
The routes in a successful response are listed in the order of decreasing optimality. If the request includes the supportingPoints field, the response first returns the reconstructed route, followed by any alternative routes.
Note: For brevity, this example includes all fields described in this document. In practice, some fields may be incompatible with others, and only a subset of them will be present in the response, depending on the request parameters used.
A response could look like this: (Note: Comments are contained within ... ....)
Response body - JSON
{ "formatVersion": "0.0.12", "routes": [ { "summary": { "lengthInMeters": 1147, "travelTimeInSeconds": 161, "trafficDelayInSeconds": 15, "trafficLengthInMeters": 147, "departureTime": "2015-04-02T15:01:57+02:00", "arrivalTime": "2015-04-02T15:04:38+02:00", "noTrafficTravelTimeInSeconds": 120, "historicTrafficTravelTimeInSeconds": 157, "liveTrafficIncidentsTravelTimeInSeconds": 161, "batteryConsumptionInkWh": 0.155, "deviationDistance": 1735, "deviationTime": 127, "deviationPoint": { "latitude": 52.50904, "longitude": 13.42912 }, "reachableRouteOffsets": [ { "chargeMarginInkWh": 0.0, "routeOffsetInMeters": 1147, "point": { "latitude": 52.51565, "longitude": 13.43979 }, "pointIndex": 50 } ] }, "routeReassessments": [ { "batteryConsumptionInkWh": 0.2, "reachableRouteOffsets": [ { "chargeMarginInkWh": 0.0, "routeOffsetInMeters": 1147, "point": { "latitude": 52.51565, "longitude": 13.43979 }, "pointIndex": 50 } ] } ], "legs": [ { "summary": { "lengthInMeters": 108, "travelTimeInSeconds": 11, "trafficDelayInSeconds": 0, "trafficLengthInMeters": 0, "departureTime": "2015-04-02T15:01:57+02:00", "arrivalTime": "2015-04-02T15:02:07+02:00", "noTrafficTravelTimeInSeconds": 10, "historicTrafficTravelTimeInSeconds": 11, "liveTrafficIncidentsTravelTimeInSeconds": 11, "batteryConsumptionInkWh": 0.1, "originalWaypointIndexAtEndOfLeg": 0, "userDefinedPauseTimeInSeconds": 1020, "entryPointIndexAtEndOfLeg": 0 }, "points": [ { "latitude": 52.50931, "longitude": 13.42937 }, { "latitude": 52.50904, "longitude": 13.42912 }, ...further points... ], "encodedPolyline": "evn_Iq|}pAt@p@", "encodedPolylinePrecision": 5 }, ...further legs... ], "progress": [ { "pointIndex": 0, "travelTimeInSeconds": 0, "distanceInMeters": 0, "batteryConsumptionInkWh": 0 }, { "pointIndex": 5, "travelTimeInSeconds": 7, "distanceInMeters": 74, "batteryConsumptionInkWh": 0.002 }, ...further progresses... { "pointIndex": 87, "travelTimeInSeconds": 161, "distanceInMeters": 1147, "batteryConsumptionInkWh": 0.155 } ], "sections": [ { "startPointIndex": 0, "endPointIndex": 3, "sectionType": "TRAVEL_MODE" "travelMode": "other" }, { "startPointIndex": 3, "endPointIndex": 7, "sectionType": "TRAVEL_MODE" "travelMode": "car" }, { "startPointIndex": 2, "endPointIndex": 3, "sectionType": "TOLL", "tollPaymentTypes": [ "CREDIT_CARD", "DEBIT_CARD" ] }, { "startPointIndex": 4, "endPointIndex": 5, "sectionType": "TOLL", "tollPaymentTypes": [ "ETC_TRANSPONDER" ] }, { "startPointIndex": 2, "endPointIndex": 5, "sectionType": "TOLL_ROAD" }, { "startPointIndex": 3, "endPointIndex": 4, "sectionType": "TUNNEL" }, { "startPointIndex": 0, "endPointIndex": 1, "sectionType": "PEDESTRIAN" }, { "startPointIndex": 3, "endPointIndex": 4, "sectionType": "TRAFFIC", "simpleCategory": "JAM", "effectiveSpeedInKmh": 40, "delayInSeconds": 158, "magnitudeOfDelay": 1, "tec": { "effectCode": 4, "causes": [ { "mainCauseCode": 1 }, { "mainCauseCode": 26, "subCauseCode": 2 } ] } }, { "startPointIndex": 0, "endPointIndex": 3, "sectionType": "IMPORTANT_ROAD_STRETCH", "importantRoadStretchIndex": 0, "streetName": { "text": "Sample Street" } }, { "startPointIndex": 5, "endPointIndex": 6, "sectionType": "IMPORTANT_ROAD_STRETCH", "importantRoadStretchIndex": 0, "streetName": { "text": "Sample Street" } }, { "startPointIndex": 6, "endPointIndex": 7, "sectionType": "IMPORTANT_ROAD_STRETCH", "importantRoadStretchIndex": 2, "streetName": { "text": "Another Street" }, "roadNumbers": [ { "text": "A10" }, { "text": "E10" } ] }, { "startPointIndex": 8, "endPointIndex": 9, "sectionType": "IMPORTANT_ROAD_STRETCH", "importantRoadStretchIndex": 1, "roadNumbers": [ { "text": "A10" } ] }, ...further sections... ] } ...further routes... ], "optimizedWaypoints": [ { "providedIndex": 0, "optimizedIndex": 1 }, { "providedIndex": 1, "optimizedIndex": 0 } ...further optimized waypoints... ], "report": { "effectiveSettings": [ { "key": "avoid", "value": "motorways" }, { "key": "computeBestOrder", "value": "true" }, ...further settings... ] }}Example of an error response
If an error occurs, the response contains the description of the error. An example error response is shown below:
{ "formatVersion": "0.0.12", "detailedError": { "code": "<error code>", "message": "Error message" }}Special behavior for content type JSONP
When contentType=jsonp is used, the returned HTTP status code is always OK (200). Reference: JSONP - JSON with Padding
- This ensures that the
jsonpcallback is always invoked on the client side, regardless of the request outcome. - In order to provide the client with the actual status of the request, the response body includes a
statusCodefield.
Currently, the preceding statement is not true for certain types of errors described below.
Special behavior of certain types of errors - authentication errors, request quota related errors, etc.
- For those errors, the HTTP status code (
400,500, …) is returned as usual, and the response content type istext/xml, regardless of the request’s content type. - For those errors, the content does not follow the documented format for error responses.
- Note: This limitation should not cause issues during normal use of the API.
Structure of a successful response
Note: Some names are implicitly defined. For example, the name leg
describing legs as an array of leg objects.
| JSON field | Description |
|---|---|
| The format version. |
| The request may return more than one route. |
| The summary of a route, or of a route leg. |
|
|
| A description of a part of a route, comprised of an array of points.
|
| Each object in the array is a location on the surface of the globe
defined by its |
| A string in the
encoded polyline format,
representing the array of points describing a part of a route. |
| The precision used to encode the polyline in the |
| This array is available inside
|
| Index of the first point (offset |
| Index of the last point (offset |
| A 3-character ISO 3166-1 alpha-3 country code. |
| Type of the incident.
|
| The effective speed of the incident in km/h, averaged over its entire length. |
| The delay in seconds caused by the incident. |
| The magnitude of delay caused by the incident.
These values correspond to the values of the response field
|
| Details of the traffic event. It uses the definitions in the
TPEG2-TEC
standard. It can contain the |
| The effect on the traffic flow. Contains a value in the
|
| Each object in the array describes one cause of the traffic event.
|
| The main cause of the traffic event. Contains a value in the
|
| The sub-cause of the traffic event. Contains a value in the sub cause
table defined by the |
| A unique ID of the traffic incident. |
| The route or leg length in meters. |
| The estimated travel time in seconds. Note that even when
|
| The delay in seconds compared to free-flow conditions according to real-time traffic information. |
| The portion of the route or leg, expressed in meters, that is affected by traffic events which cause the delay. |
| The estimated travel time in seconds calculated as if there are no
delays on the route due to traffic conditions (e.g., congestion).
Included if requested using the |
| The estimated travel time in seconds calculated using time-dependent
historic traffic data. Included if requested using the
|
| The estimated travel time in seconds calculated using real-time speed
data. Included if requested using the |
| The distance (in meters) from the origin point of the
|
| The travel time (in seconds) from the origin point of the
|
| The coordinates of the first point following the origin point of the
|
| The estimated fuel consumption in liters using the Combustion Consumption Model. Included if:
|
| The estimated electric energy consumption in kilowatt hours (kWh) using the Electric Consumption Model.
|
| This field is included if
|
| A description of an optimized sequence of waypoints. It shows the index from the user-provided waypoint sequence for the original and optimized list. For instance, a response: means that:
Since the index starts by |
| The estimated departure time for the route or leg. Specified as a
|
| The estimated arrival time for the route or leg. Specified as a
|
| Each object in the array represents an effective parameter or a data
used when calling the Calculate Route API. Each object has fields
|
| The original HTTP status code as listed in the response codes (note:
included for content type |
| The reason for a better route proposal. Can currently be:
This field is included in the response only if the route is requested
with |
| This field is included if
A
|
| The index of the waypoint at the end of the leg that corresponds to:
This field is not provided if the end of the leg corresponds to the destination or to a new charging waypoint that is not present in the request. |
| Contains the value of |
| Identifies the entry point that was used for the route at the end of the leg. |
| The base URL of the Road Shields service to fetch the road shield atlas
and metadata resources.
We recommend to cache the sprite atlas ( |
| The integer value of importance. The index starts from 0, and a lower value means higher importance. The index is needed for two reasons:
|
| An object contains a |
| An array of objects of type |
Structure of the section object
Each section object provides additional information about a specific part of the route and includes, at a minimum, the startPointIndex, endPointIndex, and sectionType fields.
| JSON field | Description | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Contains the response section type.
| ||||||||||||||||||||||||||||||||||||||
| This field is either set to the value given to the request parameter
| ||||||||||||||||||||||||||||||||||||||
| The Possible toll payment types are:
|
Structure of an error response
| JSON field | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| This object provides a representation of the error message. It contains
a
| ||||||||||||||||||||
| The original HTTP status code as listed in response codes (included for
content type |
Structure of a road shield reference object
JSON field | Description | ||||||
|---|---|---|---|---|---|---|---|
| This object describes a single road shield reference. It contains the following fields:
|
Route geometry representation formats
Certain request and response fields that describe route geometry using a polyline support two alternative representation formats:
- An array of points defined as raw decimal coordinates, such as the
supportingPointsfield in requests and thepointsfield in responses. - An encoded polyline string, such as the
encodedPolylinefield in both requests and responses.
Where documented, either of the two representations can be used. This is purely a representational choice and is independent of any other statements about route geometry. The field containing the array of points is used as a stand-in for the concern of route geometry. For brevity, any references and constraints related to the polyline are stated using the stand-in only.
Using encoded polylines can significantly reduce the data size of requests and responses.
Encoded polyline format
For efficient representation of polylines as encoded polyline strings, this service uses an extended version of the
Encoded Polyline Algorithm Format.
The original algorithm limits coordinate precision to 5 decimal places by using a multiplier of 1e5 for the decimal values.
The extension allows using multipliers of both 1e5 and 1e7.
These multipliers correspond to precisions of 5 and 7 decimal places.
Please note that each field in the encoded polyline format may have limitations on its supported precisions.
Since the encoded polyline string doesn’t contain information of the precision or multiplier used, this information must be provided separately alongside each encoded polyline string.
We recommend taking special care when using the higher precision, as some encoding implementations may suffer internal overflows with the higher multiplier.
Encoding
When encoding a polyline, select a supported precision and use the respective multiplier for the decimal value instead of the fixed 1e5 multiplier in the original algorithm (refer to the following table).
Otherwise, the encoding process remains the same as in the original algorithm.
Ensure to send the precision used alongside each encoded polyline string in the request.
Decoding
When decoding a received polyline, use the provided precision next to the encoded polyline string to determine the appropriate multiplier for the decimal value instead of the fixed 1e5 multiplier in the original algorithm (refer to the following table).
Otherwise, the decoding process remains the same as in the original algorithm.
Note that each encoded polyline string is accompanied by the precision used for its encoding.
Precisions and multipliers
The following table illustrates the relationship between precision and multiplier:
Precision | Multiplier |
|---|---|
5 | 1e5 |
7 | 1e7 |