A Node.js wrapper for IP2Country JSON API https://ip2country.info
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples
lib
test
.codeclimate.yml
.editorconfig
.eslintignore
.eslintrc.json
.gitignore
.travis.yml
CHANGELOG.md
LICENSE.md
README.md
index.js
package.json
yarn.lock

README.md

ip2countrify

ip2countrify is a memory-friendly and dependencies-free Node.js module for retrieving country information via https://ip2country.info JSON API. With support for IPv4 and IPv6 addresses.

Dependency Status Build Status Code Climate Known Vulnerabilities

Install

npm install ip2countrify

or

yarn add ip2countrify

Usage

var ip2countrify = require( 'ip2countrify' );

ip2countrify.lookup(
    '5.6.7.8',
    function( ip, results, error ) {
        if ( error ) {
            return console.warn( 'An error has occurred: ' + error );
        }

        console.log(
            'API results for ' + ip
        );
        console.log(
            'countryCode: ' + results.countryCode,
            'countryCode3: ' + results.countryCode3,
            'countryName: ' + results.countryName,
            'countryEmoji: ' + results.countryEmoji
        );
    }
);

Output

API results for 5.6.7.8
countryCode: DE
countryCode3: DEU
countryName: Germany
countryEmoji: 🇩🇪

Limitations

Free, but only for open source projects. Be fair!

Requirements

  • Internet connection

Notice

This product includes GeoLite data created by MaxMind, available from http://maxmind.com