API 接口文档
简单易用的IP地址查询API接口
IP查询接口
GET
/api/lookup
请求参数
ip
string
要查询的IP地址(可选,不提供则查询客户端IP)
请求示例
curl
# 查询指定IP
curl "https://your-domain.com/api/lookup?ip=8.8.8.8"
# 查询客户端IP
curl "https://your-domain.com/api/lookup"
JavaScript
fetch('/api/lookup?ip=8.8.8.8')
.then(response => response.json())
.then(data => console.log(data));
PHP
$response = file_get_contents('/api/lookup?ip=8.8.8.8');
$data = json_decode($response, true);
print_r($data);
响应格式
JSON
{
"ip": "8.8.8.8",
"type": "ipv4",
"hostname": "dns.google",
"location": "美国 加利福尼亚",
"isp": "Google LLC",
"asn": "AS15169",
"asn_org": "Google LLC"
}
响应字段说明
ip
string
查询的IP地址
type
string
IP类型:ipv4 或 ipv6
hostname
string
反向解析的主机名
location
string
地理位置信息
isp
string
互联网服务提供商
asn
string
自治系统号码
asn_org
string
ASN组织名称
错误响应
错误示例
{
"error": "Invalid IP address",
"ip": "invalid.ip.address"
}
使用限制
- 目前无访问频率限制
- 支持IPv4和IPv6地址查询
- 无需API密钥
- 支持跨域访问(CORS)