Public IP address API

Your public IP, in one command.

Get the address used by your current connection as plain text or JSON. IPv4 and IPv6 are available through the same domain or separate subdomains. No API key is needed.

Start with IPv4
curl -4 -L mypublicipnow.com

Use -6 for IPv6, or omit the flag to use whichever address family your connection selects. -L follows the redirect to HTTPS.

Your IP as plain text

These commands return one IP address followed by a newline. The root URL serves the homepage to browsers and plain text to curl after following the HTTPS redirect.

AutomaticIPv4 or IPv6
curl -L mypublicipnow.com
IPv4Force IPv4
curl -4 -L mypublicipnow.com
IPv6Force IPv6
curl -6 -L mypublicipnow.com

For software that sends an HTML Accept header, use /ip to always receive plain text.

Dedicated IPv4 and IPv6 hosts

Choose the subdomain for the address family you need.

https://v4.mypublicipnow.com/IPv4 only · plain text
https://v6.mypublicipnow.com/IPv6 only · plain text

IPv6 requires IPv6 connectivity.

Your IP as JSON

The JSON endpoint includes ASN, organization, location, coordinates, time zone, and links when those fields are known.

AutomaticCurrent connection
curl -L mypublicipnow.com/json
IPv4 JSONForce IPv4
curl -4 -L mypublicipnow.com/json
IPv6 JSONForce IPv6
curl -6 -L mypublicipnow.com/json

/api/ip returns the same JSON. You can also append /json to either family subdomain.

To look up a specific address, open /IP address in a browser, or request /api/lookup/IP address for JSON. Both IPv4 and IPv6 addresses are supported.

Live response · your current connectionOpen raw JSON ↗
Loading response…

Response fields

The response describes the caller's address. GeoIP fields are approximate and may be unavailable for some networks.

ipThe public address used for this request.
versionipv4 or ipv6.
asn · asn_urlAutonomous System Number and ASNBase link.
organization · organization_urlASN organization and its registration record.
company · company_sourceFor Chinese IPs, the ip2region ISP name and source when available. It may differ from the ASN organization.
country_code · flag_urlTwo-letter country code and SVG flag URL.
country · region · city · location_sourceApproximate location and its source: ip2region for Chinese IPs, otherwise MaxMind or DB-IP.
latitude · longitudeApproximate decimal coordinates, not a precise device position.
time_zoneIANA time zone for the approximate location.
accuracy_radius_kmEstimated radius of the location, in kilometers.

Unknown values may be null or omitted. Responses use Cache-Control: no-store and permit cross-origin requests.

Use it from code

Both examples read the current caller's JSON response.

JavaScript

const response = await fetch('https://mypublicipnow.com/json');
const info = await response.json();
console.log(info.ip, info.version);

Python

import json
from urllib.request import urlopen

with urlopen('https://mypublicipnow.com/json') as response:
    info = json.load(response)
print(info['ip'], info['version'])

This API reports the requester's own IP. It does not look up arbitrary addresses.