Home / Developers
Free IP API: your public IP from the command line
Every tool on this site is backed by a plain HTTP endpoint you can call from a script. No key, no sign-up and no ads, and ipcomet's own code never stores the addresses it sees.
The one-line answer
Ask for the home page from a terminal and you get your public IP address, and nothing else:
curl ipcomet.comThe output is a single line, such as 203.0.113.7. The home page returns plain text when it recognises a command-line client (curl, wget, PowerShell, Python, Node and the like) by its User-Agent, and the full web page to everyone else. In a script, prefer /api/ip: it always returns plain text, whatever asks for it.
Endpoints
Every endpoint is a GET request over HTTPS to https://ipcomet.com, needs no key and answers in UTF-8. Errors come back as JSON — {"error": "…"} — with a matching HTTP status.
| GET / | Your public IP address as one line of plain text, for curl, wget, PowerShell and similar clients. Browsers get the web page instead. Limit: no fixed limit. |
|---|---|
| GET /api/ip | The same bare IP address as plain text, whatever asks for it. Use this one in scripts. Limit: no fixed limit. |
| GET /api/me | Everything about the connection that made the request, as JSON: address, IP version, approximate location, timezone, ASN, network owner and connection details. Limit: no fixed limit. |
| GET /api/lookup?q= | Location, network owner, ASN and hostname of any IP address or domain. Limit: 60 a minute. |
| GET /api/dns?name= | DNS records for a domain (A, AAAA, CNAME, MX, NS, TXT, SOA, CAA), or the PTR record of an IP address. Limit: 60 a minute. |
| GET /api/whois?q= | Registration details for a domain or an IP range, from RDAP. Limit: 60 a minute. |
| GET /api/reputation?q= | Whether an address is a Tor exit, what kind of network owns it, and whether it is on public spam blocklists. Limit: 60 a minute. |
| GET /api/port?port= | Whether a TCP port is reachable on the address you are calling from. It cannot be aimed anywhere else. Limit: 10 a minute. |
| GET /api/ping | An empty 204 response for timing a round trip, with the Cloudflare data center that answered in the x-colo header. Limit: no fixed limit. |
Only /api/ip and /api/me send Access-Control-Allow-Origin: *, so those two are the ones you can also call from a web page in the browser. The rest are meant for command-line and server-side use. Answers are sent with Cache-Control: no-store, except the lookup, reputation and WHOIS replies, which allow private caching for one to five minutes.
Get your public IP address
The same request in the tools you are most likely to reach for. Each one prints one line.
curl
curl https://ipcomet.com/api/ipwget
wget -qO- https://ipcomet.com/api/ipmacOS ships curl but not wget; most Linux distributions ship both.
PowerShell
(Invoke-RestMethod https://ipcomet.com/api/ip).Trim()Windows 10 and 11 also include curl, but write curl.exe in PowerShell, where curl can be an alias for Invoke-WebRequest.
Python (requests)
import requests
r = requests.get("https://ipcomet.com/api/ip", timeout=10)
print(r.text.strip())With the standard library instead, set a User-Agent of your own. Python's default (Python-urllib) is turned away by the bot protection in front of this site, which answers 403.
Node.js (fetch)
const res = await fetch("https://ipcomet.com/api/ip");
const ip = (await res.text()).trim();
console.log(ip);No dependency needed: fetch is built into Node.js 18 and later, and the endpoint allows cross-origin requests, so the same two lines work in a browser page.
A shell one-liner for scripts
MYIP=$(curl -fsS --max-time 10 https://ipcomet.com/api/ip)
echo "$MYIP"-f makes curl exit non-zero on an HTTP error instead of assigning the error body to the variable, -sS hides the progress meter but keeps real errors, and --max-time stops a stalled call from hanging a cron job. To act only when the address has changed, compare it with the last one you stored:
MYIP=$(curl -fsS --max-time 10 https://ipcomet.com/api/ip)
if [ "$MYIP" != "$(cat ~/.myip 2>/dev/null)" ]; then
echo "Address changed to $MYIP"
printf '%s' "$MYIP" > ~/.myip
fiYour address, location and network as JSON
curl https://ipcomet.com/api/meThe reply describes the connection that made the request. With made-up values:
{
"ip": "203.0.113.7",
"version": 4,
"city": "Mumbai",
"region": "Maharashtra",
"country": "India",
"countryCode": "IN",
"postal": "400001",
"timezone": "Asia/Kolkata",
"latitude": 19.076,
"longitude": 72.8777,
"asn": 64500,
"org": "Example Broadband Ltd",
"edge": "BOM",
"protocol": "HTTP/2",
"tls": "TLSv1.3 · AEAD-AES128-GCM-SHA256",
"rttMs": 24
}A field that cannot be determined for your connection is left out rather than set to null, so check that a key is there before using it. To pull out one value, pipe the reply through jq:
curl -s https://ipcomet.com/api/me | jq -r .countryThe location is an estimate drawn from network records, not GPS, and it often points at your provider's nearest hub instead of your town. The About page explains where each field comes from and how far to trust it.
Look up any address or domain
These endpoints take a query string and return JSON. They call out to DNS resolvers, registries and blocklists, so they carry the tighter limits in the table above.
IP or domain lookup
curl "https://ipcomet.com/api/lookup?q=8.8.8.8"
curl "https://ipcomet.com/api/lookup?q=example.com"A domain is resolved to its first A or AAAA record and that address is looked up, and the reply then carries resolvedFrom. It also carries hostname when the address has a reverse DNS record. As with /api/me, a field that cannot be determined is left out rather than set to null.
DNS records
curl "https://ipcomet.com/api/dns?name=example.com&type=MX"
curl "https://ipcomet.com/api/dns?name=example.com&resolver=google"
curl "https://ipcomet.com/api/dns?name=8.8.8.8"type accepts A, AAAA, CNAME, MX, NS, TXT, SOA and CAA; leave it out and all eight are fetched at once, grouped by type in a records object. resolver is cloudflare by default or google. Pass an IP address as name and you get its PTR record instead.
WHOIS and registration
curl "https://ipcomet.com/api/whois?q=example.com"
curl "https://ipcomet.com/api/whois?q=8.8.8.8"Answers come from RDAP, the modern replacement for the WHOIS protocol. A domain reply carries the registrar, status, dates, nameservers and DNSSEC state; an IP reply carries the range, CIDR, owner and parent allocation.
Reputation and blocklists
curl "https://ipcomet.com/api/reputation?q=203.0.113.7"
curl https://ipcomet.com/api/reputationLeave q off and your own address is checked. The reply says whether the address is a published Tor exit node, what kind of network owns it, and how it fares on five public blocklists. The network classification is a heuristic, not proof, and the blocklist checks cover IPv4 only.
Open port check
curl "https://ipcomet.com/api/port?port=443"The check connects back to the address you are calling from, so it can only ever test your own connection, never someone else's host. state is open, closed or filtered. Port 25 cannot be tested from Cloudflare Workers and is refused.
Round-trip timing
curl -s -o /dev/null -w "%{time_total}s\n" https://ipcomet.com/api/pingAn empty 204 reply, as cheap to answer as it gets. The x-colo response header names the Cloudflare data center that handled it.
Rate limits and fair use
Limits are counted per calling IP address over a rolling minute, and the groups are counted separately from one another:
- 60 a minute for
/api/lookup,/api/dns,/api/whoisand/api/reputation. - 10 a minute for
/api/port, which opens a real TCP connection on every call. - No fixed limit on
/,/api/ip,/api/meand/api/ping, which are answered from the request itself without contacting anything else.
Going over a limit returns HTTP 429 and {"error": "Too many requests. Please wait a minute and try again."}. Wait a minute and carry on; nothing else happens to you.
“No fixed limit” is not an invitation to hammer it. Cloudflare's abuse protection sits in front of the whole site and can throttle or block traffic that looks automated at scale, so cache the answer instead of asking on every request — a home connection's public address rarely changes more than a few times a day. The speed test and proxy checker have endpoints of their own, but they are built around the browser tools here rather than around scripts, so they are undocumented and may change.
Privacy
There is no key, no account and no advertising. Your IP address is read from the incoming request, used to build the answer and then gone: ipcomet's own code does not write it to a database, a log or any other storage, and never sells or shares it. Cloudflare handles every request as the hosting provider under its own privacy policy, and the rate limiter uses your address only to count your recent requests.
The API endpoints load no analytics at all. On the pages of this site, analytics loads only if you accept it in the banner, and never otherwise. The privacy page sets out that choice and lists every third-party service each tool contacts.
Prefer the walkthrough?
The guide covers the same commands on macOS, Linux and Windows, how to force IPv4 or IPv6, and the other free services you will see recommended.
Get your public IP from the command line Check my IP in the browser