Check distance between geo coordinate and IP location using ExtractIP /distance API
Verify Proximity with the Distance API
The ExtractIP Distance API is a powerful tool designed for security and fraud prevention. It allows you to verify if an IP address is located within a certain radius of a specific geographic coordinate. This is particularly useful for verifying user locations, detecting potential GPS spoofing, or ensuring that a request is coming from an expected area.
How it Works
The /geolocate/distance endpoint accepts a POST request with a geographic coordinate (latitude and longitude) and a
radius (distance). The API then compares these coordinates with the detected location of the incoming request's IP address.
Scoring Logic
The API returns a proximity score based on the distance between the provided coordinates and the IP's actual location:
- Score 0: The provided coordinates match the IP's location exactly.
- Score 100: The coordinates are far from the IP's location, reaching the edge of the specified radius or beyond.
This scoring system provides a granular way to assess the risk or validity of a user's reported location.
Example Usage:
You can test the Distance API using a simple curl command. Here is an example of how to check if an IP is within 100km
of a specific coordinate:
curl -X 'POST' \
'https://api.extractip.com/geolocate/distance' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"lat": 5.4282,
"lon": 4.9041,
"distance": 100
}'
By integrating this API into your workflow, you can add an extra layer of verification to your security protocols, ensuring that your users are truly where they say they are.
Tags
Related articles
Meet ipwho — a lightweight CLI tool by ExtractIP that lets you instantly retrieve geographical and administrative data for any IP address right in your terminal.
Check distance between provided geo coordinate and IP location using ExtractIP API
Find out if an IP belongs to a known AI agent or web crawler — a simple way to filter bots and automated traffic