Knowing where your web visitor is located is an incredible advantage for any website; you can display relative content such as maps, prices and availability, display your content in their likely language, etc. I can not exaggerate how useful that information is. Of course we have the HTML5 Geolocation API, but that is based on permission and even if your service does not neglect its purpose, the geolocation pop-up of the browser may seem scary.
If geolocation is critical to your app, the HTML5 Geolocation API is not reliable enough; instead, you want to use an IP-based location service as a primary or secondary option and I really enjoyed experimenting with ipstack!
- With ipstack you can sign up for free
- The only information required is the IP address – ipstack does the rest
- The country name and code, country, region, zip code and more
- Response JSON is small, simple and adaptable
- Receive currency preference of the location
- Reliable by Airbnb, Microsoft, Samsung, Activision and more
- ipstack is from apilayer, the same service provider for currency player, eversign and streetlayer
- With ipstack you can use JSONP
Based on my previous experience with apilayer APIs, I knew ipstack would be easy to use and did not disappoint. For the basic information about the IP address of a specific visitor, please call the following URL:
http://api.ipstack.com/126.96.36.199 ? Access_key = MY_API_KEY & Format = 1
A simple API response would look like this:
You can also send IP addresses in bulk by separating IPs with a comma:
http://api.ipstack.com/188.8.131.52.184.108.40.206 ? Access_key = MY_API_KEY & Format = 1 ## Result: [, ]
With ipstack the developer can also specify output fields, including more information such as the currency of the region:
http://api.ipstack.com/220.127.116.11 ? Access_key = MY_API_KEY & Fields = ip, location, security
You can even use JSONP – no server required:
https://api.ipstack.com/18.104.22.168 ? Access_key = MY_API_KEY & Callback = MY_FUNCTION_NAME
Not needing a server proxy for front-end functionality is such a useful future for developers like myself.
The only surprise I get when using apilayer IP services is how much information I can get based on so little information; the call URL is always predictable and the answer is always as simple as I had hoped. I was surprised at the moment with ipstack with currency information and developers able to provide the desired response information – APIs usually do not allow you to do that. Ultimately ipstack is exactly what you want in an API: offers as much information as you want, is easy to use and is flexible to use!