Site icon TheDevCouple

IP Geolocation API Review – Lightning Fast Geo API You Need!

Cover - thedevcouple

It is quite important for content creators, course makers to know from where their audience is coming from. There are different kinds of products available on the Internet just for this purpose. Most of these products are paid and cost too much. They also need maintainability. 

During this time, there is still a product out there which provides you all this information and more for a price of $0. It not only allows you to get your customer’s location but also provides a whole lot of other information about that location like currency, country code, continent, etc. The product I am talking about is the IP Geolocation API.

In this piece, I am going to share with you my two cents about working with this API. How it works and what kind of information it provides. So without any further delay, let’s jump in! 🙌🏻

📍 IP Geolocation API

IP Geolocation API is a child company of API Layer which was founded by Paul Zehetmayr in 2015. Since the launch of API Layer, it has come a long way and provides many amazing products like ipstack and ipapi, etc. Among these products lies the IP Geolocation API that is a free real-time IP to Geolocation JSON API with detailed countries data integration. 

IP Geolocation API provides you with the geolocation of a user. Geolocation is the identification or estimation of the real-world geographic location of an internet-connected computer or device. This API also provides country information packaged as convenient JSON objects. This country information includes data from ISO 3166 (countries and states/subdivisions ), ISO 4217 (currency), and last but not the least E.164 (phone number). 💯

💻 Experimenting With The API

Now it’s time for me to show you how this API works. Just follow the steps below and you are good to go!

→ Step #1

The first thing you need to do is to open the IP Geolocation API website. Once you have opened the site, scroll down to the Usage, and get your desired API endpoint. I am using the API with a geolocate endpoint to get data of the country I am living in right now. 

→ Step #2

The next step is to write a simple program to hit the API. I am using JavaScript to make the API call. You can see the program below. Just copy it in your JavaScript file and run it by typing node yourfilename.js. I have also included the response you will receive in the gist below. ⚡️

// importing axios in the file
const axios = require('axios');

// an asychronous function to make the API call
(async () => {
    await axios
        .get('https://api.ipgeolocationapi.com/geolocate')
        .then(({ data }) => console.log(data))
        .catch((err) => console.log(err));
})();

/* Response

{ continent: 'Asia',
  alpha2: 'PK',
  alpha3: 'PAK',
  country_code: '92',
  international_prefix: '00',
  ioc: 'PAK',
  gec: 'PK',
  name: 'Pakistan',
  national_destination_code_lengths: [ 2 ],
  national_number_lengths: [ 9, 10 ],
  national_prefix: '0',
  number: '586',
  region: 'Asia',
  subregion: 'Southern Asia',
  world_region: 'APAC',
  un_locode: 'PK',
  nationality: 'Pakistani',
  postal_code: true,
  unofficial_names: [ 'Pakistan', 'Paquistán', 'パキスタン' ],
  languages_official: [ 'en', 'ur' ],
  languages_spoken: [ 'en', 'ur' ],
  geo:
   { latitude: 30.375321,
     latitude_dec: '29.923219680786133',
     longitude: 69.345116,
     longitude_dec: '69.35774230957031',
     max_latitude: 37.084107,
     max_longitude: 77.8316195,
     min_latitude: 23.6344999,
     min_longitude: 60.8729721,
     bounds: { northeast: [Object], southwest: [Object] } },
  currency_code: 'PKR',
  start_of_week: 'monday' }

*/

🎩 API Features

After I made the API call to the IP Geolocation API, I received a JSON object with geolocation information about myself. I am going to discuss each of these pieces of information in detail now.

🔗 API Endpoints

IP Geolocation API provides its users with different endpoints which they can use to get the desired information they need. Currently, they provide four different endpoints. I am now going to discuss each of them in detail now.

📍 Geolocate

When you make the API call using this endpoint, you will get the information about the country from where you are making the call. This is useful for geolocating users in the frontend without the need to detect their actual IP yourself.

GET https://api.ipgeolocationapi.com/geolocate HTTP/1.1

I have already added the response in the gist above. Just scroll up and take a look!

🔥 Geolocating With IPv4 or IPv6

This endpoint will help you to geolocate any IPv4 or IPv6. For instance, if you have an IP and need a complete geo analysis, you can use this API to make that happen.

GET https://api.ipgeolocationapi.com/geolocate/91.213.103.0 HTTP/1.1

You will get a response something like this one.

{ continent: 'Europe',
  address_format:
   '{{recipient}}\n{{street}}\n{{postalcode}} {{city}}\n{{country}}',
  alpha2: 'DE',
  alpha3: 'DEU',
  country_code: '49',
  international_prefix: '00',
  ioc: 'GER',
  gec: 'GM',
  name: 'Germany',
  national_destination_code_lengths: [ 2, 3, 4, 5 ],
  national_number_lengths: [ 6, 7, 8, 9, 10, 11 ],
  national_prefix: '0',
  number: '276',
  region: 'Europe',
  subregion: 'Western Europe',
  world_region: 'EMEA',
  un_locode: 'DE',
  nationality: 'German',
  eu_member: true,
  eea_member: true,
  vat_rates:
   { standard: 19,
     reduced: [ 7 ],
     super_reduced: null,
     parking: null },
  postal_code: true,
  unofficial_names:
   [ 'Germany',
     'Deutschland',
     'Allemagne',
     'Alemania',
     'ドイツ',
     'Duitsland' ],
  languages_official: [ 'de' ],
  languages_spoken: [ 'de' ],
  geo:
   { latitude: 51.165691,
     latitude_dec: '51.20246505737305',
     longitude: 10.451526,
     longitude_dec: '10.382203102111816',
     max_latitude: 55.0815,
     max_longitude: 15.0418962,
     min_latitude: 47.2701115,
     min_longitude: 5.8663425,
     bounds: { northeast: [Object], southwest: [Object] } },
  currency_code: 'EUR',
  start_of_week: 'monday' }

🇻🇬 Countries

If you are interested in getting information about all the countries in the world, you can then use this endpoint. All you need to do is make an API call to it and save the result in a variable and you are good to go.

GET https://api.ipgeolocationapi.com/countries HTTP/1.1

I am not going to display the information you will receive here. It is because the information is about 195 countries which are too long to display. 

🎩 Geolocating With Country Code 

Earlier I discussed Alpha2 which is an ISO standard. You can use these codes to get information about any country you like. 

GET https://api.ipgeolocationapi.com/countries/de HTTP/1.1

You will get this response if you hit this endpoint. 💯

{ continent: 'North America',
  address_format:
   '{{recipient}}\n{{street}}\n{{city}} {{region_short}} {{postalcode}}\n{{country}}',
  alpha2: 'US',
  alpha3: 'USA',
  country_code: '1',
  international_prefix: '011',
  ioc: 'USA',
  gec: 'US',
  name: 'United States of America',
  national_destination_code_lengths: [ 3 ],
  national_number_lengths: [ 10 ],
  national_prefix: '1',
  number: '840',
  region: 'Americas',
  subregion: 'Northern America',
  world_region: 'AMER',
  un_locode: 'US',
  nationality: 'American',
  postal_code: true,
  unofficial_names:
   [ 'United States',
     'Vereinigte Staaten von Amerika',
     'États-Unis',
     'Estados Unidos',
     'アメリカ合衆国',
     'Verenigde Staten' ],
  languages_official: [ 'en' ],
  languages_spoken: [ 'en' ],
  geo:
   { latitude: 37.09024,
     latitude_dec: '39.44325637817383',
     longitude: -95.712891,
     longitude_dec: '-98.95733642578125',
     max_latitude: 71.5388001,
     max_longitude: -66.885417,
     min_latitude: 18.7763,
     min_longitude: 170.5957,
     bounds: { northeast: [Object], southwest: [Object] } },
  currency_code: 'USD',
  start_of_week: 'sunday' }

🔥 Performance

Now let’s talk about the performance of IP Geolocation API. A geolocation API performance and response time are extremely important especially if you are using it on your website to show country-specific content. 

I am using Postman for this performance test. I have run several tests with different country codes and IP addresses. The following is the result I acquired. These results are the average of many tests I performed.

💡

  • ⚡️ On the first test, I received a response time of 197ms which is pretty impressive.
  • 🚀 I then tested for different alpha2 codes and the response time never went above 200ms.

200ms is blazing fast. IP Geolocation API has ensured that you don’t face any downtime while using their API.

📖 Documentation

IP Geolocation API does not provide any documentation of its API and endpoints. This is one of the downsides I saw while I was using it. I had to google many of the response features. It would be extremely helpful for the users of this API if they have some kind of guide that will help them understand the information they are receiving from the API.

🙌🏻 Wrapping Up

I must say this is an extremely powerful free tool for getting geolocation of customers. It has made the lives of so many developers easier by providing the geolocate endpoint to identify their user’s location. It is also lightning fast and ensures that you get your desired results in time without any lag.

The one thing which I found lacking was the documentation which I mentioned above. I am sure that if IP Geolocation API covers this part of the product too then their API will be a huge success. 

Have you used the IP Geolocation API or similar tool before? Which service did you use and how was your experience? Let us know your thoughts in the comments section below.

Peace! 🤞

Exit mobile version