CodeinWP CodeinWP

A Review of ipwhois.io for Reliable Geolocation Data

The following is a sponsored article for ipwhois.io, a fast IP Geolocation API service for developers.

If you’re building an app that requires delivering a dynamic experience based on the user’s location or other location-related data, a fast and easy-to-use Geolocation API will certainly come in handy. One such option is ipwhois.io. The service, which is free for small non-commercial projects that need fewer than 10,000 requests per month, is easy to integrate with your tech stack.

ipwhois.io

As usual, it’s always best to look at a few examples so you can see it in action. Their documentation is short and easy to follow, so I’ll demonstrate using the following example request:

http://ipwhois.app/json/52.149.246.39

Notice a few things in the above URL:

  • It’s using the ipwhois.app domain, which is different from the primary domain ipwhois.io
  • I’m requesting JSON data, but I could alternatively use “xml” or “csv” by adjusting the URL
  • I’ve appended the IP address that I want to get info for

You can run the request as a cURL command in your terminal or visit the URL directly in your browser. Try one of the following links:

The payload that’s returned for the JSON request looks something like this (I’ve prettified it for readability):

{
  "ip":"52.149.246.39",
  "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":"Virginia",
  "city":"Ashburn",
  "latitude":39.0437567,
  "longitude":-77.4874416,
  "asn":"AS8075",
  "org":"Microsoft Corporation",
  "isp":"Microsoft Corporation",
  "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":15
}

For demonstration purposes in this instance, the IP I used was the IP address for DuckDuckGo. (As a side point, it’s interesting that the “org” in this payload is listed as “Microsoft Corporation”; I’m assuming this is because DuckDuckGo uses Bing as the basis for its search results as they aren’t a Microsoft-owned company.)

The above JSON payload includes a lot of info, but you can immediately see how it can be useful in your apps. Some of the bits of data you might be interested in include:

  • Continent and two-letter continent code
  • Country and two-letter country code
  • Country phone code (e.g. +1)
  • 5 different bits of time zone-related values
  • 5 different bits of currency-related values

Each request also returns a success Boolean representing whether the request was successful along with an accompanying error message when the value is false.

As mentioned, there’s quite a bit of info on each request. But you don’t need to request all of it – you can limit which fields are returned by using query string parameters:

http://ipwhois.app/xml/52.149.246.39?objects=country,city,timezone,currency

The payload for the above request (which asks for XML instead of JSON) would be:

<query>
  <country>United States</country>
  <city>Ashburn</city>
  <timezone>America/New_York</timezone>
  <currency>US Dollar</currency>
</query>

The request is also available as a JSONP callback. Simply change the URL to include the callback parameter, which you can set to the name of your callback function:

http://ipwhois.app/json/52.149.246.39?objects=country,city,timezone,currency&callback=myIPInfo

The above would return the following:

myIPInfo({
  "country":"United States",
  "city":"Ashburn",
  "timezone":"America\/New_York",
  "currency":"US Dollar"
});

Lastly, you can also append a lang parameter for localization:

http://ipwhois.app/json/52.149.246.39?objects=country,continent,success,currency&lang=fr

The result:

{
  "success":true,
  "continent":"Am\u00e9rique du Nord",
  "country":"\u00c9tats-Unis",
  "currency":"US Dollar"
}

Notice for the request I used “fr” (French) as the language, so this is reflected in the data returned.

As mentioned, if you’re building something for non-commercial use that’s under 10,000 requests per month, you can use ipwhois.io free of charge. For details on commercial usage or projects that require 10,000 request or more, check out the pricing page.

ipwhois.io is a continuously reliable service – they use a neural network that analyzes dozens of sources to update their database in almost real-time. Overall, this is a solid solution for integrating IP-based geolocation data into your JavaScript, Python, PHP, or jQuery apps (there’s code examples for each in the docs).

2 Responses

  1. zomberi says:

    Duckduck show MS maybe because it is hosted on Azure cloud service

  2. Stephan says:

    While I think it’s quite a useful service, I have my doubts about the company.
    1. There is no imprint on their webpage.
    2. The company behind it is hidden behind namecheap’s privacy shield.
    3. Their office location is a virtual one in a co-working office in Reykjavík

Leave a Reply

Comment Rules: Please use a real name or alias. Keywords are not allowed in the "name" field and deep URLs are not allowed in the "Website" field. If you use keywords or deep URLs, your comment or URL will be removed. No foul language, please. Thank you for cooperating.

Markdown in use! Use `backticks` for inline code snippets and triple backticks at start and end for code blocks. You can also indent a code block four spaces. And no need to escape HTML, just type it correctly but make sure it's inside code delimeters (backticks or triple backticks).