Skip to main content
Guide

Route with stops

When calculating an EV route with the Chargetrip Route API, you can add intermediate stops between the origin and destination using via.

Stops allow you to customize routing for real-world travel scenarios, such as charging at a preferred charge station, picking up passengers or stopping at a restaurant.

Types of stops

Chargetrip supports two types of intermediate stops:

StopChargingInput fieldPurpose
LocationNovia.geometryGeographic stop (pick-up, delivery, scenic detour, coffee break).
StationYesvia.properties.station.station_idExplicitly selected charging station.

Stop duration

You can configure the duration of every stop. Depending on the type of stop (charging or non-charging), the stop_duration is configured in different locations and has different behaviors:

1. In non-charging stops

The stop duration is configured at input.via.properties.location.stop_duration. This duration represents the exact stop duration and is added directly to the total trip duration without affecting the vehicle charging or driving time.

2. In charging stops

The stop duration is configured at input.via.properties.station.stop_duration. This value represents the minimum stop duration. The vehicle remains at the station for at least this long, but the route planner may extend the stop depending on the configured charge_mode:

  • ALWAYS_TO_MAX_CHARGE: Extends charging time if needed to reach the maximum configured SoC. If the requested stop_duration exceeds the time required to reach the maximum SoC, the remaining time is logged as idle stopover.

  • OPTIMIZE_TRAVEL_TIME: Extends the stay beyond stop_duration only if doing so reduces overall trip time (for example, by eliminating a subsequent charging stop). Otherwise, charges for the exact requested duration. If the requested stop_duration exceeds the time required to reach the optimal SoC, the remaining time is logged as idle stopover.

If no value is provided, the planner optimizes charging duration purely based on the route’s charge_mode.

Add a station to an existing route

A common scenario is a user picking a charging station for a route that already has stops, for example an alternative station that is shown in your UI. The no-code solution uses this approach to add a station as a via stop automatically, without any re-ordering logic, so the route updates seamlessly.

The order of the via array is the order in which the stops are visited. A station that is appended at the end is visited last, even if it is located near the start of the route. To insert it at the right position, compare the location of the station with the waypoints that are already on the route:

  1. Collect the waypoints in order.

    Take the origin, every existing via stop and the destination from the request_input of the route you want to change. Every waypoint on the request_input has its geometry available, including stops that were created with only a station_id.

  2. Draw a line through the waypoints.

    Connect the waypoints in order to form a line. Each part of this line between two waypoints is a segment.

  3. Find the segment closest to the station.

    Use a geospatial library to find the point on the line that is nearest to the coordinates of the station. For example, turf.js offers nearestPointOnLine, which also returns the index of the segment that contains this point. That index is the index of the waypoint the segment starts at.

  4. Insert the station after that waypoint.

    The waypoint list starts with the origin, so the index of a waypoint in this list matches the position where a new item is inserted into via to end up right after it. An index of 0 means the station is inserted as the first stop.

  5. Never insert after the destination.

    When the nearest point is on the last segment, the index can point at the destination. Inserting there would place the station after the end of the route, so use the previous waypoint instead. This way the station is inserted as the last stop before the destination.

Things to keep in mind

  • The line connects the waypoints with straight segments and does not follow the roads of the route. Alternative stations are always within a corridor of 5 to 10 km around the route, so they never deviate much from it and the closest segment is mostly accurate. For stations outside this corridor, other solutions might be more suitable.
  • The request_input of the route is the source of truth. Build the new request from it and keep all other fields, such as the vehicle and the charging settings, unchanged.

Examples

Calculate a route with a 30-minute non-charging stop. On this stop, a stop_duration of 1800 seconds (30 minutes) has been added. This will be the exact stop duration.

Example request
graphql
mutation CreateRouteWithWaypoint {  createRoute(    input: {      vehicle: {        id: "60b8d5a2f1c8e9001b9e2831"        charging: { mode: OPTIMIZE_TRAVEL_TIME }      }      origin: {        type: Point        coordinates: [4.9041, 52.3676]      }      destination: {        type: Point        coordinates: [6.9583, 50.9375]      }      via: [        {          geometry: {            type: Point            coordinates: [5.1214, 52.0907] # Utrecht          }          properties: {            location: {              name: "Utrecht Central"              stop_duration: 1800 # 30 minutes in seconds            }          }        }      ]    }  ) {    id    status  }}

Calculate a route with a charging stop of at least 30 minutes. On this stop, a stop_duration of 1800 seconds (30 minutes) has been added. This will be the minimum stop duration. Because the vehicle.charging.mode:OPTIMIZE_TRAVEL_TIME, if charging longer benefits the travel time, the duration will automaticly be increased.

Example request
graphql
mutation CreateRouteWithChargingVia {  createRoute(    input: {      vehicle: {        id: "60b8d5a2f1c8e9001b9e2831"        charging: { mode: OPTIMIZE_TRAVEL_TIME }      }      origin: {        type: Point        coordinates: [4.9041, 52.3676]      }      destination: {        type: Point        coordinates: [6.9583, 50.9375]      }      via: [        {          properties: {            station: {              station_id: "5e849ea2837bc43df65d19a2"              stop_duration: 1800            }          }        }      ]    }  ) {    id    status  }}

Calculate a route with a charging stop without a minimum stop duration. On this stop, stop_duration is omitted. The planner calculates optimal charging time exclusively based on the choosen charging mode (OPTIMIZE_TRAVEL_TIME).

Example request
graphql
mutation CreateRouteWithChargingVia {  createRoute(    input: {      vehicle: {        id: "60b8d5a2f1c8e9001b9e2831"        charging: { mode: OPTIMIZE_TRAVEL_TIME }      }      origin: {        type: Point        coordinates: [4.9041, 52.3676]      }      destination: {        type: Point        coordinates: [6.9583, 50.9375]      }      via: [        {          properties: {            station: {              station_id: "5e849ea2837bc43df65d19a2"            }          }        }      ]    }  ) {    id    status  }}

Was this content helpful?

Developers

Chargetrip ©

Manage cookies

Effective: 20th March, 2024 · Updated: 1 September, 2026

We use cookies to help improve your experience of developers.chargetrip.com. This cookie policy is part of the privacy policy, and covers the use of cookies between your device and our site. We also provide basic information on third-party services we may use, who may also use cookies as part of their service, though they are not covered by our policy.

If you don’t wish to accept any cookies from us, you should instruct your browser to refuse cookies from developers.chargetrip.com, with the understanding that we may be unable to provide you with some of your desired content and services.

A cookie is a small piece of data that a website stores on your device when you visit, typically containing information about the website itself, a unique identifier that allows the site to recognize your web browser when you return, additional data that serves the purpose of the cookie itself, and the lifespan of the cookie itself.

Cookies are used to enable certain features (e.g. logging in), to track site usage (e.g. analytics), to store your user settings (e.g. timezone, notification preferences), and to personalize your content (e.g. advertising, language).

Cookies set by the website you are visiting are normally referred to as “first-party cookies,” and typically only track your activity on that particular site. Cookies set by other sites and companies (i.e. third parties) can be used to track you on other websites that use the same third-party service.

Essential cookies

Cookies set by the website you are visiting are normally referred to as “first-party cookies,” and typically only track your activity on that particular site. Cookies set by other sites and companies (i.e. third parties) can be used to track you on other websites that use the same third-party service.

Performance cookies

Targeting / advertising cookies are used in determining what promotional content is more relevant and appropriate to you and your interests. Websites may use them to deliver targeted advertising or to limit the number of times you see an advertisement. This helps companies improve the effectiveness of their campaigns and the quality of content presented to you. These cookies may be set by the website you’re visiting (first-party) or by third-party services. Targeting/advertising cookies set by third parties may be used to track you on other websites that use the same third-party service. We use targeting/advertising cookies on our site.

Marketing / advertising cookies

Targeting / advertising cookies are used in determining what promotional content is more relevant and appropriate to you and your interests. Websites may use them to deliver targeted advertising or to limit the number of times you see an advertisement. This helps companies improve the effectiveness of their campaigns and the quality of content presented to you. These cookies may be set by the website you’re visiting (first-party) or by third-party services. Targeting/advertising cookies set by third parties may be used to track you on other websites that use the same third-party service. We use targeting/advertising cookies on our site.

Third party promise

We review the privacy policies of all our third-party providers before enlisting their services to ensure their practices align with ours. We will never knowingly include third-party services that compromise or violate the privacy of our users.

Cookie
google-cookie-consent
Description
Stores your cookie preferences, meaning which categories you have accepted or declined, so we can respect your choice on every visit and only load the analytics or marketing tools you have allowed.
Lifetime
2 years

How you can control or opt out of cookies

If you do not wish to accept cookies from us, you can instruct your browser to refuse cookies from our website. Most browsers are configured to accept cookies by default, but you can update these settings to either refuse cookies altogether or to notify you when a website is trying to set a cookie.

If you browse websites from multiple devices, you may need to update your settings on each individual device.

Although some cookies can be blocked with little impact on the experience of a website, blocking all cookies may mean you are unable to access certain features and content across the sites you visit.

We may update this Cookie Policy from time to time in order to reflect, for example, changes to the cookies we use or for other operational, legal, or regulatory reasons. Please re-visit this Cookie Policy to stay informed about our use of cookies and related technologies. The date at the top of this Cookie Policy indicates when it was last updated.