There are thousands of courses out on the Internet right now. Some of these courses are on platforms like Coursera, Pluralsight, Frontend Masters, etc. But there are still developers who prefer to have their course on a separate learning management system. By doing this they can offer different discounts.
Some of these developers use geolocation APIs to get their visitor’s locations and then offer them a discount accordingly. This is one of the many benefits of geolocation APIs.
In the wide variety of these APIs, there exists a geolocation API that not only provides you with the location of your customer but also with the currency, timezone in their location. I am talking about none other than IPAPI.
Today, I am going to share my thoughts about IPAPI and I will also show you how it works, what are the different features it provides. We will also take a dive into its performance. So without any further ado, let’s jump in! 🙌🏻
⚡️ IPAPI
Originally developed as part of an internal IP address validation and lookup tool, IPAPI is another flagship product of API Layer. The company was founded by Paul Zehetmayr who is also the man behind ipstack, another powerful geolocation API. To this point, IPAPI has helped more than 30,000 businesses worldwide to gain control over their audience and deliver user experience and content at an unparalleled speed and quality.
IPAPI provides a lot of useful information to its users. This information mostly revolves around the location, timezone, currency, and the connection and security of the visitor. The information is extremely detailed which means that you are not only getting the location of your audience but also getting their continent, country, region, city, ZIP Code, latitude, longitudes, and whatnot. 🥂
💻 Experimenting with the API
Now I will take a deep dive into this API by making a call to it using JavaScript and in the process showing you how it works.
→ Step #1
The first and foremost step is to open the IPAPI website. After you have done it, select pricing from the navigation bar. It will take you to a page that will show different features of the API associated with different prices. I am using the free version of the API for this extensive review. You can choose whatever plan that suits you.
Once you have successfully signed up, you will be directed to a dashboard where you can easily see your API access key. Copy it! 💯
→ Step #2
The next step is to write a small program. I have already done that part and you can see it in the gist below. I have also added the response you will receive in the gist if you are too using the free version of the API.
Make sure you understand that the response you will receive will be somewhat different from mine since it would be according to the region you are currently residing in.
// importing axios
const axios = require('axios');
// making the API call
(async () => {
await axios
.get('http://api.ipapi.com/182.185.176.244?access_key=YOUR_API_ACCESS_TOKEN&format=1')
.then(({ data }) => console.log(data))
.catch((err) => console.log(err));
})();
// response I received
{ ip: '182.185.176.244',
type: 'ipv4',
continent_code: 'AS',
continent_name: 'Asia',
country_code: 'PK',
country_name: 'Pakistan',
region_code: 'PB',
region_name: 'Punjab',
city: 'Lahore',
zip: '54000',
latitude: 24.882999420166016,
longitude: 67.05799865722656,
location:
{ geoname_id: 1174872,
capital: 'Islamabad',
languages: [ { code: 'en', name: 'English', native: 'English' },
{ code: 'ur', name: 'Urdu', native: 'اردو', rtl: 1 } ],
country_flag: 'http://assets.ipapi.com/flags/pk.svg',
country_flag_emoji: '🇵🇰',
country_flag_emoji_unicode: 'U+1F1F5 U+1F1F0',
calling_code: '92',
is_eu: false }
}
🚀 Features
IPAPI free plan lets you access all the geolocation data of the visitor looking up at your website. This is extremely beneficial if you are interested in getting only this information.
Now I am going to break down the information I received when I made the API to IPAPI free version. I am going to discuss each of them in detail.
- 📌 IP: This is the IP address that you give to the API as an endpoint. All of the data you receive will be related to this IP address.
- 💥 Type: The next thing you will see is the type of IP address which in my case is Internet Protocol version 4 (IPv4). IPv4 uses a 32-bit address space which provides 4,294,967,296 (232) unique addresses but large blocks are reserved for special networking methods.
- 🔥 Continent Code: Every continent in this world has been given a code, for instance, for Europe it is the EU, and for Antarctica, it is the AN. Since I am making this API call from Asia, I received AS in the response.
- 🌎 Continent Name: This will show you the name of the continent your visitor is currently living at the moment, from where he has opened your website or product.
- 💡 Country Code: Moving a little down the road, you will see next to the Continent Name, the country code of your visitor. From here on now, you will have a more specific idea about your visitor’s location.
- 🌐 Country Name: This will provide you with the name of the country where your visitor is currently living in. This information can give all sorts of ideas about the culture of your visitor or any other useful information you may need about their country.
- 🚝 Region Code: Region Code is the code given to a particular area of a country. It’s mostly the states or provinces of a country.
- 🚀 Region Name: This is the name of the area from where your visitor is checking out your website. In my case, I received Punjab.
- 🏙 City: This is the name of the city where your customer is residing. When I made the API call, I got Lahore as you can see in the gist above.
- ✉️ Zip: The zip code of your visitor’s location.
- 🌍 Latitudes & Longitudes: These are the geographic coordinates and they will provide you with a more precise location of your customer. You can use these coordinates on a map to get the location.
- 📍 Location: Then after all this you will see a location object which will contain the geoname_id, capital, languages, country flag, country flag emoji, country flag emoji Unicode, calling code, and last but not the least is_eu information.
You can find more detailed information about these features here.
🔗 API Endpoints
Like any other good API service, IPAPI provides three different types of API endpoints. Considering the nature of the data this service provides its customer, it is only fair that most of these endpoints are available to those who have purchased their plan.
📍 Standard IP Lookup
You can make use of this endpoint in every plan of IPAPI even if you are using a free account. This endpoint is what I used earlier when I showed you how IPAPI works. You only need to provide the IP address and the API takes care of the rest.
curl http://api.ipapi.com/api/161.185.160.93?access_key=YOUR_ACCESS_KEY
You will get a response somewhat like the following when you make the API call.
{
"ip": "161.185.160.93",
"type": "ipv4",
"continent_code": "NA",
"continent_name": "North America",
"country_code": "US",
"country_name": "United States",
"region_code": "NY",
"region_name": "New York",
"city": "Brooklyn",
"zip": "11238",
"latitude": 40.676,
"longitude": -73.9629,
"location": {
"geoname_id": 5110302,
"capital": "Washington D.C.",
"languages": [
{
"code": "en",
"name": "English",
"native": "English"
}
],
"country_flag": "http://assets.ipapi.com/flags/us.svg",
"country_flag_emoji": "🇺🇸",
"country_flag_emoji_unicode": "U+1F1FA U+1F1F8",
"calling_code": "1",
"is_eu": false
},
"time_zone": {
"id": "America/New_York",
"current_time": "2018-09-24T05:07:10-04:00",
"gmt_offset": -14400,
"code": "EDT",
"is_daylight_saving": true
},
"currency": {
"code": "USD",
"name": "US Dollar",
"plural": "US dollars",
"symbol": "$",
"symbol_native": "$"
},
"connection": {
"asn": 22252,
"isp": "The City of New York"
}
}
If you see the above response one more time, you will notice that it also contains timezone, currency, and connection information. You will only get this information if you have subscribed to IPAPI paid plan.
🚀 Bulk IP Lookup
If you have multiple IP addresses and you need to get information for all of them, then this endpoint is designed just for you. You can do all this by putting IPs in the API URL separated by a comma. That’s it!
curl http://api.ipapi.com/api/161.185.160.93,87.111.168.248,210.138.184.59?access_key=YOUR_ACCESS_KEY
Once you hit the API with multiple IPs, you will get an array of results, containing subarray per IP address looked up.
[
{
"ip": "161.185.160.93",
"type": "ipv4",
"continent_code": "NA",
"continent_name": "North America",
"country_code": "US",
"country_name": "United States",
"region_code": "NY",
"region_name": "New York",
"city": "Brooklyn",
"zip": "11238",
"latitude": 40.676,
"longitude": -73.9629,
[...]
},
{
"ip": "161.185.160.93",
"type": "ipv4",
"continent_code": "EU",
"continent_name": "Europe",
"country_code": "ES",
"country_name": "Spain",
"region_code": "GA",
"region_name": "Galicia",
"city": "Santiago de Compostela",
"zip": "15781",
"latitude": 42.88,
"longitude": -8.5448,
[...]
},
{
"ip": "210.138.184.59",
"type": "ipv4",
"continent_code": "AS",
"continent_name": "Asia",
"country_code": "JP",
"country_name": "Japan",
"region_code": "13",
"region_name": "Tokyo",
"city": "Tokyo",
"zip": "102-0082",
"latitude": 35.685,
"longitude": 139.7514,
[...]
}
]
⚡️ Origin IP Lookup
Last but not the least, they have an Origin IP lookup that lets you get the information of your visitor without you needing to provide their IP address. To work with this endpoint, all you need to do is write a check instead of the IP address in the API base URL.
curl http://api.ipapi.com/api/check?access_key=YOUR_ACCESS_KEY
You will get a response like this.
{
"ip": "161.185.160.93",
"type": "ipv4",
"continent_code": "NA",
"continent_name": "North America",
"country_code": "US",
"country_name": "United States",
"region_code": "NY",
"region_name": "New York",
"city": "Brooklyn",
"zip": "11238",
"latitude": 40.676,
"longitude": -73.9629,
"location": {
"geoname_id": 5110302,
"capital": "Washington D.C.",
"languages": [
{
"code": "en",
"name": "English",
"native": "English"
}
],
"country_flag": "http://assets.ipapi.com/flags/us.svg",
"country_flag_emoji": "🇺🇸",
"country_flag_emoji_unicode": "U+1F1FA U+1F1F8",
"calling_code": "1",
"is_eu": false
},
"time_zone": {
"id": "America/New_York",
"current_time": "2018-09-24T05:07:10-04:00",
"gmt_offset": -14400,
"code": "EDT",
"is_daylight_saving": true
},
"currency": {
"code": "USD",
"name": "US Dollar",
"plural": "US dollars",
"symbol": "$",
"symbol_native": "$"
},
"connection": {
"asn": 22252,
"isp": "The City of New York"
}
}
This is a sample response and again it contains information like a currency that is available only in paid IPAPI plans.
🔥 Performance
It goes without saying that performance is extremely important for geolocation APIs. They need to be lightning-fast to not be responsible for any kind of lag. Also, with the speed, they need to maintain the quality of their work. For instance, if I do not like an API which is fast but gets me different results every time I hit it.
So, the next thing I am going to test is the performance of IPAPI. I am using Postman to make the API call and checking the performance. Also, all of the following results are the average of many attempts I have performed using this API.
💡
- ⚡️ On the first test, I received a response time of 356ms which is quite fast.
- 🚀 Then I tested the API with Bulk IP lookup and Origin IP lookup and the response time never went above 400ms.
The test results are quite satisfactory. The API has shown blazing fast speed and is also showing all the correct data. 💯
📖 Documentation
This is the area in which I look for the first whenever I am testing a service. What kind of documentation they provide. In my opinion, good documentation is essential for a product to succeed.
IPAPI documentation is one of the best API documentation I have seen so far. It contains just the right amount of information that the user needs to work with their API. They even included the information about the response object you receive when you make the API call.
Their documentation includes everything related to their API whether it’s about the endpoints, API error codes, specific response format, etc. They have also provided code examples that you can see if you find something wrong when working with their API. Currently, these examples are only available in PHP and JavaScript.
💰 Pricing
Unlike the IP Geolocation API, IPAPI is not entirely free service. It provides you different plans that include Free, Standard, Business, Business Pro, and Enterprise. All of these plans offer different API features. You also have the option to purchase any of these plans on a monthly basis or a yearly basis. A yearly base plan gets you a 20% discount.
On a free plan, you get 10,000 lookups, location data, and limited support from the IPAPI. But on a $10/month standard plan, you get more features. You have 50,000 lookups, unlimited support, location data, HTTPs encryption while making the API call, currency, timezone, and also connection data.
If you have purchased a business plan that costs $50/month, you get all the standard plan features with 500,000 lookups instead of 50,000 and also Bulk lookups. On the other hand, a $100/month plan gets you all the business plan features and also 2M lookups instead of 500,000 and security data of your visitors as well. ⚡️
🙌🏻 Wrapping Up
IPAPI is one of the best geolocation API I have used so far. It has amazing documentation. The whole API works stupendously and is crazy fast as well.
It is definitely my go-to service if I will ever need the kind of service it provides. So far, I have not seen any fault or irregularities while working with the API. So you should definitely give it a shot if you are planning to buy something similar.
Have you used IPAPI or any similar service to drill user’s information? Which service did you use and how was your experience? Let us know your thoughts in the comments section below.
Peace! 🤞
🙌
SUBSCRIBE TO DEVELOPERS TAKEAWAY!
A Premium Development Newsletter by TheDevCouple! What is TheDevTakeaway?