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 省略时使用请求来源地址。

参数

参数位置必填说明
ipquery否要查询的 IPv4 地址;省略则取 X-Forwarded-For / X-Real-IP / socket 地址

响应结构

字段类型说明
ip.value / version / flag / scopeobject目标地址、IPv4/IPv6、国旗、作用域
ip.sourcestringquery 手动输入 / request 来源地址
modestringself 本机出口 / lookup 第三方查询
geoobjectcountry{code,zh,en,flag} · continent · province · city · isp · precision · raw · source
networkobjectrdns · rdnsDisplay · sdnsOk · hostingSignals[] · residentialHit
checks[]arrayid · label · group · status(pass/warn/fail/info/skip) · value · detail · penalty · weight
scoreobjectvalue(0–100) · label · level · penalty · deductions[] · measuredCount · failureCount · summary
riskobjectvalue(0–100) · label
purityobjectlabel · level(good/warn/muted)
headers[]arraykey · value · kind(ingress/standard/fingerprint/proxy/other)
edgeobject|null边缘节点(EdgeOne / Vercel / Cloudflare)识别的访客情报:provider · asn · asnOrg · hosting · country · region · city · timezone · lat · lon · rows[] · diffCount · consistent。仅当边缘识别地址等于本次判定地址时返回
metaobjectelapsedMs · 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"]
    }
  }
}

字段

字段类型说明
ipstring目标地址;省略则用请求来源地址
client.uastringUser-Agent,用于识别浏览器与自动化特征
client.tzstringIANA 时区名,如 Asia/Shanghai
client.tzOffsetMinutesnumberDate.getTimezoneOffset(),东八区为 -480
client.screen / dprstring / number屏幕逻辑分辨率与像素比
client.cores / memorynumberhardwareConcurrency / deviceMemory
client.connectionstring网络类型、下行、RTT 摘要
client.dntbooleanDo Not Track / GPC
client.canvasHashstringCanvas 绘制结果 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, …}
400IP 格式非法,或来源地址为内网且未传 ip{"ok": false, "needInput": true, "error": {...}}
404地址不可路由 / 库中无记录{"ok": false, "error": {"message": "…"}}
503本地库不可用(仅 /api/health){"ok": false, "db": {...}}