Distance Calculator API - Haversine Between Coordinates
Provide two latitude/longitude pairs and receive the distance between them calculated using the Haversine formula. Supports kilometers, miles, and nautical miles. Accurate for any two points on Earth. No external service calls; the calculation runs entirely on the server.
Code examples
curl -X POST https://api.botoi.com/v1/geo/distance \
-H "Content-Type: application/json" \
-d '{"from":{"lat":40.7128,"lng":-74.006},"to":{"lat":51.5074,"lng":-0.1278},"unit":"km"}'When to use this API
Sort nearby stores or restaurants by distance from the user
Calculate the distance from the user's coordinates to each location in your database. Sort by the result to show the closest options first. Runs server-side so you don't need a Google Maps API key.
Validate delivery radius for an e-commerce checkout
Before confirming an order, calculate the distance between your warehouse and the delivery address. Reject or apply a surcharge if the distance exceeds your delivery zone.
Build a travel distance tracker for fitness or logistics apps
Send sequential GPS waypoints and sum the distances to compute total trip length. Works for running routes, fleet tracking, or cycling apps.
Frequently asked questions
How accurate is the Haversine formula?
What coordinate system does this endpoint expect?
Can I calculate distances for more than two points?
What is the difference between km, mi, and nm?
Does this endpoint call an external mapping service?
Get your API key
Free tier includes 5 requests per minute with no credit card required. Upgrade for higher limits.