Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
geoip-lite
Advanced tools
The geoip-lite npm package provides a fast and lightweight IP geolocation library for Node.js. It allows you to look up the geographic location of an IP address, including country, region, and city information. The package uses a local database, which means it does not require an external service or API call, making it suitable for high-performance applications.
IP to Country Lookup
This feature allows you to look up the country associated with a given IP address. The code sample demonstrates how to use the `lookup` method to retrieve the country code for the IP address '207.97.227.239'.
const geoip = require('geoip-lite');
const ip = '207.97.227.239';
const geo = geoip.lookup(ip);
console.log(geo.country); // Output: 'US'
IP to City Lookup
This feature allows you to look up the city associated with a given IP address. The code sample demonstrates how to use the `lookup` method to retrieve the city name for the IP address '207.97.227.239'.
const geoip = require('geoip-lite');
const ip = '207.97.227.239';
const geo = geoip.lookup(ip);
console.log(geo.city); // Output: 'San Antonio'
IP to Region Lookup
This feature allows you to look up the region (state or province) associated with a given IP address. The code sample demonstrates how to use the `lookup` method to retrieve the region code for the IP address '207.97.227.239'.
const geoip = require('geoip-lite');
const ip = '207.97.227.239';
const geo = geoip.lookup(ip);
console.log(geo.region); // Output: 'TX'
IP to Latitude and Longitude Lookup
This feature allows you to look up the latitude and longitude coordinates associated with a given IP address. The code sample demonstrates how to use the `lookup` method to retrieve the coordinates for the IP address '207.97.227.239'.
const geoip = require('geoip-lite');
const ip = '207.97.227.239';
const geo = geoip.lookup(ip);
console.log(geo.ll); // Output: [29.4889, -98.3987]
The maxmind package provides access to MaxMind's GeoIP2 and GeoLite2 databases. It offers more detailed and accurate geolocation data compared to geoip-lite, but requires downloading and updating the database files regularly. It also supports additional data points such as ISP and organization information.
The ipstack package is a wrapper for the ipstack API, which provides IP geolocation data. It offers a wide range of data points, including country, region, city, ZIP code, latitude, longitude, and more. Unlike geoip-lite, it requires an API key and makes external HTTP requests, which may introduce latency.
The ipinfo package is a client for the IPinfo.io API, which provides IP geolocation and other related data. It offers detailed information such as country, region, city, postal code, latitude, longitude, and ASN. Similar to ipstack, it requires an API key and makes external HTTP requests.
FAQs
A light weight native JavaScript implementation of GeoIP API from MaxMind
The npm package geoip-lite receives a total of 130,321 weekly downloads. As such, geoip-lite popularity was classified as popular.
We found that geoip-lite demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.