Public API • version 1

API documentation

The same data you see on the page is available through three simple endpoints: no API key, no sign-up and open CORS for browser use.

GET /api/ip

text/plain

The client IP as plain text, ideal for scripts and curl.

curl -s https://whatmyip.ir/api/ip
# 5.238.12.34

GET /api/ip.json

application/json

Only the IP and its version; the lightest JSON response.

{ "ip": "5.238.12.34", "version": 4 }

GET /api/json

application/json • full response

Approximate location, ASN, reverse DNS, VPN assessment, request headers and server time. Add ?lang=en to get assessment reasons in English.

{
  "ip": "5.238.12.34",
  "ipVersion": 4,
  "isPrivate": false,
  "isLoopback": false,
  "isCgnat": false,
  "ptr": "5-238-12-34.example.ir",
  "geo": {
    "countryCode": "IR",
    "countryName": "Iran",
    "city": "Tehran",
    "region": "Tehran",
    "latitude": 35.7563,
    "longitude": 51.3966,
    "timeZone": "Asia/Tehran",
    "asn": 58224,
    "asnOrganization": "Iran Telecommunication Company PJS"
  },
  "proxy": { "score": 0, "verdict": "unlikely", "reasons": ["No clear sign of a proxy or VPN was found"] },
  "timestampUtc": "2026-12-01T09:54:37.329+00:00",
  "timestampTehran": "2026-12-01 13:24:37",
  "timestampPersian": "1405/09/10 ساعت 13:24",
  "method": "GET",
  "scheme": "https",
  "host": "whatmyip.ir",
  "protocol": "HTTP/2",
  "localPort": 443,
  "userAgent": "Mozilla/5.0 …",
  "acceptLanguage": "en-US,en;q=0.9",
  "referer": "",
  "headers": [ { "name": "Accept", "value": "application/json" } ]
}

Rate limit

Fair and key-free

Per IP60 requests per minute
RejectionHTTP 429
Retry-After header60

For heavier usage, please get in touch before you start.

Technical notes

Read before using

  • CORS is open to all origins, so browser clients work directly.
  • Responses are Cache-Control: no-store; do not cache them yourself.
  • Behind a proxy or CDN, the IP you see is the exit IP of that hop.
  • Location data is approximate and not suitable for security decisions.
  • The /health path is for monitoring the service health.

Code samples

JavaScript and Python

// JavaScript
const res = await fetch("https://whatmyip.ir/api/json?lang=en");
const info = await res.json();
console.log(info.ip, info.geo?.city);

# Python
import requests
info = requests.get("https://whatmyip.ir/api/json?lang=en", timeout=5).json()
print(info["ip"], info.get("geo", {}).get("city"))