We're live-coding on Twitch! Join us! FREE Webinar: Should I use React or Vue?
Open-Source IP Geo-location API

Open-Source IP Geo-location API

Code Demo Project

Geo-location is the identification or estimation of the real-world geographic location of an Internet-connected computer terminal or device.

Basically, we can get location data from their IP address.

Geo-location offers a lot of advantages and increase level of customization to a website. We can:

  • Give users data in their language.
  • With knowlege of cultural differences, properly represent data.
  • Build a security layer/firewall

and many, many more features.

If you do a Google search, there are many services that offer Geo-location for a price. Or, companies like MaxMind that offer a subset of the data they’ve gathered over the years for free.

With companies like MaxMind, you have to download their database every now and then to make sure the data is up to date, manage your own servers, and all other house-keeping. That’s what IP Geolocation API will do for you.

What is IP Geolocation API and How Does it Work

IP Geolocation API, is a free to use Geo-location service.

The code is open-source which means you can deploy your version of the product and let it run all the house keeping for you. It is written in Python. So, if you need to fork and modify, you probably need to know how to code in Python.

When a request comes into the application,

React LogoReact Logo
Upgrade Your JS
Go from vanilla JavaScript 👉 React

How to Deploy a Standalone Version

Heroku is probably the best option since it’s managed.. If you already use Heroku, you can do a quick deploy by clicking this link.

Another reason to use heroku is that whenever the database gets updated, deployment is very easy.

Using the API

Currently, the API has four HTTP endpoints. **Don’t leave the slash at the end of the URL**.

GET https://api.ipgeolocationapi.com/geolocate HTTP/1.1
GET https://api.ipgeolocationapi.com/geolocate/<ip> HTTP/1.1
GET https://api.ipgeolocationapi.com/countries HTTP/1.1
GET https://api.ipgeolocationapi.com/countries/<country_code> HTTP/1.1
  • /geolocate will automatically detect the users IP address and return the location data.

  • /geolocate/<ip> requires you to supply the users IP address and returns the same data as /geolocate

  • /countries returns a list of the countries in the database and all the information they have about them.

  • /countries/<country_code> returns the information about one country.

Note: If you deployed your own version, you’ll want to replace _https://api.ipgeolocationapi.com with your own domain_

Making a request to https://api.ipgeolocationapi.com/geolocate will give you:

       "address_format":"{{recipient}}\n{{street}}\n{{postalcode}} {{city}}\n{{country}}",
       "subregion":"Western Europe",

With one request, the API can infer that my Iocation is Germany, the currency, longitude and latitude and so much more.


If you find this project useful, be sure to give them a star on Github, make contributions and support the author however you can. Thanks!

This content is sponsored via Syndicate Ads.