You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

ip2data

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ip2data

Module to return location information about an IP address. This module can be used with various free location API's and will cache the information locally and(optionally) on Firebase to avoid hiting the API too frequently

1.0.2
latest
Source
npmnpm
Version published
Weekly downloads
3
50%
Maintainers
1
Weekly downloads
 
Created
Source

Synopsis

Node.js module to return an object with location information from an IP address. This module can be used with various free location API's and will cache the information locally and(optionally) on Firebase to avoid hiting the API too frequently

API's tested:

http://telize.com/geoip/

http://ip-api.com/json/

Usage

Create a configuration variable.

var ip2dataConfig = {

  cache: {
    firebase: {
      firebaseUrl: [FIREBASE_URL]",
      firebaseKey: "[FIREBASE_KEY]",
      expiration: 72, // Expiration in hours
      keyname: "ipcache"  
    }, 

    local: {
      expiration: 72 // Expiration in hours
    }, 
        
  },

  IpApiEndpoint: "http://www.telize.com/geoip/", // make sure to end with "/"

}

Initialize ip2data module

var ip2data = require('ip2data')(ip2dataConfig)

Initiate the function passing the ip address. The result will be an object with informations such as city, latitude, longitude, depending on selected API.

ip2data(ip,function(error,result){

  console.log(result)

});

Motivation

Create an Angular app to show connected users in a map in real-time

Installation

npm install ip2data

License

(The MIT License)

Copyright (c) 2015 Geraldo Ramos (geraldo@hackhands.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Keywords

ip location

FAQs

Package last updated on 02 Apr 2015

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