Wednesday, 2 May 2018

How to Use the IPStack API for IP Geolocation Lookups

If you run a website, you’re certainly interested in who’s visiting it. But why leave yourself in the dark by guessing about your visitors or working with incomplete information?

ipstack is a powerful tool for your website that can locate your visitors by IP address through geolocation. Read on to find out more about this IP geolocation tool and how to use it.

What Is ipstack?

ipstack is an IP geolocation API that can look up accurate locations for your website visitors in real-time. When you want to see the information, you can download it in seconds in JSON or XML format for easy review and processing.

There are several reasons that using a tool like this is advantageous. For one, it helps you detect threats from risky IP addresses more efficiently. When a rogue address visits your site, ipstack’s quick identification helps keep it safe.

Another non-security reason is adjusting your visitors’ experience based on location. For example, you might detect a user’s country and change language settings on the fly based on where their IP is. Or, you might have slightly different content prioritized on your website depending on the user’s region.

Getting Started With ipstack

You can try out ipstack at no cost with a free API key. Head to the ipstack homepage and click the orange Get Free API Key button in the upper-right corner. You’ll see ipstack’s various plans (which we’ll discuss below).

ipstack ip geolocation Free API Key

Next, you’ll need to sign up for a free account. Enter your email address and a password, as well as your billing address (and company information if you like). You don’t need to specify any payment information for the free plan.

Once you’ve done this, you’ll see a Quickstart page with your API key. You’ll need this to access the service, so make sure you keep it safe.

IP Lookups

You should know about the three main methods of using ipstack’s IP:

  • Standard Lookup: The most straightforward method, this looks up the data behind a single IP address.
  • Bulk Lookup: This allows you to look up data for multiple IP addresses at once.
  • Requester Lookup: Use this to look up data for the IP address that’s making the API request.

No matter which of the three methods you use, all calls to the ipstack API start with the same base URL:

http://api.ipstack.com/

For a basic IP lookup, all you have to do is append the IP address in question to this URL, followed by your access key. As an example, this URL (with a valid access key) will look up the information for an UltraDNS IP:

http://api.ipstack.com/156.154.71.1?access_key=ABC123&format=1

For a bulk lookup, simply separate two or more IP addresses with commas:

http://api.ipstack.com/156.154.71.1,156.154.70.1?access_key=ABC123&format=1

Finally, for a requester lookup, you don’t need to include an IP address. Instead, add check in its place:

http://api.ipstack.com/check?access_key=ABC123&format=1

ipstack ip geolocation Example Lookup

By default, you’ll see the results in JSON format in a new tab when you open these links. It includes information on the closest city, country, latitude, longitude, language spoken in that area, and more.

Using ipstack on Your Website

Of course, you’re probably not going to manually enter IP addresses into a URL to use the ipstack API. On the backend of your website, you can call ipstack and use the results through languages like PHP or JavaScript. ipstack is flexible and works with other languages and a variety of frameworks, too.

ipstack ip geolocation Sample PHP

A full examination of the code is beyond the scope of this article, so we recommend you take a look at the Sample Code section of ipstack’s helpful documentation. See our explanation of JavaScript if you need a primer.

Once you’ve got the API integrated into your website and are storing the data, you’ll find all sorts of uses for it. The API can detect crawlers and Tor users so you can easily block them. The currency module lets you offer storefronts in the user’s local currency. And learning what percentage of your visitors come from what countries is valuable.

Pricing

Your free ipstack API key includes 10,000 requests per month with the basic location module. For a small website, this should be sufficient, but professional users will likely want to upgrade to a premium plan.

ipstack ip geolocation pricing Plans

Basic, at $9.99 per month, is one step up from the free plan. It ups your monthly requests to 50,000 and includes SSL encryption. You’ll also gain access to additional modules that tell you more about a user’s IP, including currency and time zones. If you need even more, you can check out the Professional or Professional Plus plans.

Lookups Made Easy With ipstack

ipstack receives over two million requests and updates its database more than 20 times per day. It’s also reliable, with 99.998% uptime in the last 30 days. Whether you try out the free plan or opt for a premium offering, you can know it’s a trusted solution for your IP geolocation lookup needs.

For further reading, check out how to trace an IP address and find your own.

Image Credit: efks/DepositPhotos



from MakeUseOf https://ift.tt/2FsxjVl
via IFTTT

No comments:

Post a Comment