Comparing IP Address Geolocation API Services
Origin StoryI have a side-project I've been running for several years (v1 was released on Jul 5, 2011) called FindTower. It helps people camping or hiking to locate cellular towers around them.
People with RVs also use it better position their antennas.
The app obviously requires the user's location in order to load a map and position relevant towers.
A common issue is that sometimes, on first load, a user might not grant GeoLocation authorization and therefore everything else gets stumped.
As a fall back, the app uses the IP address to at least have a rough idea of the user's location.
Over the years, I've tried multiple services offering this. Recently, I noticed many new public APIs offering this have popped up.
Honestly an approximate location is fine to showcase how the app works (before I instruct the user on how to grant GPS access).
However, this morning I was curious to see how all these APIs compare... So I decided to test all of them 😄
I'm sure there are more but for this first iteration I will be taking into account the following:
- I always use a VPN so the first step was to find my real IP address assigned by the ISP.
- Queried all the APIs for the same IP and saved the results.
- Find my true coordinates. I opened google maps, clicked on my location and grabbed the latitude and logitude.
- Calculate the distance (ie error) between all the returned coordinates and my true location. In FindTower I have a helper function to calculate the distance between two coordinates "as the crow flies" so it was pretty quick.
ResultsGranted results will vary due to many factors, I always like to have a general idea of the reliability of the data I'm using to always reduce error margins at every stage of a process.
Here is by how much the APIs were "off" (in kilometers) given my true coordinates:
[Log] AbstractAPI: 157.52246741097514 [Log] BigDataCloud: 1.920934529098657 [Log] KeyCdn: 2.09610383290298 [Log] Ip-Api: 2.2877973316608484 [Log] IpApi: 0.2635768468879036 [Log] IpData: 2.09610383290298 [Log] IpInfo: 6.296544013303361 [Log] IpStack: 0.2635768468879036 [Log] LabStack: 0.4548823247110428 [Log] Google: 2.09610383290298→ Interesting to note IpApi and IpStack are exactly the same, perhaps they rely on the same system.
ConclusionSo there you have it. Most APIs tested have satisfactory results: coordinates are within 2km (little over a mile) from the true location. The test was performed in San Francisco where there are many ISP nodes and samples therefore it's easier to obtain an accurate reading.
Published: Mon, Oct 26 2020 @ 11:53:34Back to Blog