Get tolls for multi-section route
This is a request for tolls for a multi-section route including a paid highway with a stopover in a rest area, disregarding departure time. The driver pays the toll in the second section, after the stopover, at the highway exit booth:
curl -X GET \
'https://router.hereapi.com/v8/routes?origin=41.465218,1.912036&destination=41.447398,1.865010&via=41.455196,1.882819&return=tolls&transportMode=car&departureTime=any&apikey={YOUR_API_KEY}'
{
"routes": [
{
"id": "bc63ecb7-dd44-4c76-a9e4-baec8629a5d1",
"sections": [
{
"id": "319cad34-5e89-4723-90fe-5b0e50c45f43",
"type": "vehicle",
"departure": {
"place": {
"type": "place",
"location": {
"lat": 41.4651747,
"lng": 1.9120686
},
"originalLocation": {
"lat": 41.465218,
"lng": 1.912036
}
}
},
"arrival": {
"place": {
"type": "place",
"location": {
"lat": 41.4551983,
"lng": 1.8828158
},
"originalLocation": {
"lat": 41.4551959,
"lng": 1.8828189
},
"waypoint": 0
}
},
"transport": {
"mode": "car"
}
},
{
"id": "0ff92e1b-3bda-4dae-bc5c-7af672f22fbb",
"type": "vehicle",
"departure": {
"place": {
"type": "place",
"location": {
"lat": 41.4551983,
"lng": 1.8828158
},
"originalLocation": {
"lat": 41.4551959,
"lng": 1.8828189
},
"waypoint": 0
}
},
"arrival": {
"place": {
"type": "place",
"location": {
"lat": 41.4473975,
"lng": 1.8650177
},
"originalLocation": {
"lat": 41.447398,
"lng": 1.8650099
}
}
},
"transport": {
"mode": "car"
},
"tolls": [
{
"countryCode": "ESP",
"tollSystem": "AUTOPISTAS AP2-AP7",
"fares": [
{
"id": "48a15121-4d1d-4218-b5e1-7ba8d5ffb289",
"name": "AUTOPISTAS AP2-AP7",
"price": {
"type": "value",
"currency": "EUR",
"value": 2.5
},
"reason": "toll",
"paymentMethods": [
"cash",
"bankCard",
"creditCard",
"transponder",
"travelCard"
]
}
]
}
]
}
]
}
]
}
Get tolls for multi-section routes when payment is valid for more than one section
Some tolls don't have defined points of payment. For example, in a truck carrying a toll-transponder, the device accumulates toll data as the truck continues on the route. In this case, the total toll is calculated by the transponder, but there is no single point-of-payment to which the toll can be assigned. As a result, the router will return this toll for every section of the trip to which it applies. This means that the same toll will appear on multiple sections, even though it will only be paid once. For this reason, it is important that clients pay attention to the id
field of the objects in the fares
array. The id
could be repeated across sections, and in case it is repeated, it should not be used more than once to count the total fare on the client side.
Consider the following example:
curl -X GET \
'https://router.hereapi.com/v8/routes?origin=51.672015,12.200617&destination=52.018234,12.560561&via=51.848882,12.330821&return=tolls&transportMode=truck&departureTime=any&apikey={YOUR_API_KEY}'
{
"routes":
[
{
"id": "c2a14795-5cad-415d-af2b-0c1d79b8e3ce",
"sections":
[
{
"id": "7a0a73ba-af30-42fb-ba19-77c67a24df91",
"type": "vehicle",
"departure":
{
"time": "2022-08-08T11:43:00+02:00",
"place":
{
"type": "place",
"location":
{
"lat": 51.6706573,
"lng": 12.1980494
},
"originalLocation":
{
"lat": 51.672015,
"lng": 12.200617
}
}
},
"arrival":
{
"time": "2022-08-08T12:11:15+02:00",
"place":
{
"type": "place",
"location":
{
"lat": 51.8489,
"lng": 12.33076
},
"originalLocation":
{
"lat": 51.848882,
"lng": 12.3308209
},
"waypoint": 0
}
},
"transport":
{
"mode": "truck"
},
"tolls":
[
{
"countryCode": "DEU",
"tollSystemRef": 0,
"tollSystem": "TOLL COLLECT GMBH",
"fares":
[
{
"id": "7577b304-6644-44f9-a31f-48d3d848481f",
"name": "TOLL COLLECT GMBH",
"price":
{
"type": "value",
"currency": "EUR",
"value": 4.24
},
"reason": "toll",
"paymentMethods":
[
"cash",
"bankCard",
"creditCard",
"transponder",
"travelCard"
]
}
]
}
],
"tollSystems":
[
{
"id": 5200,
"name": "TOLL COLLECT GMBH",
"languageCode": "ENG"
}
]
},
{
"id": "8f7a5792-7676-4e87-8113-aeb0f3497acc",
"type": "vehicle",
"departure":
{
"time": "2022-08-08T12:11:15+02:00",
"place":
{
"type": "place",
"location":
{
"lat": 51.8489,
"lng": 12.33076
},
"originalLocation":
{
"lat": 51.848882,
"lng": 12.3308209
},
"waypoint": 0
}
},
"arrival":
{
"time": "2022-08-08T12:31:17+02:00",
"place":
{
"type": "place",
"location":
{
"lat": 52.0189731,
"lng": 12.5608645
},
"originalLocation":
{
"lat": 52.018234,
"lng": 12.5605609
}
}
},
"transport":
{
"mode": "truck"
},
"tolls":
[
{
"countryCode": "DEU",
"tollSystemRef": 0,
"tollSystem": "TOLL COLLECT GMBH",
"fares":
[
{
"id": "7577b304-6644-44f9-a31f-48d3d848481f",
"name": "TOLL COLLECT GMBH",
"price":
{
"type": "value",
"currency": "EUR",
"value": 4.24
},
"reason": "toll",
"paymentMethods":
[
"cash",
"bankCard",
"creditCard",
"transponder",
"travelCard"
]
}
]
}
],
"tollSystems":
[
{
"id": 5200,
"name": "TOLL COLLECT GMBH",
"languageCode": "ENG"
}
]
}
]
}
]
}
Note that both fares, one in each section, share the same fare id
= 7577b304-6644-44f9-a31f-48d3d848481f
. This means that the same fare applies to both sections, and therefore needs to be paid only once. Note also that fare id
s are only valid per response. The same fare on a future request may have a completely different id
, and they are not intended to be reused across requests.