Geolocation Utilities

Calculate Midpoint

Calculates the geographic midpoint between two coordinate pairs using spherical geometry. Access via MCP in Cursor, Windsurf, or other supported editors, or call GET /v1/geo/midpoint with lat/lng parameters. Returns precise coordinates accounting for Earth's curvature — essential for accurate distance calculations in mapping applications and location-based AI agents.

API Endpoint

GET /v1/geo/midpoint

Code Examples

curl "https://tinyfn.io/v1/geo/midpoint" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/geo/midpoint', {
  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/midpoint',
    headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)

Use via MCP

Add to your AI agent

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"
      }
    }
  }
}

Learn more about MCP setup →

FAQ

How do I calculate the midpoint between two GPS coordinates?

Send GET request to /v1/geo/midpoint with lat1, lng1, lat2, lng2 parameters, or use the MCP tool with coordinate pairs. Returns the geographic center point as decimal degrees.

Does geographic midpoint calculation account for Earth's curvature?

Yes, uses spherical trigonometry rather than simple averaging. This prevents errors when calculating midpoints across large distances or near poles where flat-earth math fails.

Can AI agents use this for route planning and location analysis?

Absolutely. MCP integration lets agents calculate meeting points, analyze geographic clusters, or find optimal locations between multiple coordinates in real-time without hallucinating coordinates.

What coordinate formats does the midpoint calculator accept?

Accepts decimal degrees (e.g., 40.7128, -74.0060). Input coordinates as separate latitude and longitude parameters for each point.

How accurate is the geographic midpoint calculation?

Uses standard geodetic formulas with high precision. Accuracy depends on input coordinate precision — typically accurate to within meters for most mapping applications.

Try Calculate Midpoint Now

Get your free API key and start using Calculate Midpoint in seconds.

Get Free API Key