node package manager


IP lookup using Maxmind databases


Pure Javascript module for Geo IP lookup using Maxmind binary databases (aka mmdb or geoip2). Up to 8000% faster than other Geo lookup libraries. Module natively works with binary Maxmind database format and doesn't require any "CSV - {specific lib format}" conversions as some other modules do. Maxmind binary databases are highly optimized for size and performance so there's no point working with other than that format.

Free GEO databases are available for download here. If you need better accuracy you should consider buying commercial subscription.

npm i maxmind
var maxmind = require('maxmind');
var cityLookup ='/path/to/GeoLite2-City.mmdb');
var city = lookup.get('');
var orgLookup ='/path/to/GeoOrg.mmdb');
var organization = orgLookup.get('');

Module is fully campatible with IPv6. There are no differences in API between IPv4 and IPv6.

var lookup ='/path/to/GeoLite2.mmdb');
var location = maxmind.get('2001:4860:0:1001::3004:ef68');

Right now the only option you can configure is cache. Module uses lru-cache. You can configure its settings by doing following:

var lookup ='/path/to/GeoLite2.mmdb', {
  cache: {
    max: 1000, // max items in cache 
    maxAge: 1000 * 60 * 60 // life time in milliseconds 

Module supports validation for both IPv4 and IPv6:

maxmind.validate(''); // returns true 
maxmind.validate('66.6.44.boom!'); // returns false 
maxmind.validate('2001:4860:0:1001::3004:ef68'); // returns true 
maxmind.validate('2001:4860:0:1001::3004:boom!'); // returns false 

In case you want to use legacy GeoIP binary databases you should use maxmind@0.6.