Get toll cost with route import service
The route import (v8/import) service doesn't support returning toll fares directly. You can get this information using two API calls. First, send a v8/import request to get the route handle. Next, call the v8/routes endpoint to get to toll cost information.
Note
Requesting toll cost information for routes counts as an additional transaction.
Get the route handle
Send the following request to the /import endpoint to calculate a route from a sequence of trace points and get a route handle for the route. To get the route handle, you must include the return=routeHandle parameter in the request.
curl -gX POST 'https://router.hereapi.com/v8/import?'\
'return=routeHandle&'\
'transportMode=car&'\
'apiKey=YOUR_API_KEY' \
-H 'Content-Type: application/json' -d '
{
"trace": [
{
"lat": 47.385112,
"lng": 14.921353
},
{
"lat": 47.386529,
"lng": 14.916923
},
{
"lat": 47.387452,
"lng": 14.910906
}
]
}
'Response
The API returns the following response with the route handle stored in the routeHandle field. Note, that the example response is truncated.
{
"routes": [
{
"id": "1fda55c6-3bcf-4bc8-94f6-0965a653691d",
"sections": [
{
"id": "bb2265af-758b-435d-8dec-7fef0c1e71f2",
"type": "vehicle",
...,
"transport": {
"mode": "car"
}
}
],
"routeHandle": "AGcA_v___wUAAQCWAAAAeNpjmMbAwMTAwMCekVqUapWcq6qTzgnkMqwUSDbn4lkZMadLyHBTIoxeAaQFgTQDFoBuwvf8eDEmns6iWV3X521KhNFdUJoBB1DY63GEEUgzAgCDECUtY66_Xg"
}
]
}Get toll cost for route handle
Send the following request to the /routes endpoint to get the toll cost information for the route with the given route handle. Include the return=tolls to get toll cost information in the response.
Note
Route handles can be invalidated at any time. The route handle used in these examples is for demonstration only. To try this request, create your own route handle.
curl -gX GET 'https://router.hereapi.com/v8/routes/AGcA_v___wUAAQCWAAAAeNpjmMbAwMTAwMCekVqUapWcq6qTzgnkMqwUSDbn4lkZMadLyHBTIoxeAaQFgTQDFoBuwvf8eDEmns6iWV3X521KhNFdUJoBB1DY63GEEUgzAgCDECUtY66_Xg?'\
'return=tolls&'\
'transportMode=car&'\
'apiKey=YOUR_API_KEY'Response
The API returns route details with toll cost information in the tolls array. Note, that the example response is truncated.
{
"routes": [
{
"id": "2ab023cd-938a-49fc-8716-fe93c63973a0",
"sections": [
{
"id": "b678110e-1c95-4882-a340-d69138487d66",
"type": "vehicle",
...,
"transport": {
"mode": "car"
},
"tolls": [
{
"countryCode": "AUT",
"tollSystemRef": 0,
"tollSystem": "VIGNETTE AUSTRIA",
"fares": [
{
"id": "f37b1c4f-cbde-4ef7-9067-e4da106fd0a4",
"name": "VIGNETTE AUSTRIA",
"price": {
"type": "value",
"currency": "EUR",
"value": 8.6
},
"reason": "toll",
"paymentMethods": [
"passSubscription"
],
"pass": {
"returnJourney": false,
"validityPeriod": {
"period": "days",
"count": 1
}
}
},
{
"id": "bef6419c-a0e4-422d-904a-3efd3ea0eb4d",
"name": "VIGNETTE AUSTRIA",
"price": {
"type": "value",
"currency": "EUR",
"value": 11.5
},
"reason": "toll",
"paymentMethods": [
"passSubscription"
],
"pass": {
"returnJourney": false,
"validityPeriod": {
"period": "days",
"count": 10
}
}
},
{
"id": "c6fd7fc3-e17a-4561-ba53-b0d38b3b6e68",
"name": "VIGNETTE AUSTRIA",
"price": {
"type": "value",
"currency": "EUR",
"value": 28.9
},
"reason": "toll",
"paymentMethods": [
"passSubscription"
],
"pass": {
"returnJourney": false,
"validityPeriod": {
"period": "months",
"count": 2
}
}
},
{
"id": "c04d5c2e-36d4-474f-9d89-d2a2633c77b4",
"name": "VIGNETTE AUSTRIA",
"price": {
"type": "value",
"currency": "EUR",
"value": 96.4
},
"reason": "toll",
"paymentMethods": [
"passSubscription"
],
"pass": {
"returnJourney": false,
"validityPeriod": {
"period": "extendedAnnual"
}
}
}
]
}
],
"tollSystems": [
{
"name": "VIGNETTE AUSTRIA"
}
]
}
]
}
]
}Updated last month