This repository provides examples of how to interact with the TollGuru API. The TollGuru API offers a comprehensive suite of tools for calculating toll costs for various routes and vehicles, providing accurate and efficient toll pricing information. This guide will help you understand how to use the provided examples to integrate toll calculations into your applications.
The TollGuru API allows developers to calculate toll costs for different routes based on vehicle parameters and toll policies. This API is useful for various applications, including fleet management, trip planning, and logistics. With support for different vehicle types and configurations, the API provides flexible and accurate toll calculation.
Key features include:
- Route Calculation: Determine toll costs for specified routes.
- Vehicle Parameterization: Customize calculations based on vehicle type, fuel cost, tag cost, and more.
- Multi-Route Support: Compare toll costs for multiple routes to find the most cost-effective path.
For a comprehensive overview of the TollGuru API, please visit the TollGuru API Documentation.
To use the examples in this repository, clone the repo to your local machine and install the necessary dependencies.
git clone https://github.com/mapup/tollguru-api-parameter-examples.git
cd tollguru-api-parameter-examples
npm install
The repository includes several example scripts that demonstrate how to interact with the TollGuru API. Each example showcases different functionalities of the API.
const axios = require('axios');
const calculateToll = async () => {
const response = await axios.post('https://api.tollguru.com/v1/calc/route', {
source: {
lat: 37.7749,
lng: -122.4194
},
destination: {
lat: 34.0522,
lng: -118.2437
},
vehicleType: "2AxlesAuto",
departure_time: "2023-08-01T12:00:00Z"
}, {
headers: {
'Content-Type': 'application/json',
'x-api-key': 'YOUR_API_KEY'
}
});
console.log(response.data);
};
calculateToll();
Replace 'YOUR_API_KEY'
with your actual API key. This example demonstrates how to calculate toll costs for a route between San Francisco and Los Angeles for a 2-axle automobile.
const axios = require('axios');
const getVehicleParameters = async () => {
const response = await axios.get('https://api.tollguru.com/v1/vehicle-types', {
headers: {
'Content-Type': 'application/json',
'x-api-key': 'YOUR_API_KEY'
}
});
console.log(response.data);
};
getVehicleParameters();
const axios = require('axios');
const calculatePreferredRoute = async () => {
const response = await axios.post('https://api.tollguru.com/v1/calc/route', {
source: {
lat: 40.7128,
lng: -74.0060
},
destination: {
lat: 34.0522,
lng: -118.2437
},
vehicleType: "2AxlesAuto",
departure_time: "2023-08-01T12:00:00Z",
preferred_routes: ["fastest", "shortest"]
}, {
headers: {
'Content-Type': 'application/json',
'x-api-key': 'YOUR_API_KEY'
}
});
console.log(response.data);
};
calculatePreferredRoute();
We welcome contributions to this repository! If you have suggestions or improvements, please open an issue or submit a pull request.
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Make your changes.
- Commit your changes (
git commit -m 'Add new feature'
). - Push to the branch (
git push origin feature-branch
). - Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for more details.
For any questions or support, please reach out to [email protected].
For a comprehensive overview and additional details, refer to the following sections of the TollGuru API Documentation: