APIs enable mission-critical capabilities for many platforms. Fraud detection for online stores and banking can depend on IP geolocation services using IP lookup to detect whether a user’s IP address matches their stated country.
But location information can be faked by VPNs, proxies and anonymizer’s (TOR) to circumvent IP lookup. So if you’re looking to geolocate an IP address in PHP, can any detect this?
Following are 10 of the best IP geolocation APIs for determining a user’s location as well as three other potentially useful APIs. All use PHP, the well-known scripting language and many offer free IP geolocation plans.
But even when APIs have similar functions, there can be significant differences between them. Functionality can be different or locked behind pricing tiers. Let’s take a closer look.
The rigor of Abstract’s IP geolocation API is ensured by their long-standing relationships with internet service providers across the globe. With geolocation often being essential, Abstract developed the IP geolocation API to have fast response times and be capable of scaling to meet all use cases. Their documentation shows how you can use PHP variables to detect proxies.
Its capabilities, including 256 SSL encryption, are at all pricing levels. So if you have a light, non-commercial use case, the free plan still provides access to country code, city, postal code, and latitude/longitude data core.
For heavier use, commercial versions make richer data available, the API requests scale up to 500 per second and the level of support increases. For bulk queries, CSV upload is available.
MaxMind can source accurate geolocation data proving postal code and approximate latitude/longitude. It can pair these with confidence scores and demographic data for US IP addresses.
However, these richer capabilities and VPN/TOR detection are only available in the highest package. The cost also depends on the number of queries made. A free version limited to 1,000 lookups per day is available.
ipgeolocation can provide IP lookups with low latency/fast response times, detecting a user’s location to latitude/longitude level of detail while pairing these with country flags. It can provide browser and OS details, while also detecting VPNs and proxies.
The free version uses HTTPS to deliver up to 1,000 API returns per day with higher tiers reaching 50 million or more. This increased number of returns is the only difference between the tiers.
Alongside geolocation data, ipstack’s geolocation API can display country flags, identify whether daylight savings is in effect and has proxy/TOR detection. This data can be output in XML or JSON.
The free API key offers 5,000 API returns, but some useful data is only available in the commercial tiers. The proxy/TOR detection is only available in the top two tiers.
There are three tiers with threat assessment only in the highest tier. Each tier is segmented by the number of API calls and support level required. This makes a high number of calls/no threat assessment use case viable.
ip-info’s geolocation data spans country code and ISP data including their phone number and abuse email address.
There’s a free plan and four paid tiers for commercial use. The number of API calls scales per tier. Surprisingly, VPN detection is in the second tier package. The two tiers above this add more IP data such as ip whois with the top tier offering implementation support.
The capability of ipapi’s REST API to use geolocation data to meet different use cases is illustrated by flowcharts on their website. Compatible with IPv4 and IPv6 addresses, location data includes capital, country name and latitude/longitude.
This location data is available at the free tier with 1,000 lookups per month. Commercial tiers increase the number of lookups to over two million for the ‘Enterprise’ option, add further details such as time zone and provide greater support.
Unlike other geolocation APIs, positionstack offers an embeddable map option to offer visual representations of IP lookup data. They also provide examples of geocoding in PHP.
All the geolocation information is available at the free, 25,000 requests per month tier. Embeddable maps and outputs in JSON/GeoJSON/XML formats are available at the first paid tier. Higher tiers offer increased API requests, batch requests and additional support.
ipdata’s geolocation API can provide calling code, country flags, latitude/longitude, and ASN data.
All geolocation data is available in all paid product tiers.
Though the free plan offering 1,500 requests per day is missing from their website comparison, it appears to offer latitude/longitude data. All tiers offer threat intelligence and the top two tiers offer SLAs.
Meteoblue’s API offers local weather data for professional use. Data can be output in images, maps or raw data. The data can span 7 to 14 day forecasts updating at 1 minute intervals.
Pricing for Meteoblue is segmented by functionality, the number of API calls and support levels. A second level of segmentation is the level of meteorological detail. Meteoblue uses a credit system and provides examples to aid cost calculations.
The Mapquest API uses geographical location to source data for amenities such as places to eat, coffee shops, supermarkets, and more.
Targeting commercial needs, Mapquest’s pricing scales with your transactions. Process less than 15,000 transactions per month and it’s free. The more transactions you process, the more it costs. The highest tiers allow you to use data without maps and offer increased levels of support.
This enables the provision of flight data including origin, destination and real time pricing information with a link to ticket booking. There’s also additional options such as car hire and hotel search. These are all called using request path and query parameters.
However, pricing and capability information isn’t provided on the website. The FAQ says you need to email Skyscanner to learn more.
Now, read our guide on how to get the user’s IP address using PHP.
When you’re deciding between the best APIs for IP geolocation, analyze your business needs first. If you don’t, you could acquire the wrong product, potentially acquiring one that has features you won’t use or costs too much.
Don’t become feature obsessed. If you’re not going to use what the next price tier offers, do you need to spring for it?
While most products have flat prices, products that are priced per API lookup or transaction can cost more the more successful you are. So make sure you factor in your projected growth in usage before you make your selection.