Route

Routes is the API service for calculating a route with a vehicle. It predicts the energy required for a particular vehicle to drive from a starting point to a destination. Based on that predicted energy consumption, an optimal route, including charge stops, is created that is compatible with the vehicle being used. The calculation of the recommended route and charge stops is flexible and can be tailored to your needs by setting operator preferences.

Use case

The most common use case for Routes is to build route planning into EV driver apps, where drivers can input their start, stops, and destination and get a recommended route. Routes can also be used to build routing and dispatching for electric commercial vehicles as part of fleet management software.

Implementation

To create a route use the createRoute mutation and route subscription. We strongly recommend to use subscriptions. Recursively querying a route ID until the route is processed increases costs and delays your application. A visual representation is added below. For a more detailed explanation keep reading.

A diagram reflecting how the route mutation on the Chargetrip API works.

First, use a GraphQL client to execute the mutation. This mutation takes a CreateRouteInput object which contains all the parameters needed to create a route. It returns the id of that newly created route. Use that route id to subscribe to route updates. The status of the route (RouteStatus) will be updated from pending, to processing, and when the route calculation is finished, to the final status done. If a route is not found or something goes wrong during the calculation, the final status resolves to either not_found or error. It is recommended to unsubscribe from further updates when the route has reached a final status.