Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including ip2countrify with all npm packages installed. Try it out:

var ip2countrify = require("ip2countrify")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

ip2countrify v0.2.0

A Node.js wrapper for IP2Country JSON API

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

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free