• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

  • Enterprise
    • Product
    • eBooks
    • Contact Us
  • Marketplace
    • Product
    • Sign Up
    • Docs
  • Resources
    • API Blog
    • API Tutorial
    • Developer Showcase
  • EnglishEnglish
    • 日本語日本語
You are here: Home / API Tutorial / IP Geolocation API Tutorial Using geoPlugin

IP Geolocation API Tutorial Using geoPlugin

November 8, 2019 By Shyam Purkayastha Leave a Comment

IP Geolocation is a way of identifying the geographical location of an IP address. Given that routing of all Internet traffic begins from an originating IP address, sometimes it becomes necessary to identify the originating geographical location of the traffic. If you are new to APIs, you can get up and running quickly with our article titled What is an API?

geoPlugin IP Geolocation API is one of the oldest and most robust API for providing IP geolocation services. In this tutorial, we are going to learn about how to geolocate IP addresses with this API and evaluate some use cases.

API Tutorial Geoplugin IP Geolocation

Connect to API

If you haven’t done it yet, then sign up for your Rakuten RapidAPI account to get your universal API key to access the GepPlugin Geolocation API and thousands of other APIs hosted on Rakuten Rapid API.

Table of Contents

  • 1 Applications of IP Geolocation
    • 1.1 Location-Based Targeting
    • 1.2 Traffic Policing
  • 2 Overview of geoPlugin IP Geolocation API
  • 3 Testing the geoPlugin IP Geolocation API
  • 4 Wrapping Up
    • 4.1 Share this:

Applications of IP Geolocation

The Internet lets people live in a virtual world. However, this virtual world is associated with our physical world in every sense. If you think of booking a cab through Uber or ordering groceries online, all these virtual experiences have a link with the physical world around you. In that context, IP geolocation becomes an essential part of tracing an Internet user back to his physical location, either for providing services linked to the user’s geographical location or for law enforcement purposes.

There are two important use cases for an IP Geolocation API.

Location-Based Targeting

 

location targetting

 

Your website gets visitors from all across the world. If you want to tweak your website to show location-specific content, then you need to know the location of the visitor’s IP address. Typically, this IP address belongs to the IP address of the visitors’ Internet Service Provider (ISP) in his home country. You can then show region-specific content to the visitor or personalize the content based on the local language.

Ecommerce websites regularly use this strategy to woo customers. Amazon senses the user’s location at the time of the first visit.  Based on the user’s home country, they provide suggestions to redirect to Amazon’s country-specific site, which then displays the product prices in local currency.

Traffic Policing

 

hacker

 

Hackers routinely attack websites. Popular websites are even more vulnerable to targeted attacks from specific regions of the world. In such cases, it becomes imperative to put policing rules for visitors based on their country of origin. IP geolocation helps you achieve this by analyzing the IP addresses of the visitors.

Wordfence is a popular WordPress plugin that provides a site-wide firewall for WordPress websites. It can detect invalid login attempts from a specific IP address and blocks all traffic from specific countries if too many invalid logins are detected from IP addresses originating in those countries.

Connect to API

Overview of geoPlugin IP Geolocation API

Let’s look at the geoPlugin IP Geolocation API in more detail.

Log in to your Rakuten RapidAPI and search for “geoplugin”.

geoPlugin Ip Geolocation API Search

You can also access the API console directly by clicking here.

geoPlugin IP Geolocation API Console

The API supports two endpoint categories, “IP Geolocation” and “Currency Conversion”. You can check the “Pricing” tab and subscribe to the free basic plan.

geoPlugin API Pricing

Connect to API

The basic plan allows you to access only the “IP Geolocation” endpoints to geolocation IP addresses. The “Currency Conversion” endpoints are available only in the paid plans.

Our focus for this tutorial is on the “IP Geolocation” endpoints. Expand the “IP Geolocation” category, and you can see all the options.

Geoplugin Endpoints

For most applications, the “JSON IP geolocation” endpoint suffices your requirements. It returns the location-specific details for an IP address.

The other endpoints provide flexibility for the developers to integrate IP geolocation detection code within their applications. So, for example, if you are writing some program in PHP or Javascript, which requires the IP Geolocation functionality, then you can call the “PHP IP Geolocation” or “JS IP Geolocation” and embed the API response within your code.

Testing the geoPlugin IP Geolocation API

Get ready for a test run now. Select the “JSON IP Geolocation” from the endpoints panel at the left, and hit the “Test Endpoint” button.

geoPlugin Geolocate IP JSON request

By default, the endpoint does not take any input and accepts the IP address of your computer as the default input. Here is the API response if we set the ‘íp’ parameter to a value of “216.58.200.142”, which is one of Google’s servers located in the US.

Geoplugin Response

The response includes essential details about the origin of the IP address, such as the continent name, country name, state name as well as the city. It should provide you enough information to segment the visitors based on their location.

In case you are looking to offer content in a regional language, then based on the country, you can redirect them to the country-specific website.

For traffic policing based on the location, you can block access to your website for the visitors coming from specific regions. It can be work in other ways as well. For example,  when you are hosting a collaborative chat application for a specific country, you allow only those people from that country to join the chat room.

You can try out the other endpoints to retrieve the API response in specific formats. For instance, the “CSV IP geolocation” endpoint returns the same result in the CSV (Comma Separated Values” format, which is suitable for logging purposes.

Geoplugin CSV Response

Connect to API

Wrapping Up

The geoPlugin IP Geolocation is simple and easy to use API. It is one of the best IP geolocation APIs out there. In case you are curious about the “Currency Conversion”,  it is precisely what it sounds like. This endpoint converts a given amount from one currency from another. It can help you display location-specific pricing tables for your product based on the country of origin.

In this way, both the “IP Geolocation” and “Currency Conversion” endpoint can work in tandem to provide a seamless localized experience to visitors coming to your eCommerce website by presenting products available for the users’ location along with price options in the local currency.

If you are looking for more options, then take a look at our Top 10 Best IP Geolocation APIs.

We will be back soon with an API tutorial on one of our popular APIs.

 

5 / 5 ( 1 vote )

Share this:

  • Click to share on Facebook (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Reddit (Opens in new window)

Filed Under: API Tutorial

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Accelerate tech modernization

To compete in the digital age, Rakuten RapidAPI helps enterprises deploy scalable and flexible IT systems to allow for ongoing experimentation and iteration at speed.

Learn More
Try Rakuten RapidAPI for free
  • Enterprise
  • Marketplace
  • Resources
  • EnglishEnglish

© 2021 Rakuten RapidAPI. All rights reserved.