New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ip2location-nodejs

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ip2location-nodejs

IP2Location geolocation component

  • 8.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1K
decreased by-77.54%
Maintainers
1
Weekly downloads
 
Created
Source

IP2Location Node.js Module

This Node.js module provides a fast 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.

Installation

To install this module type the following:


npm install ip2location-nodejs

Dependencies

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

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

Below are the methods supported in this module.

Method NameDescription
IP2Location_initOpens the IP2Location BIN data for lookup.
IP2Location_get_allReturns the geolocation information in an object.
IP2Location_get_country_shortReturns the country code.
IP2Location_get_country_longReturns the country name.
IP2Location_get_regionReturns the region name.
IP2Location_get_cityReturns the city name.
IP2Location_get_ispReturns the ISP name.
IP2Location_get_latitudeReturns the latitude.
IP2Location_get_longitudeReturns the longitude.
IP2Location_get_domainReturns the domain name.
IP2Location_get_zipcodeReturns the ZIP code.
IP2Location_get_timezoneReturns the time zone.
IP2Location_get_netspeedReturns the net speed.
IP2Location_get_iddcodeReturns the IDD code.
IP2Location_get_areacodeReturns the area code.
IP2Location_get_weatherstationcodeReturns the weather station code.
IP2Location_get_weatherstationnameReturns the weather station name.
IP2Location_get_mccReturns the mobile country code.
IP2Location_get_mncReturns the mobile network code.
IP2Location_get_mobilebrandReturns the mobile brand.
IP2Location_get_elevationReturns the elevation in meters.
IP2Location_get_usagetypeReturns the usage type.

Usage


var ip2loc = require("ip2location-nodejs");

ip2loc.IP2Location_init("./DB24.BIN");

testip = ['8.8.8.8', '2404:6800:4001:c01::67'];

for (var x = 0; x < testip.length; x++) {
	result = ip2loc.IP2Location_get_all(testip[x]);
	for (var key in result) {
		console.log(key + ": " + result[key]);
	}
	console.log("--------------------------------------------------------------");
}

Keywords

FAQs

Package last updated on 09 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc