# Calculate a route with charging along the way

For longer journeys with electric vehicles, it is important to plan for charging stops along the way. After all, charging stations are much less common than petrol stations. The Routing API is capable of planning such a route. The Routing service tries to find the fastest route, which means one with the lowest overall time consumed to reach the destination, while ensuring that the vehicle does not run out of energy along the way.

This is not realized by enhancing a normal car route with stations along the way. The result of the calculation is a route optimized for electric vehicles.

This behavior can be enabled by adding ev[makeReachable]=true to the request. Additional parameters related to the charging preferences and attributes of the vehicle are necessary.

The following route is only reachable after adding one charging station on the way. The result contains 2 sections.

The first section includes a postAction, which describes the charging stop. It contains the information on the expected arrival charge, recommended target charge and speed of charging. The consumption in the summary of the first section is negative, as the the resulting charge is higher than at the start because of charging.

curl -X GET \
https://router.hereapi.com/v8/routes?departureTime=any&origin=52.533959,13.404780&ev[connectorTypes]=iec62196Type2Combo&transportMode=car&destination=51.741505,14.352413&return=summary&ev[freeFlowSpeedTable]=0,0.239,27,0.239,45,0.259,60,0.196,75,0.207,90,0.238,100,0.26,110,0.296,120,0.337,130,0.351,250,0.351&ev[trafficSpeedTable]=0,0.349,27,0.319,45,0.329,60,0.266,75,0.287,90,0.318,100,0.33,110,0.335,120,0.35,130,0.36,250,0.36&ev[auxiliaryConsumption]=1.8&ev[ascent]=9&ev[descent]=4.3&ev[makeReachable]=true&ev[initialCharge]=48&ev[maxCharge]=80&ev[chargingCurve]=0,239,32,199,56,167,60,130,64,111,68,83,72,55,76,33,78,17,80,1&ev[maxChargeAfterChargingStation]=72&apikey={YOUR_API_KEY}


The departure block in the response now contains the start charge for that section and the arrival block contains the charge at the end of the section.

{
"routes": [
{
"sections": [
{
"id": "f62775e5-829f-4444-bc04-27b36674eea4",
"type": "vehicle",
"postActions": [
{
"action": "charging",
"duration": 541,
"consumablePower": 100,
"arrivalCharge": 40.9789,
"targetCharge": 56
}
],
"departure": {
"place": {
"type": "place",
"location": {
"lat": 52.5338756,
"lng": 13.4050139,
"elv": 91
},
"originalLocation": {
"lat": 52.5339589,
"lng": 13.4047799
}
},
"charge": 48
},
"arrival": {
"place": {
"type": "chargingStation",
"location": {
"lat": 52.4278437,
"lng": 13.5197486,
"elv": 75
},
"id": "5103"
},
"charge": 40.9789
},
"summary": {
"duration": 2315,
"length": 17982,
"consumption": -8,
"baseDuration": 2315
},
"transport": {
"mode": "car"
}
},
{
"id": "bd40cfd7-2ee5-447c-8e73-625764176f9b",
"type": "vehicle",
"departure": {
"place": {
"type": "chargingStation",
"location": {
"lat": 52.4278437,
"lng": 13.5197486,
"elv": 75
},
"id": "5103"
},
"charge": 56
},
"arrival": {
"place": {
"type": "place",
"location": {
"lat": 51.7412356,
"lng": 14.3525337,
"elv": 115
},
"originalLocation": {
"lat": 51.741505,
"lng": 14.3524129
}
},
"charge": 12.1218
},
"summary": {
"duration": 4379,
"length": 114451,
"consumption": 43.8782,
"baseDuration": 4379
},
"transport": {
"mode": "car"
}
}
]
}
]
}