1. ip归属地

查询IP的归属地信息

GET:http://api.hannm.com/iploc/{ip}

字段名 字段位置 字段类型 字段说明 举例 必选
apiv head string API版本,默认是1.0.0 1.0.0 可选
Authorization head string 客户端保存的鉴权token Authorization字符串 必选
ip path string 查询的ip地址 必选

返回数据

{
    "error": 0,
    "reason": "success",
    "result": {
            "ip": "210.13.40.226",
            "country": "中国",
            "district": "",
            "province": "北京",
            "city": "北京市",
            "lon": "12958160.97",
            "lat": "4825907.72",
            "adcode": "",
            "isp": "联通"
             }
 }

成功返回

字段名 字段类型 字段说明
ip string 查询的ip地址
country string 查询的ip地址的所属国家
district string 查询的ip地址的所属地区
province string 查询的ip地址的所属省份
city string 查询的ip地址的所属城市
lon string 查询的ip地址的对应经度
lat string 查询的ip地址的对应纬度
adcode string 查询的ip地址的对应行政区代码
isp string 查询的ip地址对应的互联网提供商

失败返回

{
    "error": 1,
    "reason": "失败原因",
    "result": {"失败的参考数据"},
}

1.1. 错误码

错误码来自于error字段

错误码 错误码名 说明 可能原因
2000 服务成功完成 成功 服务成功完成。
2013 获取信息例外 成功 在查询ip地址时,因各种原因和例外,导致获取信息失败
2014 无效的ip地址 成功 查询的ip地址格式错误时,会返回“无效的ip地址”错误

1.2. Browser SDK调用示例代码

    const ham = await hannm({
        APP_KEY: "aHEVYhE1",
        APP_SECRET: "f34b127abc7cca1862dac91db6256190",
    })
    let api_name = "IP归属地";
    let res = await ham.getIploc("159.226.39.124")
    console.log(res);
    console.log(JSON.stringify(res));
    if(res.error == 0){
        console.log(api_name+"成功 ");
    }else{
        console.log(api_name+"失败 "+res.reason);
    }
{ 
    error: 0,
    reason: 'success', 
    result:{ 
        lon: '12958160.97',
        isp: '科技网',
        province: '北京',
        adcode: '',
        district: '',
        lat: '4825907.72',
        city: '北京市',
        country: '中国',
        ip: '159.226.39.124' 
    }
}

results matching ""

    No results matching ""