A lightweight Node.js package to calculate the distance and travel duration between two real-world places using the free OpenRouteService API.
✅ Supports travel by car, bike, walking, hiking, and even wheelchair routes!
- 🌐 Calculates distance between two places by name
- ⏱️ Returns estimated travel duration in minutes
- 📦 Supports multiple travel modes
- 💬 Returns detailed output in JSON format
- 🆓 Uses free API from OpenRouteService
npm install distance-calculator-openrouteservice
// test.js
import getDistance from 'distance-calculator-openrouteservice';
const run = async () => {
const result = await getDistance("New Delhi", "Mumbai", "driving-car");
console.log(result);
};
run();
##Sample output
{
"distance_km": 1400.32,
"duration_minutes": 1077,
"mode": "driving-car",
"from": "New Delhi",
"to": "Mumbai"
}
✅ Available Travel Modes
Mode Description
driving-car 🚗 Car on normal roads (default)
driving-hgv 🚚 Heavy goods vehicle (truck, lorry)
cycling-regular 🚲 Regular cycling
cycling-road 🚴 Road cycling
cycling-mountain 🚵 Mountain biking
cycling-electric ⚡ E-bike cycling
foot-walking 🚶 Walking
foot-hiking 🥾 Hiking/trail walking
wheelchair ♿ Wheelchair-optimized route