How to Look Up an Address Using Geolocation API

Services that provide location information are frequently used by websites and smartphones today. Business owners get the location information of their visitors through apps and websites. The easiest and most effortless way to access the location information of visitors is the public IP address. Visitors' geolocation information is obtained from the location information corresponding to the visitor's IP address.

Web services that provide geolocation services provide instantaneous location data corresponding to the IP address. Today, there are many web services that provide geolocation services. Among these web services, the most preferred web service by applications and websites today is Ipstack.

In the most basic sense, Ipstack offers geolocation service in the most effective way. It provides the location information corresponding to the IP address in the most detailed way to the users. It contains information such as the continent, the official currency of the location corresponding to the IP address. In addition, Ipstack can provide location information corresponding to more than one IP address at the same time with a single service.

Let's take a look at how to use Ipstack, which provides geolocation service,without integrating it into the code side, and then let's make sample requests through the browser.

Using the Ipstack API

In order to use the API of Ipstack, which provides geolocation service, we need to obtain an API key. We can access flexible packages, including the free package, from here, and we can get an API key by choosing one of them.

After obtaining an API key, we can run the Ipstack API through the browser. Ipstack API only provides endpoints with the HTTP GET method.

Let's paste the following url into the browser, make sure you have an account to make a request.

https://api.ipstack.com/134.201.250.155?access_key=c1*****51

The response returned as a result of this request is as follows.

{
    "ip":  "134.201.250.155",
    "type":  "ipv4",
    "continent_code":  "NA",
    "continent_name":  "North America",
    "country_code":  "US",
    "country_name":  "United States",
    "region_code":  "CA",
    "region_name":  "California",
    "city":  "Los Angeles",
    "zip":  "90013",
    "latitude":  34.0453,
    "longitude":  -118.2413,
    "location":  {
        "geoname_id":  5368361,
        "capital":  "Washington D.C.",
        "languages":  [
        {
            "code":  "en",
            "name":  "English",
            "native":  "English"
        }
    ],
    "country_flag":  "https://assets.ipstack.com/images/assets/flags_svg/us.svg",
    "country_flag_emoji":  "🇺🇸",
    "country_flag_emoji_unicode":  "U+1F1FA U+1F1F8",
    "calling_code":  "1",
    "is_eu":  false
  },
  "time_zone":  {
    "id":  "America/Los_Angeles",
    "current_time":  "2018-03-29T07:35:08-07:00",
    "gmt_offset":  -25200,
    "code":  "PDT",
    "is_daylight_saving":  true
  },
  "currency":  {
    "code":  "USD",
    "name":  "US Dollar",
    "plural":  "US dollars",
    "symbol":  "$",
    "symbol_native":  "$"
  },
  "connection": {
    "asn":  25876,
    "isp":  "Los Angeles Department of Water & Power"
  }
}
                        

When we change the IP address in the url with 102.129.156.20 and send a request, the following response is received.

{
    "ip": "102.129.156.20",
    "type": "ipv4",
    "continent_code": "AS",
    "continent_name": "Asia",
    "country_code": "TW",
    "country_name": "Taiwan",
    "region_code": "CYI",
    "region_name": "Taiwan",
    "city": "Taipei",
    "zip": "100",
    "latitude": 25.042139053344727,
    "longitude": 121.51986694335938,
    "location": {
        "geoname_id": 1668341,
        "capital": "Taipei",
        "languages": [
      {
        "code": "zh",
        "name": "Chinese",
        "native": "\u4e2d\u6587"
      }
    ],
    "country_flag": "https://assets.ipstack.com/flags/tw.svg",
    "country_flag_emoji": "\ud83c\uddf9\ud83c\uddfc",
    "country_flag_emoji_unicode": "U+1F1F9 U+1F1FC",
    "calling_code": "886",
    "is_eu": false
  },
  "time_zone": {
    "id": "Asia/Taipei",
    "current_time": "2022-09-03T18:58:54+08:00",
    "gmt_offset": 28800,
    "code": "CST",
    "is_daylight_saving": false
  },
  "currency": {
    "code": "TWD",
    "name": "New Taiwan Dollar",
    "plural": "New Taiwan dollars",
    "symbol": "NT$",
    "symbol_native": "NT$"
  },
  "connection": {
    "asn": 9009,
    "isp": "m247 Ltd"
  },
  "security": {
    "is_proxy": false,
    "proxy_type": null,
    "is_crawler": false,
    "crawler_name": null,
    "crawler_type": null,
    "is_tor": false,
    "threat_level": "low",
    "threat_types": null
  }
}
                        

When we look at the geolocation information of the IP addresses, one in the USA and the other in Taiwan, very detailed information about the two geolocations is provided by Fixer.

Let's test the service that provides geolocation information corresponding to more than one IP address with a single service. Let's paste the following url into the browser and make a request.

http://api.ipstack.com/134.201.250.155,72.229.28.185,110.174.165.78?access_key=c1*****51

The response returned as a result of this request is as follows.

[
  {
    "ip": "134.201.250.155",
    "type": "ipv4",
    "continent_code": "NA",
    "continent_name": "North America",
    "country_code": "US",
    "country_name": "United States",
    "region_code": "CA",
    "region_name": "California",
    "city": "Los Angeles",
    "zip": "90013",
    "latitude": 34.0453,
    "longitude": -118.2413,
    "location": { ... },
    "time_zone": { ... },
    "currency": { ... },
    "connection": { ... },
  },
  {
    "ip": "72.229.28.185",
    "type": "ipv4",
    "continent_code": "NA",
    "continent_name": "North America",
    "country_code": "US",
    "country_name": "United States",
    "region_code": "NY",
    "region_name": "New York",
    "city": "New York",
    "zip": "10036",
    "latitude": 40.7605,
    "longitude": -73.9933,
    "location": { ... },
    "time_zone": { ... },
    "currency": { ... },
    "connection": { ... },
  },
  {
    "ip": "110.174.165.78",
    "type": "ipv4",
    "continent_code": "OC",
    "continent_name": "Oceania",
    "country_code": "AU",
    "country_name": "Australia",
    "region_code": "NSW",
    "region_name": "New South Wales",
    "city": "Coffs Harbour",
    "zip": "2450",
    "latitude": -30.2963,
    "longitude": 153.1135,
    "location": { ... },
    "time_zone": { ... },
    "currency": { ... },
    "connection": { ... },
  }
]
                        

Conclusion

We have touched on the use of geolocation services in a basic sense. With geolcation services, businesses gain organic traffic by increasing visitor satisfaction. You can integrate Ipstack API, the most popular web service that offers geolocation service, into your applications in just a few steps, and you can quickly take steps to increase your visitor satisfaction.