高性能IP地理位置查询服务,支持IPv4/IPv6双栈
根据IP地址返回地理位置信息,支持IPv4和IPv6。
{
"ip": "8.8.8.8",
"country": "美国",
"region": "加利福尼亚",
"province": "加利福尼亚",
"city": "芒廷维尤",
"isp": "Google LLC",
"latitude": 37.4056,
"longitude": -122.0775,
"timezone": "America/Los_Angeles",
"ip_version": 4,
"query_time_ms": 0.05
}
批量查询多个IP地址的地理位置信息,单次最多100个。
{
"results": [
{"ip": "8.8.8.8", "country": "美国", ...},
{"ip": "1.1.1.1", "country": "澳大利亚", ...}
],
"total": 2,
"query_time_ms": 0.12
}
检查服务运行状态和数据库加载情况。
{
"status": "healthy",
"database": {
"ipv4_loaded": true,
"ipv6_loaded": true
},
"cache": {
"size": 128,
"max_size": 10000
}
}
获取缓存命中率和查询统计信息。
{
"cache_hits": 1024,
"cache_misses": 256,
"hit_rate": "80.00%",
"total_queries": 1280
}
获取请求客户端的IP地址和位置信息。
{
"your_ip": "192.168.1.1",
"location": {
"country": "中国",
"province": "北京",
"city": "北京"
}
}
curl "http://localhost:8000/api/v1/query?ip=8.8.8.8"
import requests; r = requests.get('http://localhost:8000/api/v1/query?ip=8.8.8.8')
fetch('/api/v1/query?ip=8.8.8.8').then(r => r.json())