UNPKG

get-ip-location-lite

Version:

Fetches IP address geolocation data using ip-api.com (no API key required)

84 lines (57 loc) โ€ข 1.52 kB
# ๐ŸŒ get-ip-location-lite Lightweight utility to fetch geolocation data (country, city, ISP, coordinates, etc.) from an IP address using the **ipwho.is** API. No API key required. Works with HTTPS. --- ## ๐Ÿ“ฆ Installation ### Using npm ```bash npm install get-ip-location-lite ``` ### Using yarn ```bash yarn add get-ip-location-lite ``` --- ## ๐Ÿš€ Usage ```js const getIPLocation = require("get-ip-location-lite"); // Get the location of the current user's IP getIPLocation() .then(data => console.log("Your IP Location:", data)) .catch(err => console.error("Error:", err)); // OR get location info for a specific IP getIPLocation("8.8.8.8") .then(data => console.log("Google DNS IP Location:", data)) .catch(err => console.error("Error:", err)); ``` --- ## โš™๏ธ Options No options object required. | Parameter | Type | Required | Description | |-----------|----------|----------|----------------------------------------| | `ip` | `string` | โŒ | IP address to lookup (leave blank for current IP) | --- ## ๐Ÿ“ค Output Example ```json { "ip": "8.8.8.8", "success": true, "country": "United States", "city": "Mountain View", "region": "California", "latitude": 37.386, "longitude": -122.0838, "isp": "Google LLC" } ``` > Powered by [ipwho.is](https://ipwho.is) --- ## ๐Ÿงช Run Test ```bash node test.js ``` --- ## ๐Ÿชช License ``` MIT ```