本API提供IP位置查询
GET https://ip.api.opens.ltd/public.php?ip=8.8.8.8
{
"success": true,
"data": {
"ip": "8.8.8.8",
"city_id": 2056,
"region": "美国|0|0|Level3",
"country": "美国",
"country_code": "US",
"country_info": {
"chinese": "美国",
"english": "United States of America",
"alpha2": "US",
"alpha3": "USA",
"numeric": "840"
},
"province": "",
"city": "",
"isp": "Level3",
"simple": "美国【Level3】"
},
"rate_limit": {
"limit": 60,
"remaining": 59,
"reset_time": 1758409135
}
}
POST/GET https://ip.api.opens.ltd/public.php
curl "https://ip.api.opens.ltd/public.php?ip=61.142.118.231"
curl -X POST -d "ip=61.142.118.231" \
-H "Content-Type: application/x-www-form-urlencoded" \
"https://ip.api.opens.ltd/public.php"
curl -X POST -d '{"ip":"61.142.118.231"}' \
-H "Content-Type: application/json" \
"https://ip.api.opens.ltd/public.php"
curl -H "X-IP: 61.142.118.231" \
"https://ip.api.opens.ltd/public.php"
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
ip |
string | 是 | IPv4地址 |
IP参数只能在一个位置提供,如果同时在多个位置出现会返回400错误。
HTTP状态码:200 OK
| 字段 | 类型 | 说明 |
|---|---|---|
success |
boolean | 请求是否成功 |
data |
object | IP地理位置信息 |
data.ip |
string | 查询的IP地址 |
data.city_id |
integer | 城市ID |
data.region |
string | 原始地理信息(格式:国家|省份|城市|ISP) |
data.country |
string | 国家名称(中文) |
data.country_code |
string | 国家代码(ISO 3166-1 alpha-2) |
data.country_info |
object | 详细国家信息 |
data.country_info.chinese |
string | 中文国家名称 |
data.country_info.english |
string | 英文国家名称 |
data.country_info.alpha2 |
string | ISO 3166-1 alpha-2代码 |
data.country_info.alpha3 |
string | ISO 3166-1 alpha-3代码 |
data.country_info.numeric |
string | ISO 3166-1数字代码 |
data.province |
string | 省份/州名称 |
data.city |
string | 城市名称 |
data.isp |
string | 网络服务提供商 |
data.simple |
string | 简化显示格式 |
rate_limit |
object | 速率限制信息 |
rate_limit.limit |
integer | 每分钟请求限制 |
rate_limit.remaining |
integer | 剩余请求次数 |
rate_limit.reset_time |
integer | 限制重置时间(Unix时间戳) |
{
"success": false,
"error": {
"code": 400,
"message": "错误描述"
},
"rate_limit": {
"limit": 60,
"remaining": 59,
"reset_time": 1758409135
}
}
| HTTP状态码 | 错误代码 | 说明 |
|---|---|---|
| 400 | 400 | 请求参数错误(缺少IP参数或IP格式无效) |
| 400 | 400 | IP参数在多个位置重复提供 |
| 429 | 429 | 请求频率超限(每分钟超过60次) |
| 500 | 500 | 服务器内部错误 |
每个响应都包含速率限制信息:
limit:每分钟请求限制(60)remaining:当前周期内剩余请求次数reset_time:限制重置的Unix时间戳当请求超过限制时,API将返回HTTP 429状态码,建议客户端实现指数退避重试策略。
若您想使用无速率限制的api,可以把public.php换成api.php。但不要贪杯哦~
© 2025 AIXIAOJI