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
Public API • version 1
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.
text/plain
The client IP as plain text, ideal for scripts and curl.
curl -s https://whatmyip.ir/api/ip
# 5.238.12.34
application/json
Only the IP and its version; the lightest JSON response.
{ "ip": "5.238.12.34", "version": 4 }
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" } ]
}
Fair and key-free
For heavier usage, please get in touch before you start.
Read before using
Cache-Control: no-store; do not cache them yourself./health path is for monitoring the service health.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"))