https://github.com/whois-api-llc/node-simple-geoip
The simplest possible way to get IP geolocation information.
https://github.com/whois-api-llc/node-simple-geoip
geolocation geolocation-api ip ip-geolocation nodejs whoisxmlapi
Last synced: 9 months ago
JSON representation
The simplest possible way to get IP geolocation information.
- Host: GitHub
- URL: https://github.com/whois-api-llc/node-simple-geoip
- Owner: whois-api-llc
- Created: 2018-04-16T06:29:07.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-03-01T20:26:16.000Z (almost 3 years ago)
- Last Synced: 2025-03-26T20:51:26.834Z (10 months ago)
- Topics: geolocation, geolocation-api, ip, ip-geolocation, nodejs, whoisxmlapi
- Language: JavaScript
- Homepage: https://ip-geolocation.whoisxmlapi.com/api
- Size: 50.8 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# node-simple-geoip
[](https://npmjs.org/package/simple-geoip)
[](https://npmjs.org/package/simple-geoip)
[](https://travis-ci.org/whois-api-llc/node-simple-geoip)
*The simplest possible way to get IP geolocation information in Node.*

## Meta
- Author: Randall Degges
- Email: r@rdegges.com
- Twitter: [@rdegges](https://twitter.com/rdegges)
- Site: https://www.rdegges.com
- Status: production ready
## Prerequisites
To use this library, you'll need to create a free IP Geolocation account:
https://ip-geolocation.whoisxmlapi.com/api
If you haven't done this yet, please do so now.
## Installation
To install `simple-geoip` using [npm](https://www.npmjs.org/), simply run:
```console
$ npm install simple-geoip
```
In the root of your project directory.
## Usage
Once you have `simple-geoip` installed, you can use it to easily find the
physical location of a given IP address.
This library gives you access to all sorts of geographical location data that
you can use in your application in any number of ways.
```javascript
const IpGeolocation = require("simple-geoip");
let ipGeolocation = new IpGeolocation("your-api-key");
ipGeolocation.lookup("8.8.8.8", (err, data) => {
if (err) throw err;
console.log(data);
});
```
Here's the sort of data you might get back when performing a ip geolocation lookup
request:
```json
{
"ip": "8.8.8.8",
"location": {
"country": "US",
"region": "California",
"city": "Mountain View",
"lat": 37.40599,
"lng": -122.078514,
"postalCode": "94043",
"timezone": "-08:00"
}
}
```
By default, this library handles retrying failed HTTP requests for you. For
instance: if the IP Geolocation API service is currently down or having issues,
your request will be retried up to five consecutive times before failing.
This can add more request time, and may not be what you want in all cases.
If you'd prefer to lower the amount of retries that this library will perform on
your behalf, you can pass in a `retries` option like so:
```javascript
const IPGeolocation = require("simple-geoip");
let iPGeolocation = new IPGeolocation("your-api-key", { retries: 2 });
```
## Changelog
0.1.1: *05-06-2018*
- Updating dependencies to handle `hoek` vulnerability.
0.1.0: *04-16-2018*
- First release!