Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

simple-geoip

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-geoip

The simplest possible way to get IP geolocation information.

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-94.74%
Maintainers
2
Weekly downloads
 
Created
Source

node-simple-geoip

NPM Version NPM Downloads Build Status

The simplest possible way to get IP geolocation information in Node.

Email Verifier Icon

Meta

Prerequisites

To use this library, you'll need to create a free GeoIPify account: https://geoipify.whoisxmlapi.com/

If you haven't done this yet, please do so now.

Installation

To install simple-geoip using npm, simply run:

$ 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.

const GeoIP = require("simple-geoip");

let geoIP = new GeoIP("your-api-key");
geoIP.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 geoip lookup request:

{
  "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 geoip 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:

const GeoIP = require("simple-geoip");

let geoIP = new GeoIP("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!

Keywords

FAQs

Package last updated on 04 Dec 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc