npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

async-ip2location

v8.1.3

Published

Asynchronous IP2Location geolocation component

Downloads

3

Readme

Asynchronous IP2Location Node.js Module

This Node.js module provides a fast and asynchronous lookup of country, region, city, latitude, longitude, ZIP code, time zone, ISP, domain name, connection type, IDD code, area code, weather station code, station name, mcc, mnc, mobile brand, elevation, and usage type from IP address by using IP2Location database. This module uses a file based database available at IP2Location.com. This database simply contains IP blocks as keys, and other information such as country, region, city, latitude, longitude, ZIP code, time zone, ISP, domain name, connection type, IDD code, area code, weather station code, station name, mcc, mnc, mobile brand, elevation, and usage type as values. It supports both IP address in IPv4 and IPv6.

This module can be used in many types of projects such as:

  • select the geographically closest mirror
  • analyze your web server logs to determine the countries of your visitors
  • credit card fraud detection
  • software export controls
  • display native language and currency
  • prevent password sharing and abuse of service
  • geotargeting in advertisement

The database will be updated in monthly basis for the greater accuracy. Free sample DB1 database is available at /samples directory or download it from https://www.ip2location.com/developers.htm.

The complete database is available at https://www.ip2location.com under Premium subscription package.

Dependencies

This library requires IP2Location BIN data file to function. You may download the BIN data file at

  • IP2Location LITE BIN Data (Free): https://lite.ip2location.com
  • IP2Location Commercial BIN Data (Comprehensive): https://www.ip2location.com

IPv4 BIN vs IPv6 BIN

Use the IPv4 BIN file if you just need to query IPv4 addresses. If you query an IPv6 address using the IPv4 BIN, you'll see the IPV6_NOT_SUPPORTED error.

Use the IPv6 BIN file if you need to query BOTH IPv4 and IPv6 addresses.

Methods

The module itself only exports a single function that is used to initialize the database. The result is a promise that resolves to a database object with the methods below.

Below are the methods supported in this module.

|Method Name|Description| |---|---| |get_all|Returns the geolocation information in an object.| |get_country_short|Returns the country code.| |get_country_long|Returns the country name.| |get_region|Returns the region name.| |get_city|Returns the city name.| |get_isp|Returns the ISP name.| |get_latitude|Returns the latitude.| |get_longitude|Returns the longitude.| |get_domain|Returns the domain name.| |get_zipcode|Returns the ZIP code.| |get_timezone|Returns the time zone.| |get_netspeed|Returns the net speed.| |get_iddcode|Returns the IDD code.| |get_areacode|Returns the area code.| |get_weatherstationcode|Returns the weather station code.| |get_weatherstationname|Returns the weather station name.| |get_mcc|Returns the mobile country code.| |get_mnc|Returns the mobile network code.| |get_mobilebrand|Returns the mobile brand.| |get_elevation|Returns the elevation in meters.| |get_usagetype|Returns the usage type.|

Usage


var ip2loc = require('./ip2location.js');

ip2loc('./DB8.BIN')
	.then((db) => {
		return db.get_all('8.8.8.8');
	})
	.then(result => {
		console.log(JSON.stringify(result))
		console.log('--------------------------------------------------------------');
	});