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 https://myipspot.com/ip curl -4 https://myipspot.com/ip
curl -6 https://myipspot.com/ip wget -qO- https://myipspot.com/ip (Invoke-RestMethod https://myipspot.com/ip).Trim() from urllib.request import urlopen
print(urlopen("https://myipspot.com/ip").read().decode().strip()) const ip = (await (await fetch("https://myipspot.com/ip")).text()).trim(); 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.
curl https://myipspot.com/api/ip {
"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"
} | Field | Type | Meaning |
|---|---|---|
ip | string | Your public IPv4 or IPv6 address. |
ipVersion | 4 or 6 | Which protocol this request used. |
city | string or null | Approximate city. |
region | string or null | State, province or region. |
country | string or null | Two-letter ISO 3166-1 code. XX means unknown and T1 means the Tor network. |
latitude | string or null | Approximate latitude, as a string such as "31.55". |
longitude | string or null | Approximate longitude, as a string. |
timezone | string or null | IANA timezone name, such as "Asia/Karachi". |
asn | number or null | Network number (ASN) of your provider, without the "AS" prefix. |
isp | string or null | Name 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.