Freegeoip access from NodeJS
JavaScript
Switch branches/tags
Nothing to show
Latest commit 6290e09 Apr 18, 2016 @lxfontes lxfontes Merge pull request #1 from DanPen/master
Add option for timeout

README.md

freegeoip.net bindings for NodeJS.

Build Status

Install

The usual

npm install node-freegeoip

Usage

var freegeoip = require('node-freegeoip');

var ip = '127.0.0.1';
freegeoip.getLocation(ip, function(err, location) {
    console.log(location);
});

If you concerned about latency, you can set the maximum time to wait for a response from freegeoip.net. It is set to 3000 milliseconds by default.

freegeoip.maxLatency = 750;

Running your own server ?

Set the default server prior queries

var freegeoip = require('node-freegeoip');

freegeoip.setUrl('http://myserver.info/json/');

var ip = '127.0.0.1';
freegeoip.getLocation(ip, function(err, location) {
  console.log(location);
});