Calculates great-circle distance between two GPS coordinates using the Haversine formula. Access via GET /v1/geo/haversine with lat/lng pairs, returns precise distances in kilometers or miles. Essential for location-based apps, delivery routing, and proximity searches. MCP integration lets Cursor and other AI tools perform accurate geographic calculations without approximation errors.
curl "https://tinyfn.io/v1/geo/haversine" \
-H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/geo/haversine', {
headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests
response = requests.get('https://tinyfn.io/v1/geo/haversine',
headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)
Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's geolocation tools:
{
"mcpServers": {
"tinyfn-geo": {
"url": "https://tinyfn.io/mcp/geo",
"headers": {
"X-API-Key": "YOUR_API_KEY"
}
}
}
}
Haversine calculates distance along Earth's curved surface (great-circle), while straight-line goes through the planet. For GPS coordinates, Haversine gives real-world travel distance.
GET /v1/geo/haversine?lat1=40.7128&lng1=-74.0060&lat2=51.5074&lng2=-0.1278 returns approximately 5585 kilometers between the coordinates.
Yes, AI agents in Cursor or Windsurf can call this tool to build proximity searches, delivery radius calculations, or geographic filters with precise distance measurements.
Haversine assumes perfect sphere, with ~0.5% error on Earth. For most applications under 1000km, it's sufficiently accurate for GPS-based calculations.
Default output is kilometers. Most implementations allow unit parameter (km/miles) - check the specific endpoint documentation for unit conversion options.
Get your free API key and start using Haversine Distance in seconds.
Get Free API Key