Subscribe to a Premium Development Newsletter by TheDevCouple! What is TheDevTakeaway?

It is extremely important for some developers to know from which part of the world people are accessing their products. The products might be a course platform that provides discount depending upon the visitor’s location. It can also be a region-restricted website.

There are a lot of products in the market that provides you the location data of your visitor. One of them is the ipwhois.io that not only provides you the geolocation information but also the timezone, currency information, and then some.

Today, I am also going to show you how you can use the ipwhois.io to get the information you require. Also, I am going to test its performance and discuss its features along with a couple of other things. So without any further ado, let’s jump in!

Ipwhois.io Cover Thedevcouple

IPWhoIs.io

As I said earlier, it is a geolocation API. It provides you the location data of your website’s visitor. You can also get information about a particular IP address with this API.

When you make the API call to ipwhois.io, you have the option to get receive information in one of the three formats. These formats include JSON, XML, and Newline. You need to specify your format of choice in the API URL.

Ipwhois.io Landing Page Thedevcouple

Experimenting With The API

Now I am going to show you how this API works and how you can use it to get the geolocation data. Just follow the steps below and you will be alright.

→ Step #1

We need the API first. So for that, head over to the ipwhois.io website, and then from there, the documentation page. Now scroll down and in the example section, you will see an API endpoint. Go ahead and copy it.

Ipwhois.io Api Thedevcouple

→ Step #2

I am going to use JavaScript specifically Node.js to make the API call. I am going to write a simple program that will hit the API and log the results on the console.

I am not going to provide the API any IP address so it can detect where I am coming from automatically. Just copy-paste the following code inside a JavaScript file and run it using node yourfile.js. I have also added the response I received in the gist below.


const axios = require('axios');

// Fetch IP Who Is data.
axios
  .get('http://ipwhois.app/json/')
  .then(({ data }) => console.log(data))


// Sample Response:
{
  "ip": "8.8.4.4",
  "success": true,
  "type": "IPv4",
  "continent": "North America",
  "continent_code": "NA",
  "country": "United States",
  "country_code": "US",
  "country_flag": "https://cdn.ipwhois.io/flags/us.svg",
  "country_capital": "Washington",
  "country_phone": "+1",
  "country_neighbours": "CA,MX,CU",
  "region": "New Jersey",
  "city": "Newark",
  "latitude": 40.735657,
  "longitude": -74.1723667,
  "asn": "AS15169",
  "org": "Google LLC",
  "isp": "Google LLC",
  "timezone": "America/New_York",
  "timezone_name": "Eastern Standard Time",
  "timezone_dstOffset": 0,
  "timezone_gmtOffset": -18000,
  "timezone_gmt": "GMT -5:00",
  "currency": "US Dollar",
  "currency_code": "USD",
  "currency_symbol": "$",
  "currency_rates": 1,
  "currency_plural": "US dollars",
  "completed_requests": 0
}

API Features

I get a lot of information back when I hit the API. Since I didn’t provide any IP address, all of the information is related to where I am right now. Let’s take a look at some of the information it provided us in detail:

  • 🎯 IP: The first thing I received was my IP address. The ipwhois.io API fetched my IP address while making the API call. P.S. I’ve changed the IP to something random.
  • 👍 Success: It is the status of whether my API request is a success or not. Since I was able to hit the API, it gave me back true as its value.
  • 💥 Type: The API provided me the type of my IP address that is Internet Protocol Version 4 (IPv4).
  • 🌍 Continent: It is the continent I am currently on while making the API call. Since I am in Pakistan, I got Asia in this field. If you are from Europe, you will see Europe here.
  • 💡 Continent Code: Every continent is assigned a two letter unique continent code. You get the code according to the continent you are living in at the moment.
  • 🌐 Country: This is the country you are currently living in while making this API call. If you are living in Japan, you will see Japan here.
  • 🚝 Country Code: This is the two-letter country that is assigned to every country in the world.
  • 🇺🇸 Country Flag: This is a URL to an SVG of your country flag. You can place it directly inside an image tag and it will render the flag on your app.
  • 🚀 Country Capital: This is self-explanatory. It is the capital of the country you are living in.
  • 📞 Country Phone: This is the country phone code that you use while making international calls.
  • 🌍 Country Neighbors: This field includes all the countries surrounding the country you are living in while making the API call. The countries are not mentioned by their names but with their country code.
  • 🌐 Region: Now the API is narrowing down the search. In this field, you will see the country region you are in currently.

These are some of the features that this API provides.

💰 Pricing

ipwhois.io currently provides three paid plans and one free plan. With a free plan, you get up to 10,000 requests per month.

The three paid plans are Pro, Business, and Platinum. As you upgrade your plan, you get more and more API requests per month. For instance, with the Platinum plan, you get almost 10 million requests per month.

Ipwhois.io Pricing

🙌 Wrapping Up

If you are in the market for a geolocation API, I would recommend that you should give ipwhois.io a shot. You can try it for free before buying any of its plans. And try it out and see if it is what you are looking for in your product.

It provides you a detailed location data of any IP address. You can use it to get all sorts of information about your visitor including the timezone and the city they are living in.

Have you used ipwhois.io or any similar service to get the user’s geolocation data? Which service did you use and how was your experience? Let us know your thoughts in the comments section below.

🙌

SUBSCRIBE TO DEVELOPERS TAKEAWAY!

A Premium Development Newsletter by TheDevCouple! What is TheDevTakeaway?

IPStack #1 Choice for Site Visitors’ Tracking and Identification DevKinsta – One Suite For All Your WordPress Development Rank Math Plugin For Your SEO Needs
There are currently no comments.

🙌 You must have something to say here...