Skip to content

Latest commit

 

History

History
38 lines (21 loc) · 857 Bytes

README.md

File metadata and controls

38 lines (21 loc) · 857 Bytes

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);
});