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
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|---|
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.
This product includes GeoLite data created by MaxMind, available from http://www.maxmind.com