Almost all of us have come across the term IP Address while using the internet. An IP address is a numerical label used to identify the presence of a digital device on the Internet. In other words, it is the physical address of a device in the online world.
Whenever a device communicates with other devices over the Internet, they use IP addresses to keep track of each other. So, for example, if you want to load a website on your device, a request will be sent with your IP address to the site’s server.
Any information regarding the geolocation of an IP address of your site’s visitor can tell you from which part of the world he visited your website. This type of information can be handy to any person who wants to know more about their visitors.
There are many tools available on the Internet which can tell the geolocation of the IP addresses and we have reviewed a couple of them at WPCouple. Recently, while finding such a tool for one of my client projects, I came across this incredible API known as IP Geolocation API by Whois API Inc.
I jumped on the opportunity to try out this API, and it proved that it was worth every second of my time. This incredible API help you instantly find the physical location of an IP address along with other related parameters — more on this later.
After integrating this API with my client’s project, and seeing this API in action, I am super excited to share it with you. So let’s get started, shall we?
📌 IP Geolocation API by WhoisXMLAPI
IP Geolocation API is a product of Whois API Inc. — one of the leading Whois API Webservices and data providers. The incredible Jonathan Zhang, the CEO of Whois API LLC, leads this company. It was launched eight years ago in 2010. Their headquarters is in Walnut, California.
Besides IP Geolocation API, they also have a great range of other web products. A few of them are:
- 📮 Email Verification API — An API to verify email address individually or in bulk. We recently reviewed this API at WPCouple.
- 🔍 Reverse IP API — An interesting API for discovering connected domains hosted on the same IP address.
- 🚨 Threat Intelligence API — This one lets you analyze host for any suspicious activity and we plan to review it soon. So, stay updated!
- ✅ Domain Availability API — It enables you to check the availability of domain names in almost every TLDs.
During this period of less than a decade, Whois API Inc managed to serve the fortune 500 companies. They have an impressive list of clients including big names like Apple, Cisco, AT&T, eBay, Amazon, IBM, and Symantec. They manage an extensive database of 5 billion+ historic WHOIS records, 1.2 billion+ domains and subdomains, 2,864+ TLDs & ccTLDs, 8.7 million+ IP netblocks, and 99.5% IP addresses in use.
Getting back to IP Geolocation API, it currently has ~1100 satisfied customers with 15M+ IP blocks and locations. You can inquire about any email address using an HTTP request. The API can respond in one of these two formats — JSON or XML.
🎩 Features of the IP Geolocation API
IP Geolocation API allows you to query the geo information related to an IP address. Let’s quickly take a look at the information returned by this API.
- 🌆 City
- ⏰ Timezone
- 📫 Postal Code
- 📍 Latitude/Longitude
- 🗺 Region/State/Province
- 🇺🇸 Country — Name of the country in which the IP address is located.
Performance of an API is one of the most important metrics that anyone can use to judge its ability. If an API is not able to deliver results promptly, then it might just not work at all. Because in a real-time system, waiting time should be next to zero.
Since this API has over 15 million IP blocks and locations, I decided to the conduct a little performance testing of my own on this API. The results were nothing better than hitting a home run. 🔥
I used the desktop App of Postman to perform a bunch of queries for the same IP address, and the following are the shining details of my little experiment.
- ⏱ Response time for my first request was around ~1 – 2 seconds.
- ⚡️ Average response time for my request, when I made the same request again & again, was reduced to ~400 – 600 milliseconds.
👉 You can see from the results that the response time decreased by more than 50% which indicates that this API is using caching to reduce their response time.
🤘 Benefits of Using IP Geolocation API
There are a lot of benefits of using IP Geolocation API that any online business owner can take advantage of. Let’s briefly take a look at some of these advantages.
🖼 Content Personalization
You can build custom experiences for visitors from different countries. It is a great feature for an e-commerce website. Using the geolocation data, a store owner can show the products related to a specific region of the world.
E-commerce websites can also use the IP Geolocation API to detect the country of their visitors and then use this information to switch the currency to the currency of the visitor’s country or offer different percentages of discount to your products.
🔑 Location Based Access Control
You can control the access to your website using this API. Since the API provides the geolocation of an incoming visitor, you can check whether they are allowed to view your website or not and control their view accordingly.
You can also use this API to give your users access to your services present within a specific IP geolocation range.
👮 Security Applications
You can keep a close watch on the IP addresses visiting your website from any part of the world. If any IP address is showing a suspicious behavior or doing something that it is not supposed to do, then you can track down the originating location, and then act on the information accordingly.
Another great benefit of using IP Geolocation API is that you can compare visitor IP addresses on your e-commerce website with some known customer data to detect online fraud and identity theft.
As mentioned earlier, this API is pretty straightforward to use. If you want geo-information about an IP address, you need to send an HTTP request to the API along with some parameters. Let’s take a look at how you can perform this query.
Before making a request, you need to sign up for the IP Geolocation API. After signing up, you get a free monthly quota of 1000 queries. If you are performing more than a 1000 requests, you need to buy credits.
→ HTTP Request
There are two parameters required to send an HTTP request to the API.
- 🔑 API Key — You will get yours once you sign up for the API.
- 💻 IP Address — IP address whose information needs to be queried.
- 🎨 Output Format (Optional) — Response output format.
You can grab your API key from the dashboard of the API website and make an HTTP request at the following endpoint.
🎯 Performing a GeoIP Lookup with NodeJS
→ Step #1
Get yourself an account on IP Geolocation API’s website. As I mentioned earlier, you get 1000 GeoIP requests free per month. In case, you need more; you can purchase more queries from their site.
→ Step #2
The NPM package which I mentioned earlier is called simple-geoip. You can install it using NPM inside your application. Follow these steps to whip up a new NodeJS application quickly:
- ✅ Open your terminal.
- 🎯 Create a new directory — sample-app — and go inside this directory.
- 👇 Enter the following command to create a new NodeJS application.
- 👊 Now enter the following command to install simple-geoip.
→ Step #3
Since you have installed the NPM package successfully inside your application, the next step is considerably simple. Now you need to include the package inside your application file to perform a GeoIP Lookup of an IP address. Below is a heavily commented gist to help you accomplish that.
This is the simplest way of getting the geo-information of an IP address in your application. You can read the detailed documentation on their website to start customizing your code. A sum of three steps is enough to get your application up and running with IP Geolocation API. Awesome! 👌
🔥 Support & Documentation
A product is only as good as its support and documentation. If the support of a product is not reachable, then you might not want to use it in your projects — to be on the safe side.
I found the support of this API to be reachable within a few hours when you first approach them. After that, their response time decreases with every support query which is commendable. Thumbs up for the service 👍
IP Geolocation API also has a section of API Docs available for everyone on their website. The documentation covers everything which an individual needs to know before using this API and the expected results after using it.
There are three types of payment packages available for the API queries, which are:
- 1️⃣ One-time Purchase
- 2️⃣ Monthly Subscription
- 3️⃣ Yearly Subscription
There is also a custom package available for those who want a different package according to their needs. Contact the company using their contact form to negotiate the custom pricing.
🌟 For those who want to get the hang of the API, there are a 1000 API queries available for free on a monthly basis.
🙌 Final Thoughts!
IP Geolocation API is an impressive API for getting GeoIP data of an IP address. It is straightforward to implement and can be used to detect fraud, identify suspicious behavior, and access management on your online store.
So, whether you are a business manager or a developer, you should give this API a shot. You can use this API to make your website more secure and reliable. It can also help you build a list of safe and loyal customers.
Are you already using this API in your business? Or are you looking for one right now? Let me know your comments in the section below.
SUBSCRIBE TO DEVELOPERS TAKEAWAY!
A Premium Development Newsletter by TheDevCouple! What is TheDevTakeaway?