The future of mobility is digital, and the key to this future lies in harnessing the power of data. TollGuru's API serves as a powerful tool to unlock this potential, providing a wealth of information for route optimization. This blog will explore how to use TollGuru's API for finding the fastest and cheapest routes and for planning efficient routes for electric vehicles (EVs).
Discovering the Fastest and Cheapest Routes
When planning a journey, two crucial factors often come into play: time and cost. With the TollGuru API, developers can build solutions that provide users with the fastest and cheapest routes for their journeys.
Fastest Route
TollGuru's API returns a diffs object in the response body that provides insights into the fastest and cheapest routes. The diffs object contains data in the format {"cheapest":"x.xx","fastest":y}, where x.xx is the additional cost to take the fastest route, and y is the additional time in minutes to take the cheapest route.
"diffs": {
"cheapest": 0,
"fastest": 2
}
In this example, the value of "fastest" is 0, indicating that this route is the fastest. If the value was 2, it would mean the route is 2 minutes slower than the fastest route.
Cheapest Route
Similarly, if "cheapest" is 0, it indicates that the route is the cheapest. If it was 2, it would mean the route is $2 more expensive than the cheapest route.
"diffs": {
"cheapest": 1.35,
"fastest": 0
}
The API also provides cost breakdowns for various payment methods in the costs object, including fuel, tag, cash, licensePlate, creditCard, and prepaidCard. By comparing these values, developers can help users find the most cost-effective route based on their preferred payment method.
"costs": {
"tagAndCash": 0.4,
"minimumTollCost": 0.4,
"fuel": 2.3,
"tag": 0.4,
"cash": null,
"licensePlate": 0.68,
"prepaidCard": 0.4
}
EV Route Planning with TollGuru API
The rise of electric vehicles (EVs) has brought new challenges to route planning. Not only do you need to find the fastest and most cost-effective route, but you also need to locate charging points along the way. The TollGuru API provides a chargingPoints field specifically for this purpose.
Each object within the chargingPoints array contains detailed information about a specific EV charging station along the route. This includes the station's name, address, contact phone number, geographic coordinates, connector type, power feed types, pricing structure, facility type, access times, and more.
Here's an example of a chargingPoints list:
"chargingPoints": [
{
"id": 85980,
"evStation": {
"name": "Clay Cooley Nissan",
"address": "4707 Lyndon B Johnson Fwy, Farmers Branch, TX, 75244, US",
"contact": {
"phone": "972-450-2400"
},
"position": {
"point": {
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [
-96.828116,
32.926739
]
}
}
},
"brand": "Non-Networked",
"connectorType": "J1772",
"powerFeedTypes": [
{
"id": 2,
"name": "Level 2",
"totalNumberOfConnectors": 1
}
],
"pricingStructureType": {
"description": "Free"
},
"facilityType": "Car Dealer",
"accessTime": "Dealership business hours",
"otherInfo": ""
}
}
]
This data enables developers to build solutions that help EV drivers plan their routes more efficiently, ensuring they have access to charging stations when they need them.