Calculate Physical Distance Between IPs

We're excited to announce a powerful new addition to the FreeIPAPI toolkit: the Distance API.

As applications become more global, understanding the physical relationship between your users and your services—or between two different user activities—is becoming critical. Whether you are building security features, optimizing network routing, or just analyzing user data, knowing the physical distance between two points can provide valuable context.

Our new Distance API makes this calculation effortless by allowing you to compute the precise distance between two IP addresses in both Kilometers and Miles.

Why Use the Distance API?

Integrating distance calculations can solve several complex problems with a simple API call:

1. Enhanced Security & Fraud Prevention

One of the most common use cases is detecting "Impossible Travel". If a user logs in from London, and ten minutes later attempts to log in from New York, the physical distance between those two IPs confirms that the second login is likely fraudulent. By automating this check, you can flag suspicious accounts instantly.

2. Server & Content Optimization

Direct your users to the nearest data center or CDN node. By calculating the distance between a user's IP and your various server IPs, you can intelligently route traffic to reduce latency and improve load times.

3. Geographical Analytics

Gain deeper insights into your traffic flow. Understanding the average distance your users are connecting from can help in planning infrastructure expansion or targeting specific regions more effectively.

How It Works

The Distance API is designed to be simple and developer-friendly. It works via a POST request where you provide a "source" and "destination" IP address.

Endpoint: POST /api/distance

Request Body: You simply send the from and to IP addresses in JSON format:

{
    "from": "1.1.1.1",
    "to": "8.8.8.8"
}

The Response: The API returns the geolocation details for both IPs (including city, country, and coordinates) and the calculated distance in both metric and imperial units.

{
  "from": {
    "ip": "1.1.1.1",
    "latitude": -33.8688,
    "longitude": 151.209,
    "city": "Sydney",
    "country": "Australia"
  },
  "to": {
    "ip": "8.8.8.8",
    "latitude": 37.4223,
    "longitude": -122.085,
    "city": "Mountain View",
    "country": "United States"
  },
  "distance": {
    "km": 11953.88,
    "miles": 7427.79
  }
}

Availability

The Distance API is an advanced feature exclusively available to our Unlimited Plan subscribers.

The Unlimited Plan not only unlocks this powerful distance calculation tool but also provides:

  • Unlimited Requests per minute.
  • SSL/TLS Support for secure connections.
  • Commercial Use rights.
  • Access to our full suite of premium endpoints.

Get Started

Ready to start calculating?

  1. Check the Docs: Read the full Distance API Documentation for integration details.
  2. Upgrade Your Plan: Visit our Pricing Page to upgrade to the Unlimited Plan and unlock this feature today.

We can't wait to see what you build with this new capability! 🎉

Published on November 23, 2025 | Tags: new-feature