Free Public API
Free, no-authentication JSON (and plain-text) API that returns the caller’s public IP address and reverse DNS hostname.
GET Base endpoint
https://directip.info/api/
# Full information (JSON) curl https://directip.info/api/ # Expanded information curl https://directip.info/api/?expanded=true # IPv4 only curl https://directip.info/api/?type=ipv4 # IPv6 only curl https://directip.info/api/?type=ipv6 # Plain text IP (ipify-style) curl https://directip.info/api/?format=text
| Parameter | Values | Description |
|---|---|---|
type |
all, ipv4, ipv6 |
Which address family to return |
format |
json, text |
Response format |
hostname |
1 or 0 |
Include reverse DNS lookup |
expanded |
true or 1 |
Return geo, ISP, ASN, city, coordinates, timezone |
Full response (?type=all)
{
"success": true,
"ipv4": "203.0.113.42",
"ipv6": null,
"hostname_v4": "customer.example.net",
"hostname_v6": null,
"user_agent": "curl/8.5.0",
"note": "A single request only reveals the protocol used to reach the server..."
}
Expanded response (?expanded=true)
{
"success": true,
"ip": "203.0.113.42",
"version": 4,
"hostname": "customer.example.net",
"city": "Austin",
"region": "Texas",
"region_code": "TX",
"country": "United States",
"country_code": "US",
"zip": "02108",
"lat": 42.3588,
"lon": -71.0638
"timezone": "America/Chicago",
"isp": "Charter Communications",
"org": "Spectrum",
"as": "AS11427 Charter Communications Inc",
"asname": "TWC-11427-TEXAS",
"mobile": false,
"proxy": false,
"hosting": false,
"user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36"
}
IPv4 only(?type=ipv4)
{
"success": true,
"ipv4": "203.0.113.42",
"hostname": "customer.example.net"
}
Plain text (?format=text)
203.0.113.42
Access-Control-Allow-Origin: *) so you can call the API from browsers.null.fetch('https://directip.info/api/')
.then(r => r.json())
.then(data => {
console.log('Your IP:', data.ipv4 || data.ipv6);
console.log('Hostname:', data.hostname_v4 || data.hostname_v6);
});
Questions or feedback? Use the Contact us button on the homepage.