免费公共IP API,无需身份验证。四个端点返回IPv4、IPv6、ISP、ASN、地理位置和时区——JSON或文本格式。
# Full data (JSON) https://ippubblico.org/?api=1 # IPv4 + IPv6 (plain text, 2 lines) https://ippubblico.org/?text=1 # IPv4 only https://ipv4.ippubblico.org/ # IPv6 only https://ipv6.ippubblico.org/
返回包含调用者IP地址所有可用数据的完整JSON对象。
curl https://ippubblico.org/?api=1
{
"status": "ok",
"ip": "93.45.12.88",
"ipv4": "93.45.12.88",
"ipv6": null,
"isp": "Telecom Italia S.p.A.",
"asn": "AS3269",
"timezone": "Europe/Rome",
"datetime": "2026-05-05T12:00:00+02:00",
"geo": {
"city": "Rome",
"region": "Lazio",
"country": "Italy",
"lat": 41.9028,
"lon": 12.4964
},
"headers": { /* HTTP request headers */ },
"cached": false,
"lang": "en"
}
| 字段 | 类型 | 描述 |
|---|---|---|
| status | string | "ok"或"partial"(地理位置失败时) |
| ip | string | 检测到的IP(可能是IPv4或IPv6) |
| ipv4 | string | null | IPv4地址(如可用) |
| ipv6 | string | null | IPv6地址(如可用) |
| isp | string | null | 互联网服务提供商名称 |
| asn | string | null | 自治系统编号(如"AS3269") |
| timezone | string | null | IANA时区(如"Europe/Rome") |
| datetime | string | 调用者时区的ISO 8601日期/时间 |
| geo.city | string | null | 近似城市名称 |
| geo.region | string | null | 地区/省份 |
| geo.country | string | null | 国家名称 |
| geo.lat / geo.lon | float | null | 近似坐标 |
| cached | boolean | 如果结果来自1小时缓存则为true |
在两行中分别返回IPv4和IPv6。如果协议不可用则返回NONE。
curl https://ippubblico.org/?text=1
IPv4: 93.45.12.88 IPv6: NONE
以纯文本形式仅返回IPv4地址,如不可用则返回NONE。
curl https://ipv4.ippubblico.org/
93.45.12.88
以纯文本形式仅返回IPv6地址,如不可用则返回NONE。
curl https://ipv6.ippubblico.org/
2001:db8::1
# 获取完整JSON curl https://ippubblico.org/?api=1 # 仅获取IPv4 MY_IP=$(curl -s https://ipv4.ippubblico.org/) echo "My IPv4: $MY_IP" # 仅获取IPv6 MY_IPV6=$(curl -s https://ipv6.ippubblico.org/) echo "My IPv6: $MY_IPV6"
// Full JSON const res = await fetch('https://ippubblico.org/?api=1'); const data = await res.json(); console.log(data.ipv4, data.ipv6, data.geo.country); // IPv4 only const ipv4 = await fetch('https://ipv4.ippubblico.org/').then(r => r.text()); console.log('IPv4:', ipv4);
import requests # Full JSON data = requests.get('https://ippubblico.org/?api=1').json() print(data['ipv4'], data['geo']['country']) # IPv4 only ipv4 = requests.get('https://ipv4.ippubblico.org/').text.strip() print(f'IPv4: {ipv4}')
// Full JSON $data = json_decode(file_get_contents('https://ippubblico.org/?api=1'), true); echo $data['ipv4']; // IPv4 only $ipv4 = trim(file_get_contents('https://ipv4.ippubblico.org/'));
resp, _ := http.Get("https://ipv4.ippubblico.org/") body, _ := io.ReadAll(resp.Body) fmt.Println("IPv4:", strings.TrimSpace(string(body)))
$ip = (Invoke-WebRequest 'https://ipv4.ippubblico.org/').Content.Trim() Write-Host "IPv4: $ip"
require 'open-uri' ipv4 = URI.open('https://ipv4.ippubblico.org/').read.strip puts "IPv4: #{ipv4}"
var client = new HttpClient(); var ipv4 = (await client.GetStringAsync("https://ipv4.ippubblico.org/")).Trim(); Console.WriteLine($"IPv4: {ipv4}");
ipv4.ippubblico.org通过DNS A记录强制IPv4连接ipv6.ippubblico.org通过DNS AAAA记录强制IPv6连接完整网站提供43种语言版本。API本身与语言无关。