geoplugin

Geo plugin provided geolocation data of user's browser using services provided by http://www.geoplugin.net/

Usage no npm install needed!

<script type="module">
  import geoplugin from 'https://cdn.skypack.dev/geoplugin';
</script>

README

GEOPLUGIN

Features

  • Get geolocation of visitor's browser
  • Get geolocation by IP
  • Supports the Promise API
  • Automatic transforms for JSON data
  • Free geolocation data provided by http://www.geoplugin.net/

Browser Support

Chrome Firefox Safari Opera Edge IE
Latest ✔ Latest ✔ Latest ✔ Latest ✔ Latest ✔ 11 ✔

Installing

Using npm:

$ npm install geoplugin

Using yarn:

$ yarn add geoplugin

Example

usage

import {getGeo, getGeoByIp} from 'geoplugin';

Getting geolocation of user's browser.

import {getGeo} from 'geoplugin';

// Get geolocation of a user's browser.
getGeo()
  .then(response => console.log(response)); // handle success
  .catch(error => console.log(error)); // handle error
  .then(() => {  }); // always executed

Getting geolocation by an ip address.

import {getGeoByIp} from 'geoplugin';

// Get  geolocation by an ip address.
getGeoByIp('xx.xx.xx.xx')
  .then(response => console.log(response)); // handle success
  .catch(error => console.log(error)); // handle error
  .then(() => {  }); // always executed

Promises

geoplugin depends on a native ES6 Promise implementation to be supported. If your environment doesn't support ES6 Promises, you can polyfill.

Credits

geoplugin is a simple wrapper for REST API provided by geoplugin.com. geoPlugin provides a free geolocation API in multiple different programming languages in a single API call. There is no software installation required, no API key and whether your programming language of choice be Javascript, PHP, XML, JSON, ASP, or CSV, geoPlugin has a way to simply and efficiently geo-localize your visitors.

IP Geolocation by geoPlugin

This product includes GeoLite data created by MaxMind, available from http://www.maxmind.com

License

MIT