IP API

Get Your IP From the Command Line

Run curl https://myipspot.com/ip and it prints your public IP address. Two free endpoints: plain text for scripts, JSON for apps. No key, no signup.

Plain text: /ip

Returns your public IP address and a newline, nothing else. Ideal for the command line and shell scripts.

curl
curl https://myipspot.com/ip
curl, forcing IPv4 or IPv6
curl -4 https://myipspot.com/ip
curl -6 https://myipspot.com/ip
wget
wget -qO- https://myipspot.com/ip
PowerShell
(Invoke-RestMethod https://myipspot.com/ip).Trim()
Python (standard library only)
from urllib.request import urlopen
print(urlopen("https://myipspot.com/ip").read().decode().strip())
JavaScript (browser or Node 18+)
const ip = (await (await fetch("https://myipspot.com/ip")).text()).trim();
Bash: tell me when my IP changes
ip=$(curl -fsS https://myipspot.com/ip) && [ "$ip" != "$(cat ~/.last_ip 2>/dev/null)" ] && echo "$ip" > ~/.last_ip && echo "IP changed to $ip"

The response is text/plain, for example 203.0.113.42 followed by a newline. curl -6 only works if your connection has IPv6.

JSON: /api/ip

The same lookup our homepage uses, with approximate location and network details.

Request
curl https://myipspot.com/api/ip
Example response
{
  "ip": "203.0.113.42",
  "ipVersion": 4,
  "city": "Lahore",
  "region": "Punjab",
  "country": "PK",
  "latitude": "31.55",
  "longitude": "74.34",
  "timezone": "Asia/Karachi",
  "asn": 64500,
  "isp": "Example ISP"
}
FieldTypeMeaning
ipstringYour public IPv4 or IPv6 address.
ipVersion4 or 6Which protocol this request used.
citystring or nullApproximate city.
regionstring or nullState, province or region.
countrystring or nullTwo-letter ISO 3166-1 code. XX means unknown and T1 means the Tor network.
latitudestring or nullApproximate latitude, as a string such as "31.55".
longitudestring or nullApproximate longitude, as a string.
timezonestring or nullIANA timezone name, such as "Asia/Karachi".
asnnumber or nullNetwork number (ASN) of your provider, without the "AS" prefix.
ispstring or nullName of the organisation that owns the network.

Any field except ip and ipVersion can be null when Cloudflare has no value for it.

Which address you get

Both endpoints return the address your request came from. Behind a VPN or proxy, that's the server's address, not yours. On a network with both IPv4 and IPv6, it's whichever one your tool chose for this request, so an IPv4 answer doesn't prove you lack IPv6. Run it from a server and you get the server's outgoing address.

Fair use

Both endpoints are free, with no key and no signup. Requests are rate limited per IP address, and there are no guarantees about availability, so handle errors in anything that depends on them. We don't log or store the addresses.

Both send Access-Control-Allow-Origin: *, so you can call them with fetch() from any website. Keep requests simple: custom request headers trigger a CORS preflight, which isn't supported.

Using it in a public project? A link back to myipspot.com is appreciated.

Frequently asked questions

Run curl https://myipspot.com/ip. It prints your public IP address and a newline, nothing else. Add -4 or -6 to choose IPv4 or IPv6. Keep the https:// part: a plain http:// address answers with a redirect, which curl only follows if you add -L.

More network tools