Skip to content

eliot/wheresthatip-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wheresthatip

IP geolocation from the command line. Look up any IP address to get city, country, ISP, and coordinates.

$ wheresthatip

  IP            203.0.113.42
  City          San Francisco
  State         California
  Country       United States
  ISP           Comcast Cable Communications
  Coordinates   37.7749, -122.4194

  Details: https://www.wheresthatip.com/ip/203.0.113.42

Install

npm install -g wheresthatip

Usage

Show your public IP and location

wheresthatip

Look up any IP address

wheresthatip 8.8.8.8
wheresthatip 1.1.1.1

Output as JSON

wheresthatip --json
wheresthatip 8.8.8.8 --json
{
  "ip": "8.8.8.8",
  "city": "Mountain View",
  "state": "California",
  "country": "United States",
  "isp": "Google LLC",
  "latitude": 37.386,
  "longitude": -122.0838
}

Get just the IP (for scripting)

wheresthatip --raw
# 203.0.113.42

# Use in scripts:
MY_IP=$(wheresthatip --raw)

Use as a library

const { myip, lookup } = require('wheresthatip');

// Get your public IP
const ip = await myip();
console.log(ip); // "203.0.113.42"

// Look up any IP
const info = await lookup('8.8.8.8');
console.log(info.country); // "United States"
console.log(info.city);    // "Mountain View"
console.log(info.isp);     // "Google LLC"

API

myip()

Returns a Promise<string> with your public IP address.

lookup(ip)

Returns a Promise<Object> with geolocation data:

Field Type Description
ip string The IP address
city string City name
state string State/region name
country string Country name
isp string Internet Service Provider
latitude number Latitude coordinate
longitude number Longitude coordinate
postal string Postal/ZIP code

Options

Flag Description
-j, --json Output as JSON
-r, --raw Output IP address only
-h, --help Show help
-v, --version Show version

Powered by

WheresThatIP.com — Free IP geolocation, network tools, and privacy resources.

License

MIT

About

IP geolocation from the command line. Powered by WheresThatIP.com

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors