willscott / ip2country

A standalone ip -> country lookup table. Prebuilt & Redistributable.
Apache License 2.0
27 stars 8 forks source link

IP 2 Country

IP 2 Country provides a current lookup table to geolocate IP address to the countries in which they are most probably located. Distributed as a stand-alone NPM module with no dependencies, the list is created at publication time. This mapping is generated through the use of two databases:

Size

2.0M ip2country.js
510K ip2country.js.gz

Installation

  npm install ip2country

Usage

var ip2country = require('ip2country');
var country = ip2country(ip);

Advanced Usage

There are several related lookup tables for IP addresses that may be of use. While not published for direct consumption, this library contains the tools to generate those tables for your process. This functionality is accessed through the getGenericMap() function in build.js. In particular, the following knobs are exposed when generating the lookup table: