API 文档
强大的 IP 查询接口,支持多数据源并行查询
快速开始
最简单的使用方式,一行代码即可查询 IP 信息
GET https://ip.jszsl.top/api/ip?ip=8.8.8.8接口地址
RESTful API 设计,简单易用
GET
/api/ip查询指定 IP 地址的地理位置和网络信息
请求参数
Query String 参数说明
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
ip | String | 是 | 要查询的 IP 地址(支持 IPv4 和 IPv6) |
示例: ?ip=8.8.8.8 或 ?ip=2001:db8::1
响应格式
JSON 格式返回,包含详细的数据源信息
{
"success": true,
"data": {
"ip": "8.8.8.8",
"city": "Mountain View",
"region": "California",
"country": "United States",
"postal": "94035",
"latitude": 37.386,
"longitude": -122.0838,
"timezone": "America/Los_Angeles",
"isp": "Google LLC",
"asn": "AS15169",
"source": "ip-api.com"
},
"allSources": [
{ /* 数据源1 */ },
{ /* 数据源2 */ },
// ... 更多数据源
],
"debug": {
"totalSources": 6,
"successfulSources": 3,
"failedSources": 3,
"sources": [
{
"source": "ip-api.com",
"status": "success",
"responseTime": 245
}
// ... 其他数据源状态
]
}
}响应字段说明
data 对象中的字段详细说明
| 字段名 | 类型 | 说明 |
|---|---|---|
ip | String | IP 地址 |
city | String | 城市名称 |
region | String | 地区/省份 |
country | String | 国家名称 |
postal | String | 邮政编码 |
latitude | Number | 纬度坐标(可选) |
longitude | Number | 经度坐标(可选) |
timezone | String | 时区 |
isp | String | 互联网服务提供商 |
asn | String | 自治系统编号 |
source | String | 数据来源 |
代码示例
多种编程语言的调用示例
JSJavaScript / Fetch API
async function queryIP(ip) {
const response = await fetch(`/api/ip?ip=${ip}`);
const data = await response.json();
if (data.success) {
console.log('城市:', data.data.city);
console.log('ISP:', data.data.isp);
}
}PYPython / Requests
import requests
def query_ip(ip):
response = requests.get(f'/api/ip?ip={ip}')
data = response.json()
if data['success']:
print(f"城市: {data['data']['city']}")
print(f"ISP: {data['data']['isp']}")CLIcURL
curl "https://ip.jszsl.top/api/ip?ip=8.8.8.8"
速率限制
保护 API 稳定性的限流策略
限制规则
- 每分钟最多 10 次请求
- 基于客户端 IP 地址限制
超限响应
HTTP 429 Too Many Requests
{
"error": "请求过于频繁,请稍后再试",
"retryAfter": 45
}错误码
常见错误及解决方案
400
Bad Request
缺少 IP 参数或 IP 格式无效
解决方案: 检查请求参数,确保提供有效的 IP 地址
429
Too Many Requests
请求频率超过限制
解决方案: 等待一段时间后重试,或降低请求频率
500
Internal Server Error
服务器内部错误
解决方案: 稍后重试,如持续出现请联系管理员
数据源
并行查询多个权威数据源,确保准确性
ip-api.com
免费无需配置
ipapi.co
免费无需配置
ipinfo.io
免费无需配置
ipdata.co
免费需要 API Key
abstractapi.com
免费需要 API Key
ipregistry.co
免费需要 API Key
核心特性
为什么选择我们的 IP 查询 API
🔄
多数据源并行
同时查询 6 个权威数据源,自动选择最优结果
⚡
智能缓存
内置缓存机制,相同 IP 重复查询秒级响应
🔍
完整调试信息
提供每个数据源的详细状态和响应时间
📊
数据对比
返回所有数据源的结果,方便交叉验证
🛡️
速率限制保护
防止滥用,保障服务稳定性
🌐
IPv4/IPv6 支持
全面支持两种 IP 协议版本
如有问题或建议,欢迎通过 博客 联系我们