API 调用文档
接口地址
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 |
运营商/组织 |
调用示例
curl "https://tools.wifilu.com/ip/api.php?ip=8.8.8.8"
fetch('/ip/api.php?ip=223.5.5.5')
.then(res => res.json())
.then(data => console.log(data.data.country));
状态码
| 状态码 |
说明 |
200 |
查询成功 |
400 |
IP 地址格式错误 |
500 |
服务器内部错误(如 IP 库文件不存在) |