API
基础地址 https://ip.isking.cc · 返回 application/json; charset=utf-8
端点
9 个| 方法 | 路径 | 说明 |
|---|---|---|
| GET | /api/ip/{ip} | 归属地查询(国家/省/市/ISP/ISO2 + PTR) |
| GET | /api/query?ip= | 完整判定(检查项 + 评分 + 风险) |
| POST | /api/assess | 合并浏览器特征后重新判定 |
| GET | /api/export?format= | 导出单次报告(json / csv) |
| GET | /api/history | 查询历史与统计 |
| DELETE | /api/history | 清空查询历史 |
| GET | /api/db | 本地库信息与样例查询 |
| GET | /api/health | 库可用性自检(可接监控) |
| GET | /api/whoami | 调试:回显请求头与实际采用的客户端地址 |
GET /api/ip/{ip}
归属地查询
查询单个 IPv4 地址的国家 / 省份 / 城市 / ISP / ISO2,并附带一次 PTR 反查。
也支持查询参数形式:/api/ip?ip=8.8.8.8、/api/ip?q=8.8.8.8。
响应
{
"ok": true,
"ip": "114.114.114.114",
"scope": { "kind": "public", "label": "公网地址", "public": true },
"geo": {
"ok": true,
"ip": "114.114.114.114",
"raw": "中国|江苏省|南京市|南京新锋信息|CN",
"country": "中国",
"province": "江苏省",
"city": "南京市",
"isp": "南京新锋信息",
"iso2": "CN",
"reserved": false
},
"reverse": { "ok": true, "names": ["public1.114dns.com"], "error": null, "ms": 42 }
}
失败情况
- 私网 / 保留段:
"ok": false,error.message说明原因(仍返回 200)。 - 格式非法:
400+{"ok": false, "error": {"message": "IP 地址格式无效"}}。 - 地址不在库中:
ok: false,error.message = "本地库中没有该地址的段记录"。
GET /api/query
完整判定
返回归属地 + 检查项 + 评分 + 风险指数。ip 省略时使用请求来源地址。
参数
| 参数 | 位置 | 必填 | 说明 |
|---|---|---|---|
| ip | query | 否 | 要查询的 IPv4 地址;省略则取 X-Forwarded-For / X-Real-IP / socket 地址 |
响应结构
| 字段 | 类型 | 说明 |
|---|---|---|
| ip.value / version / flag / scope | object | 目标地址、IPv4/IPv6、国旗、作用域 |
| ip.source | string | query 手动输入 / request 来源地址 |
| mode | string | self 本机出口 / lookup 第三方查询 |
| geo | object | country{code,zh,en,flag} · continent · province · city · isp · precision · raw · source |
| network | object | rdns · rdnsDisplay · sdnsOk · hostingSignals[] · residentialHit |
| checks[] | array | id · label · group · status(pass/warn/fail/info/skip) · value · detail · penalty · weight |
| score | object | value(0–100) · label · level · penalty · deductions[] · measuredCount · failureCount · summary |
| risk | object | value(0–100) · label |
| purity | object | label · level(good/warn/muted) |
| headers[] | array | key · value · kind(ingress/standard/fingerprint/proxy/other) |
| edge | object|null | 边缘节点(EdgeOne / Vercel / Cloudflare)识别的访客情报:provider · asn · asnOrg · hosting · country · region · city · timezone · lat · lon · rows[] · diffCount · consistent。仅当边缘识别地址等于本次判定地址时返回 |
| meta | object | elapsedMs · headerCount · ingressHops · thirdPartyChain · generatedAt |
示例
curl "https://ip.isking.cc/api/query?ip=8.8.8.8"
{
"ok": true,
"mode": "lookup",
"ip": { "value": "8.8.8.8", "version": 4, "flag": "🇺🇸", "scope": "公网地址", "source": "query" },
"geo": {
"country": { "code": "US", "zh": "美国", "en": "United States", "flag": "🇺🇸" },
"continent": { "code": "NA", "zh": "北美洲" },
"province": "California",
"city": "Mountain View",
"isp": "Google LLC",
"precision": "city",
"raw": "United States|California|Mountain View|Google LLC|US"
},
"checks": [
{ "id": "hosting", "label": "IP 类型与场景", "status": "warn", "value": "机房 / 云服务 IP", "penalty": 18 },
{ "id": "geo_precision", "label": "归属地精度", "status": "pass", "value": "城市级", "penalty": 0 },
{ "id": "timezone", "label": "系统时区一致性", "status": "skip", "value": "不适用", "penalty": 0 }
],
"score": {
"value": 82, "label": "安全合规", "level": "good", "penalty": 18,
"deductions": [{ "id": "hosting", "label": "IP 类型与场景", "penalty": 18, "value": "机房 / 云服务 IP" }],
"measuredCount": 7, "failureCount": 1
},
"risk": { "value": 38, "label": "中等" },
"purity": { "label": "机房 IP", "level": "warn" }
}
POST /api/assess
合并浏览器特征
提交浏览器上报的特征后重新判定,返回与 /api/query 相同的结构,并补上 client 字段。
请求体
{
"ip": "8.8.8.8",
"client": {
"ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/131.0 Safari/537.36",
"tz": "Asia/Shanghai",
"tzOffsetMinutes": -480,
"languages": ["zh-CN", "zh"],
"screen": "2560x1440",
"dpr": 1,
"cores": 20,
"memory": 32,
"connection": "4g / 1.5Mbps / RTT 300ms",
"dnt": false,
"canvasHash": "ErLYC+ObuSz1VfG1E3nzAk",
"webrtc": {
"supported": true,
"publicIps": [],
"localIps": ["mdns-2f4c…local"]
}
}
}
字段
| 字段 | 类型 | 说明 |
|---|---|---|
| ip | string | 目标地址;省略则用请求来源地址 |
| client.ua | string | User-Agent,用于识别浏览器与自动化特征 |
| client.tz | string | IANA 时区名,如 Asia/Shanghai |
| client.tzOffsetMinutes | number | Date.getTimezoneOffset(),东八区为 -480 |
| client.screen / dpr | string / number | 屏幕逻辑分辨率与像素比 |
| client.cores / memory | number | hardwareConcurrency / deviceMemory |
| client.connection | string | 网络类型、下行、RTT 摘要 |
| client.dnt | boolean | Do Not Track / GPC |
| client.canvasHash | string | Canvas 绘制结果 SHA-256 前 22 位 |
| client.webrtc.publicIps[] | string[] | ICE 候选中的公网地址(srflx / relay) |
| client.webrtc.localIps[] | string[] | ICE 候选中的内网 / mDNS 地址 |
示例
curl -X POST "https://ip.isking.cc/api/assess" \
-H "Content-Type: application/json" \
-d '{"ip":"8.8.8.8","client":{"tz":"Asia/Shanghai","tzOffsetMinutes":-480}}'
GET /api/export
导出报告
参数
| 参数 | 必填 | 说明 |
|---|---|---|
| format | 否 | json(默认)或 csv |
| ip | 否 | 目标地址;省略则用请求来源地址 |
响应带 Content-Disposition: attachment,可直接下载;CSV 带 BOM,Excel 打开不乱码。
curl -OJ "https://ip.isking.cc/api/export?format=csv&ip=8.8.8.8"
GET DELETE /api/history
查询历史
GET 返回最近记录与统计;DELETE 清空。参数 limit(1–200,默认 50)。
{
"ok": true,
"items": [
{
"at": "2026-11-30T06:30:22.000Z",
"ip": "114.114.114.114",
"flag": "🇨🇳",
"country": "中国",
"province": "江苏省",
"city": "南京市",
"isp": "南京新锋信息",
"precision": "city",
"score": 100,
"risk": 0,
"purity": "普通公网 IP",
"hits": 1
}
],
"stats": { "total": 12, "uniqueIps": 7, "avgScore": 88, "avgRisk": 14, "hostingShare": 17 }
}
GET /api/db · /api/health
状态与自检
/api/db 返回库信息与 4 条样例查询(含单次检索耗时);/api/health 做一次自检,
正常返回 200,库不可用返回 503,可直接接监控。
{
"ok": true,
"db": {
"available": true,
"sizeMb": 10.6,
"error": null
},
"probe": {
"ip": "8.8.8.8",
"ok": true,
"tookMs": 0.033
},
"latencyMs": 3,
"at": "2026-12-01T07:21:45.521Z"
}
GET /api/whoami
调试
回显服务端看到的请求头,以及最终采用的客户端地址和来源头。排查"显示的不是我的 IP"时用它:
{
"ok": true,
"ip": "85.211.180.237",
"source": "eo-client-ip",
"chain": ["43.174.51.194"],
"candidates": [
{ "ip": "85.211.180.237", "source": "eo-client-ip", "public": true },
{ "ip": "43.174.51.194", "source": "x-forwarded-for", "public": true }
],
"socket": "127.0.0.1",
"headers": { "eo-client-ip": "85.211.180.237", "x-real-ip": "43.174.51.194", … }
}
地址取值顺序:eo-client-ip → eo-connecting-ip → cf-connecting-ip → true-client-ip → x-real-ip → X-Forwarded-For(取最左侧公网地址)→ socket。
状态码
| 状态码 | 含义 | 响应 |
|---|---|---|
| 200 | 成功 | {"ok": true, …} |
| 400 | IP 格式非法,或来源地址为内网且未传 ip | {"ok": false, "needInput": true, "error": {...}} |
| 404 | 地址不可路由 / 库中无记录 | {"ok": false, "error": {"message": "…"}} |
| 503 | 本地库不可用(仅 /api/health) | {"ok": false, "db": {...}} |