The Importance of IP Geolocation for Web Developers
Today, I'm introducing ipapi, a new service that provides a wealth of information about your website's visitors based on their IP address. Using the service, you can determine the customer's location, timezone, default language and currency and details about their network's organizational identity. And, ipapi servers provide this information with extremely fast response times.
Essentially, ipapi offers free IP to geolocation, IP to language, currency and timezone detection as well as security details and hostname and ASN lookups.
The home page for the ipapi.com website and its ip2location time zone lookup an, language and currency services
If you've used FreeGeoIP in the past, you'll be familiar with ipapi. It's the result of FreeGeoIP merging with apilayer, a company we've covered here before:
- Introduction to the eversign Electronic Signature API
- How The Streetlayer API Lets You do Real-time, International Address Validation and Autocomplete
- Introduction to the coinlayer Real Time Cryptocurrency API
ipapi provides a faster, higher capacity service to more than 100,000 customers. Cumulatively, they've handled more than 2 billion requests.
ipapi's geolocation API is still free to use for new users up to 10,000 requests per month. For smaller applications, this may be all you need. To access ipapi's complete suite of features, you'll need to choose a plan from $10 monthly up to $100, or request a custom enterprise plan.
Exploring Common Scenarios
The ipapi home page has an excellent interactive visualization that shows how developers can leverage IP data to personalize the experience for visitors. Let's take a look.
Below you see an example of Content Personalization, presenting content specific to a user's location:
Example of IP indication geolocation in New York to show visitor New York Campaign
As a user arrives at your site, you send ipapi the ip address 22.214.171.124. In this example, they respond with the location of your customer New York, United States.
With this information, you can customize the content you provide. For example, this site automatically presents a "New York Campaign" to the visitor. Without geolocation, sites typically have an extra step to request the user's location.
ipapi's average response time is typically 20-50ms, a delay which is not perceptible to site visitors.
Here's a scenario showing how to customize your website's language using ipapi:
When your site visitor arrives, you send the IP address 126.96.36.199 to ipapi. It determines that your prospective customer from Spain. While Spain has five different languages, ipapi determines that this person is visiting from a region that speaks spanish allowing you to personalize your site's translation.
If you're operating an international e-commerce site, it's important to know which currency to present pricing in. The example below shows how to use ipapi to detect currency:
When the site visitor arrives, you transmit their IP address 188.8.131.52 to ipapi. The service responds by telling you the customer is in Japan and the Japanese Yen is the currency used. Then, you can switch your website to display currency in JPY without requiring the user manually do so.
If you do any kind of scheduling or calendaring on your website, it's important to identify the user's timezone.
In this example, a visitor arrives with the IP address 184.108.40.206. Our request to ipapi responds that the person is in Sydney, Australia and uses the Australia Eastern Time (AET).
ipapi also provides fraud detection to help screen bots, crawlers, anonymous users and bad actors. Here you see an IP identified as a TOR proxy which gives you the option of preventing registration:
Example of ipapi indicating visitor IP appears in a threat database to disallow signup
One example not shown above is determining the ASN. The ASN is a code associated with the organization that manages a range of IP addresses. For example, mobile Verizon customers would appear as Verizon, whereas an Apple employee would likely appear as from Apple.
All of this demonstrates the powerful intelligence ipapi can add to your web service. The additional information allows you to provide a more personalized and more efficient user experience.
To clarify, you can get all this data and more from a single request to the ipapi service. Here's an example of a detailed ipapi API response (I formatted the results in two columns to fit on one page):
Example of JSON response of an ipapi query for free geolocation, IP to language, timezone lookup, currency, security, et al.
This response is in JSON but you can also request your results in XML format.
By default, ipapi responds in English but you can also choose German, Spanish, French, Japanese, Portuguese (Brazil), Russian, and Chinese.
Getting Started with the ipapi Service
Sign Up for Your Free Account
To get started with ipapi, click the SIGN UP FREE button in the upper right of the navigation bar. Of course, you can also choose a premium plan with higher capacity.
ipapi's pricing page showing Free, Standard $10, Business $50, Business Pro $100 and custom Enterprise plans.
All paid plans gain SSL access via HTTPS, whereas the free plan does not.
For $10 per month, you get 50,000 requests per month, ip2location, currency information, timezone lookup and hostname and ASN organizational details.
Higher level plans provide bulk processing, which allows you to gather data about large numbers of ip addresses you already have, often from your existing customer base.
With the Business Pro plan at $100 per month, you gain access to security details.
You can save 20 percent on any plan by paying annually.
Registration for ipapi
The sign up form is very straightforward:
Blank sign up form at ipapi's website ipapi.com
You'll also be asked to provide your billing information in case you upgrade.
The ipapi API Dashboard
The Quickstart Guide
ipapi's API dashboard provides your API key and a simple 3 step quickstart guide:
3-step quickstart guide at ipapi after sign up
Step 1 - Your API Access Key
Your API access key provides access to the ipapi API. It's required to be included as a parameter in every call. You can also reset the key to secure a new one whenever you wish.
Step 2 - Reviewing the Major API Endpoints
Overall, there are three primary methods for making use of ipapi API services:
- Standard Lookup: Looks up the data behind a specific IP address you provide in the request.
- Bulk Lookup: Look up the data for multiple IP addresses at once, which you provide in the request.
- Origin Lookup: Look up the data behind the IP address the current API request is coming from i.e. the requesting API is the specified IP address.
Base URL: Whichever API method you choose to use, all API requests to the ipapi API start out with the following base URL: https://api.ipapi.com/