![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
ip2location-nodejs
Advanced tools
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, usage type, address type and IAB category 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, usage type, address type and IAB category as values. It supports both IP address in IPv4 and IPv6.
This module can be used in many types of projects such as:
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.
To install this module type the following:
npm install ip2location-nodejs
This library requires IP2Location BIN data file to function. You may download the BIN data file at
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.
Below are the methods supported in this module.
Method Name | Description |
---|---|
IP2Location_init | Opens the IP2Location BIN data for lookup. |
IP2Location_get_all | Returns the geolocation information in an object. |
IP2Location_get_country_short | Returns the country code. |
IP2Location_get_country_long | Returns the country name. |
IP2Location_get_region | Returns the region name. |
IP2Location_get_city | Returns the city name. |
IP2Location_get_isp | Returns the ISP name. |
IP2Location_get_latitude | Returns the latitude. |
IP2Location_get_longitude | Returns the longitude. |
IP2Location_get_domain | Returns the domain name. |
IP2Location_get_zipcode | Returns the ZIP code. |
IP2Location_get_timezone | Returns the time zone. |
IP2Location_get_netspeed | Returns the net speed. |
IP2Location_get_iddcode | Returns the IDD code. |
IP2Location_get_areacode | Returns the area code. |
IP2Location_get_weatherstationcode | Returns the weather station code. |
IP2Location_get_weatherstationname | Returns the weather station name. |
IP2Location_get_mcc | Returns the mobile country code. |
IP2Location_get_mnc | Returns the mobile network code. |
IP2Location_get_mobilebrand | Returns the mobile brand. |
IP2Location_get_elevation | Returns the elevation in meters. |
IP2Location_get_usagetype | Returns the usage type. |
IP2Location_get_addresstype | Returns the address type. |
IP2Location_get_category | Returns the IAB category. |
IP2Location_close | Closes BIN file and resets metadata. |
var ip2loc = require("ip2location-nodejs");
ip2loc.IP2Location_init("./DB25.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("--------------------------------------------------------------");
}
ip2loc.IP2Location_close();
FAQs
IP2Location geolocation component
The npm package ip2location-nodejs receives a total of 4,666 weekly downloads. As such, ip2location-nodejs popularity was classified as popular.
We found that ip2location-nodejs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.