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
Markdown
# ๐ 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
```