Icanhazip API

⭐ Beginner's Pick Development / No Auth Required Beginner HTTPS CORS
Free to Use Varies (check documentation)

Overview

Icanhazip returns your public IP address as a plain text string with no authentication, parsing, or configuration needed. It is one of the oldest and most widely used IP detection services, commonly embedded in shell scripts and network configuration tools. Both IPv4 (icanhazip.com) and IPv6 (ipv6.icanhazip.com) variants are available.

💡

Beginner Tip

Just curl the URL and you get your IP address back as plain text — it is that simple. This is an ideal first API call for anyone new to curl or HTTP. Use it in shell scripts with MY_IP=$(curl -s https://icanhazip.com) to capture your current public IP into a variable.

Available Data

IP address information
geographic location
ASN and ISP data
Use case: Integrate ip address api data into web and mobile applications

Example Response

JSON Response
{
  "status": "success",
  "data": {
    "result": "Data from Icanhazip",
    "description": "IP Address API",
    "timestamp": "2025-01-15T10:00:00Z"
  }
}

Field Reference

(plain text body) Your public IP address as a plain text string, either IPv4 or IPv6 depending on your network stack.

Implementation Example

const url = "https://major.io/icanhazip-com-faq/";
const response = await fetch(url);
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();
console.log(data);

What Can You Build?

Note: These code examples are AI-generated and unverified. Always refer to the official API documentation for accurate usage.

Common Errors & Troubleshooting

Returns IPv6 address unexpectedly Your machine prefers IPv6 and the resolver returns AAAA records
Use curl -4 https://icanhazip.com to force IPv4, or use https://ipv4.icanhazip.com explicitly.
Trailing newline in response The API appends a newline character after the IP
Trim the response: in bash use $(curl -s https://icanhazip.com | tr -d newline).
429 rate limit Too many requests from the same IP in a short time
Add delays between requests; for high-frequency use consider ipify.org which has a more generous rate limit.

Matrix Score Breakdown

🌐 Reachability 30/30
⚡ Speed 15/20
🔒 Security 15/15
🛠 Developer XP 20/20
✓ Reliability 7/15
Response Time 244ms

Fully tested on Apr 5, 2026

Technical Specifications

Auth No Auth
HTTPS REQUIRED
CORS YES
Category Development
Difficulty Beginner
Verified: 2026-04-04

Similar APIs

View All →