Real-time Geolocation & Reverse IP Lookup with ipapi

By (Sponsor)  on  


There's an incredible amount you can do when you know where your web visitor is located.  You can target advertising to the user, you can load maps of nearby search queries, you can localize website verbiage, you can customize content for their region, etc.  I guess what I'm trying to say is reliable geolocation data can make your users happy and you a lot of money.

Whenever I need an API for critical tasks, from currency conversion and email validation, to phone number validation, I look to apilayer, who provide amazing, reliable APIs.  Their latest offering is ipapi, another amazingly simple but reliable and powerful API to get user geolocation information.

Quick Hits

  • Trusted by Wix, Allianz, and gengo
  • Provides location, ISP, currency, and timezone information
  • Free to sign up!
  • Provides TOR detection and fraud prevention
  • Allows response format of JSON or XML
  • Allows JSONP for client side requests


Using ipapi

The easiest way to use ipapi is by simply sending the IP address:


You quickly receive a response with location details based on the IP address:

   "continent_name":"North America",
   "country_name":"United States",
      "capital":"Washington D.C.",
      "country_flag_emoji_unicode":"U+1F1FA U+1F1F8",

You can also customize the data returned by ipapi by taking advantage of the fields parameter:,longitude

ipapi even allows you to specify a response language for select response properties:
    "ip": "",
    "type": "ipv4",
    "continent_code": "NA",
    "continent_name": "Norteamérica",  <-- translated
    "country_code": "US",
    "country_name": "Estados Unidos",  <-- translated
    "region_code": "NY",
    "region_name": "Nueva York",  <-- translated
    "city": "Brooklyn",
    "zip": "11238",
    "latitude": 40.676,
    "longitude": -73.9629,

If you're looking for security-centric data for the IP address, ipapi has you covered there:

    "security": {
        "is_proxy": false,
        "proxy_type": null,
        "is_crawler": false,
        "crawler_name": null,
        "crawler_type": null,
        "is_tor": false,
        "threat_level": "high",
        "threat_types": [

ipapi also allows you to provide a callback parameter so that you can take advantage of JSONP on the client side:

// set endpoint and your access key
var ip = ''
var access_key = 'MY_ACCESS_KEY';

// get the API result via jQuery.ajax
    url: '' + ip + '?access_key=' + access_key,   
    dataType: 'jsonp',
    success: function(json) {

        // output the "calling_code" object inside "location"

ipapi is another amazingly practical and useful API from apilayer.  Having geolocation data for the user is an invaluable tool in improving user experience, conversion, utility, and anything your imagine can dream up.  Better yet is that the API is flexible, reliable, and backed by proven API experts.  If you want an advantage in visitor user experience and ad space, check out ipapi -- you wont be disappointed!


    Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!