IP归属地查询 在线试调 →
查询IP的归属地: 国家/省份/城市/运营商/ISO两字母码
接口说明
IP归属地查询:输入IP → 国家/省份/城市/运营商/ISO两字母码,基于离线库 ip2region(月级更新),IPv4/IPv6 双栈,单次查询微秒级。
ip 不传=按调用方出口IP查询(风控留痕/渠道识别常用姿势)
中国地区全中文,海外英文;私网/保留地址 country=Reserved
归属地是"尽力而为"的参考信息,勿用于计费或合规级判断
快速调用
同一调用的三种等价写法,按接入习惯任选其一,复制即可运行。
查询指定IP
import top369 as gp
pro = gp.pro_api("sk-xxxxxxxxxxxx") # 安装: pip install top369
df = pro.ip_location(ip="223.5.5.5") # → 单行DataFrame: country/province/city/isp/iso2
查询调用方IP
import top369 as gp
pro = gp.pro_api("sk-xxxxxxxxxxxx") # 安装: pip install top369
df = pro.ip_location() # ip省略, 服务端按来源IP查询
查询指定IP
import requests
API = "https://api.369.top/api"
KEY = "sk-xxxxxxxxxxxx"
r = requests.get(f"{API}/tools/ip",
headers={"X-API-Key": KEY},
params={"ip": "223.5.5.5"},
timeout=30)
r.raise_for_status()
data = r.json()["data"] # 信封解包
查询调用方IP
import requests
API = "https://api.369.top/api"
KEY = "sk-xxxxxxxxxxxx"
r = requests.get(f"{API}/tools/ip",
headers={"X-API-Key": KEY},
timeout=30)
r.raise_for_status()
data = r.json()["data"] # 信封解包
查询指定IP
curl -H "X-API-Key: sk-xxxxxxxxxxxx" \ "https://api.369.top/api/tools/ip?ip=223.5.5.5"
查询调用方IP
curl -H "X-API-Key: sk-xxxxxxxxxxxx" \ "https://api.369.top/api/tools/ip"
输入参数
| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
| ip | str | 可选 | 要查询的IP(IPv4/IPv6); 省略=调用方来源IP |
返回字段
| 名称 | 类型 | 描述 |
|---|---|---|
| ip | str | 实际查询的IP |
| version | str | IPv4/IPv6 |
| country | str | 国家(中国=中文, 海外英文) |
| province | str | 省份/州 |
| city | str | 城市 |
| isp | str | 运营商/机构 |
| iso2 | str | ISO 3166-1 两字母码 |
| raw | str | 原始region串(国家|省份|城市|ISP|iso2) |
返回数据样例
{
"ip": "223.5.5.5",
"version": "IPv4",
"country": "中国",
"province": "浙江省",
"city": "杭州市",
"isp": "阿里",
"iso2": "CN",
"raw": "中国|浙江省|杭州市|阿里|CN"
}
最佳实践:ip不传=按调用方出口IP查询(风控留痕/渠道识别常用); 私网与保留地址返回 country=Reserved; 数据未覆盖(如回环地址)返回404 —— 归属地是"尽力而为"的参考信息, 不要拿它做计费或合规级判断。