GET 工具 调用 0 次

IP信息查询

获取调用者真实IP及归属地信息,也可指定IP查询。

接口路径 /api/ip
API文档 状态码 示例代码

◆ 接口信息

接口地址 /api/ip
请求方式 GET
返回格式 JSON
请求示例 https://cloud.xgiao.cn/api/ip

◆ 请求参数

参数名参数值参数类型是否必填默认值取值范围参数描述
key YOUR_API_KEY string 可选 临时测试Key 32位大写字母数字 API Key(可省略,默认使用临时测试Key,无需登录即可体验)
ip 182.247.249.12 string 可选 调用者真实IP 合法IPv4或IPv6地址 要查询的IP地址,缺省返回调用者自身IP信息

◆ 返回参数

参数名参数类型参数描述
ip string 查询的IP地址
country string 国家/地区
province string 省份/州
city string 城市
isp string 运营商
location string 归属地完整描述

◆ 返回示例

查询指定IP 182.247.249.12 的归属地(key可省略)

curl
curl "https://cloud.xgiao.cn/api/ip?ip=182.247.249.12"
JSON
{
  "code": 200,
  "msg": "success",
  "data": {
    "ip": "182.247.249.12",
    "country": "中国",
    "province": "云南省",
    "city": "昆明市",
    "isp": "电信",
    "location": "中国 云南省 昆明市 电信"
  }
}

◆ 错误示例

以下为常见请求错误时的返回结果:

API Key 无效 code 40002
curl
curl "https://cloud.xgiao.cn/api/ip?key=WRONG_KEY"
返回
{"code":40002,"msg":"API Key无效","data":null}
ip 参数格式不正确 code 40005
curl
curl "https://cloud.xgiao.cn/api/ip?ip=not-an-ip"
返回
{"code":40005,"msg":"ip参数格式不正确","data":null}