API 调用文档
接口一:纯真 IP 库(仅 IPv4)
接口地址
GET https://tools.wifilu.com/ip/api.php?ip=223.5.5.5
不指定 ip 参数时,自动返回访问者 IP 的归属地信息。
请求参数
| 参数 |
类型 |
必填 |
默认值 |
说明 |
ip |
string |
否 |
访问者 IP |
要查询的 IPv4 地址 |
返回示例
{
"code": 200,
"message": "success",
"data": {
"ip": "223.5.5.5",
"country": "中国",
"province": "浙江省",
"city": "杭州市",
"isp": "阿里巴巴anycast公共DNS"
}
}
字段说明
| 字段 |
说明 |
ip |
查询的 IP 地址 |
country |
国家/地区 |
province |
省份(中国境内带省/市/自治区后缀,境外可能为 null) |
city |
城市(中国境内带市后缀,境外可能为 null) |
isp |
运营商/组织 |
接口二:ip2region IP 库(IPv4 + IPv6)
接口地址
GET https://tools.wifilu.com/ip/ip2region.php?ip=223.5.5.5
依据 ip 的地址版本自动选用 IPv4 或 IPv6 数据库。不指定 ip 参数时,自动返回访问者 IP 的归属地信息。
请求参数
| 参数 |
类型 |
必填 |
默认值 |
说明 |
ip |
string |
否 |
访问者 IP |
要查询的 IPv4 或 IPv6 地址 |
返回示例
{
"code": 200,
"message": "success",
"data": {
"ip": "223.5.5.5",
"country": "中国",
"province": "浙江省",
"city": "杭州市",
"isp": "阿里",
"isoCode": "CN"
}
}
字段说明
| 字段 |
说明 |
ip |
查询的 IP 地址 |
country |
国家/地区(中国返回中文,境外返回英文) |
province |
省份(无数据时为 null) |
city |
城市(无数据时为 null) |
isp |
运营商/组织(无数据时为 null) |
isoCode |
国家两字母简称,如 CN、US(无数据时为 null) |
调用示例
curl "https://tools.wifilu.com/ip/api.php?ip=8.8.8.8"
curl "https://tools.wifilu.com/ip/ip2region.php?ip=240e:3b7:3272:d8d0:db09:c067:8d59:539e"
fetch('/ip/ip2region.php?ip=223.5.5.5')
.then(res => res.json())
.then(data => console.log(data.data.country));
状态码(两套接口一致)
| 状态码 |
说明 |
200 |
查询成功 |
400 |
IP 地址格式错误 |
500 |
服务器内部错误(如 IP 库文件不存在) |