接口地址
GET https://ip.eycit.com/api
免费、免鉴权、支持 CORS;数据在服务端本地离线查询,响应通常在 1 毫秒级
curl "https://ip.eycit.com/api?ip=114.114.114.114"
{
"ip": "114.114.114.114",
"region": "中国|江苏省|南京市|0|CN",
"data": {
"country": "中国",
"province": "江苏省",
"city": "南京市",
"isp": "",
"code": "CN"
},
"version": 4,
"scope": "公网地址",
"int": "1920103026"
}
| 字段 | 类型 | 说明 |
|---|---|---|
| ip | string | 查询的 IP 地址 |
| region | string | 原始串:国家|省|市|运营商|国家代码 |
| data.country | string | 国家或地区 |
| data.province | string | 省份(国外地址可能为空) |
| data.city | string | 城市 |
| data.isp | string | 运营商,未收录时为空串 |
| data.code | string | ISO 3166-1 两位国家代码 |
| version | int | 4 或 6 |
| scope | string | 公网地址 / 内网保留地址 |
| int | string | IPv4 的整数形式,IPv6 返回 — |
HTTP/1.1 400 Bad Request
{"error": "无效的 IP 地址", "ip": "notanip"}
const res = await fetch('https://ip.eycit.com/api?ip=8.8.8.8');
const { data } = await res.json();
console.log(data.country, data.city, data.isp);
$json = file_get_contents('https://ip.eycit.com/api?ip=' . urlencode($ip));
$obj = json_decode($json, true);
echo $obj['data']['country'] ?? '未知';
import requests
r = requests.get('https://ip.eycit.com/api', params={'ip': '223.5.5.5'}, timeout=5)
print(r.json()['data'])
GET https://ip.eycit.com/health
{"status":"ok","service":"ip2region-php","php":"8.1.29"}
本接口为公益服务,未做频率限制,请勿用于爬取全量 IP 或高频轰炸;如需大规模调用, 建议直接部署开源项目 ip2region 到自己的服务器,性能更好且不受网络限制。接口返回结果仅供学习与一般参考,不作为法律依据。