Free IP address API

Get your public IP address as plain text or JSON from any script, terminal or app. No API key, no sign-up, CORS enabled.

Plain text: /ip

Returns just your public IP address followed by a newline. Ideal for shell scripts.

$ curl whatsmyipnumber.com/ip
216.73.216.23

Tip: requesting the home page with curl, wget or HTTPie also returns plain text.

JSON with location: /json

Returns your IP address plus geolocation and network details.

$ curl whatsmyipnumber.com/json
{
  "ip": "203.0.113.42",
  "version": 4,
  "city": "Amsterdam",
  "region": "North Holland",
  "region_code": "NH",
  "country": "Netherlands",
  "country_code": "NL",
  "continent": "Europe",
  "postal": "1012",
  "latitude": 52.37,
  "longitude": 4.89,
  "timezone": "Europe/Amsterdam",
  "utc_offset": "+02:00",
  "asn": 64500,
  "org": "Example Networks B.V.",
  "isp": "Example Networks"
}

Look up a different address with ?ip=: curl "whatsmyipnumber.com/json?ip=8.8.8.8". Location fields are omitted for private or reserved addresses.

Code examples

Python

import requests
ip = requests.get("https://whatsmyipnumber.com/ip", timeout=5).text.strip()
info = requests.get("https://whatsmyipnumber.com/json", timeout=5).json()
print(ip, info.get("country"))

JavaScript (browser or Node.js 18+)

const res = await fetch("https://whatsmyipnumber.com/json");
const { ip, city, country } = await res.json();
console.log(`${ip} – ${city}, ${country}`);

PowerShell

(Invoke-RestMethod https://whatsmyipnumber.com/json).ip

wget

wget -qO- whatsmyipnumber.com/ip

Go

resp, _ := http.Get("https://whatsmyipnumber.com/ip")
body, _ := io.ReadAll(resp.Body)
fmt.Print(string(body))

Fair use

  • /ip has no practical limit for normal use.
  • /json is limited to about 45 requests per minute per IP address, because each lookup queries a geolocation database. Responses return HTTP 429 when the limit is exceeded.
  • Please cache results instead of polling every few seconds. For high-volume commercial use, contact us.

By using the API you agree to our terms of service.

Copied to clipboard