IP address API and command-line endpoints
Get your public IP address from a script, a shell or a cron job: plain text for curl, JSON with the details, and IPv4-only and IPv6-only hosts when you need a specific family. No key, no account, 600 requests per minute per address.
Quick start: get your IP with curl
curl checkmyip.com/raw
203.0.113.42That is the whole API for most uses: one request, the address, a newline. curl -4 and curl -6 force a family; curl checkmyip.com/json returns the details below. Any client that sends Accept: text/plain or a command-line User-Agent gets the bare address from /raw; browsers get the human page.
$ curl checkmyip.com
216.73.216.52
$ curl -H "Accept: text/plain" https://checkmyip.com/
216.73.216.52 Endpoints
| Endpoint | Returns | Notes |
|---|---|---|
GET https://checkmyip.com/raw | your IP as plain text with a trailing newline | also GET / with a curl/wget/PowerShell User-Agent |
GET https://checkmyip.com/ip · /ip.txt | the same plain-text address (aliases for scripts that expect those paths) | Cache-Control: no-store |
GET https://checkmyip.com/json | JSON: ip, version, geo, network, type, risk summary (fields below) | Cache-Control: private, no-store |
GET https://checkmyip.com/json?ip=203.0.113.42 | the same JSON for any public address | same 600/min limit |
GET https://ipv4.checkmyip.com/ip | {ip, family: 4, …} over IPv4 only | fails if you have no IPv4 path |
GET https://ipv6.checkmyip.com/ip | {ip, family: 6, …} over IPv6 only | fails if you have no IPv6 path |
GET https://ds.checkmyip.com/ip | the family your client prefers when both work | ?format=text for bare output |
All endpoints answer over HTTPS with CORS enabled for read-only use, send Cache-Control: no-store, and are marked noindex for search engines. Results for other addresses are cached for ten minutes.
https://checkmyip.com/rawhttps://checkmyip.com/iphttps://checkmyip.com/ip.txthttps://checkmyip.com/https://checkmyip.com/jsonhttps://checkmyip.com/json?ip=203.0.113.9All of them send Cache-Control: private, no-store, Access-Control-Allow-Origin: * and X-Robots-Tag: noindex; no api key needed.
JSON response fields
ip — the address as a string. version — 4 or 6. geo.consensus — country (ISO 3166-1 alpha-2), region, city, lat, lon, timezone, confidence (0–1), disagreement (boolean), anycast (boolean); geo.sources[] — each database's answer with updated, licence and attribution. network — asn, as_name, as_org, prefix, rir, allocation_date, registry_country, abuse_contacts[]. hostname — the PTR name or null. type.type — residential, mobile, business, datacenter or unknown, with confidence and reasons[]. risk — is_proxy, is_vpn, is_tor, is_datacenter, is_relay, score (0–100), level, reasons[], blacklists[] and score_version. A missing value is null with the reason in status or note; heuristic verdicts say so. The attribution strings must be displayed if you show the geolocation data to users (CC BY 4.0 / CC BY-SA 4.0 conditions).
Two fields are additive on top of the list above: schema_version (the lookup service's response schema, 1.1 today; fields are only ever added) and geo.agreement — the per-field tally behind the consensus (country_sources, country_source_ids, city_sources, city_source_ids, the disagreeing ids and a one-line summary such as “country confirmed by 3 sources, city from 2”). network.origins[] lists every ASN that originates the address (asn, as_name, as_org, named_by[], primary; network.multi_origin is true when there is more than one and network.note says which was chosen as primary). risk.factors[] carries the score arithmetic (id, label, points, source; sum = score before the cap at 100) and risk.reasons[] the same signals as full sentences. A tied city vote sets geo.consensus.city to null and lists the options in geo.consensus.city_candidates[]; geo.consensus.tie_break says what rule applied. hosted_domains (full lookups only) is the IP2WHOIS hosted-domain block: status (ok, cached, budget_exhausted with retry_after, no-data, skipped on fast answers), total_domains, domains[] (a sample — the free plan returns one name per page), page/total_pages and the attribution string, which must be shown with the names. Own-address answers also carry colo (the Cloudflare data centre that served you) and cache (live or edge ≤10 min).
Code examples
Each example prints the public address of the machine it runs on.
curl
curl -s https://checkmyip.com/raw
curl -s -4 https://checkmyip.com/raw # IPv4 only
curl -s -6 https://checkmyip.com/raw # IPv6 only
curl -s https://checkmyip.com/json | jq .geo.consensus.countrywget
wget -qO- https://checkmyip.com/rawPowerShell
(Invoke-WebRequest -Uri https://checkmyip.com/raw -UseBasicParsing).Content.Trim()
(Invoke-RestMethod -Uri https://checkmyip.com/json).network.asnPython
import urllib.request
ip = urllib.request.urlopen("https://checkmyip.com/raw", timeout=5).read().decode().strip()
print(ip)JavaScript (fetch)
const r = await fetch("https://checkmyip.com/json", { cache: "no-store" });
const { ip, geo } = await r.json();
console.log(ip, geo.consensus.country);Go
resp, err := http.Get("https://checkmyip.com/raw")
if err != nil { log.Fatal(err) }
defer resp.Body.Close()
b, _ := io.ReadAll(resp.Body)
fmt.Println(strings.TrimSpace(string(b)))Bash scripts and cron
#!/bin/sh
# notify when the public IP changes (run from cron every 5 minutes)
new=$(curl -fsS --max-time 5 https://checkmyip.com/raw) || exit 0
old=$(cat /var/tmp/public-ip 2>/dev/null)
[ "$new" != "$old" ] && { echo "$new" > /var/tmp/public-ip; logger "public IP changed: $old -> $new"; }Use --max-time, treat a failure as unknown rather than changed, and poll no more often than once a minute.
Rate limits and fair use
/raw, /ip, /ip.txt, /json, /json?ip= and the family-specific /ip hosts allow 600 requests per minute per address; the port checker allows 20 per minute and only ever tests the caller's own address. Exceeding a limit returns HTTP 429 with a JSON error body. The endpoints are free for personal, internal and commercial use within these limits; if you expect sustained volume above them, or want to embed our data in a product, tell us first through the contact page. Please do not use the human pages from scripts — they are heavier and slower than the endpoints above.
Uptime and status
The endpoints run on the same edge network as the site and are monitored continuously; the /healthz endpoint of our test server reports its version and uptime. A public status page is planned. Changes to the response format are announced on this page in advance; existing fields are never renamed, only added.
Frequently asked questions
Is there a free IP API available?
Yes. The endpoints on this page return your public address as plain text or JSON without a key or account, within the rate limits above, and /json?ip= returns the same JSON for any public address. The IP address lookup page shows the same data for people.
Are IP grabbers illegal?
An "IP grabber" is a link or image that records the address of whoever opens it. Logging the address of a visitor to your own site is legal and routine; tricking someone into revealing it in order to harass, locate or attack them is where the law gets involved. Our endpoints only return the address of the client that calls them.
Does API have an IP address?
Every server that answers an API has an IP address, including ours. The question usually behind this one — "can a program learn its own public address?" — is what these endpoints are for: the program asks us, and we reply with the address we saw the request come from.
What is my IP address API?
It is a web endpoint that answers with the address of whoever calls it. https://checkmyip.com/raw returns it as text and https://checkmyip.com/json with the location, network and risk details, documented above.
What does curl ifconfig me do?
ifconfig.me is another site that returns the caller's address when fetched with curl. curl checkmyip.com/raw does the same here; the JSON endpoint additionally gives you the network and location fields.
How can I find my IP address using curl?
Run curl -s https://checkmyip.com/raw in any terminal with internet access. Add -4 or -6 to force IPv4 or IPv6. The output is the address followed by a newline, which makes it safe to use in scripts.
Is ifconfig.me safe?
We cannot vouch for other services. For ours: requests are answered without storing your address, the response is served over HTTPS, and the privacy policy applies to the endpoints exactly as to the pages.