在开发网络应用时,了解用户地理位置是提升用户体验的关键之一。本文将介绍多个免费的开放API来查询IP地址的具体信息,并展示其请求方式和返回结果。我们将以阿里巴巴接口文档规范为标准,详细说明每个接口的使用方法。
1. 阿里巴巴IP查询接口
请求地址
https://ip.taobao.com/outGetIpInfo?ip=121.8.215.106&accessKey=alibaba-inc
请求方法
参数说明
参数名 | 必选 | 类型 | 说明 |
---|
ip | 是 | string | 待查询的IP地址 |
accessKey | 是 | string | 访问密钥 |
返回数据格式
{
"data": {
"area": "",
"country": "中国",
"isp_id": "100017",
"queryIp": "121.8.215.106",
"city": "广州",
"ip": "121.8.215.106",
"isp": "电信",
"county": "",
"region_id": "440000",
"area_id": "",
"county_id": null,
"region": "广东",
"country_id": "CN",
"city_id": "440100"
},
"msg": "query success",
"code": 0
}
2. 百度IP查询接口
请求地址
https://sp0.baidu.com/8aQDcjqpAAV3otqbppnN2DJv/api.php?query=119.135.194.24&co=&resource_id=6006&ie=utf8&oe=gbk&format=json
请求方法
参数说明
参数名 | 必选 | 类型 | 说明 |
---|
query | 是 | string | 待查询的IP地址 |
resource_id | 是 | int | 资源ID |
ie | 是 | string | 输入编码 |
oe | 是 | string | 输出编码 |
format | 是 | string | 数据格式 |
返回数据格式
{
"status": "0",
"t": "",
"set_cache_time": "",
"data": [
{
"location": "广东省清远市 电信",
"origip": "119.135.194.24"
}
]
}
3. VORE-API IP查询接口
请求地址
https://api.vore.top/api/IPdata?ip=121.8.215.106
请求方法
参数说明
参数名 | 必选 | 类型 | 说明 |
---|
ip | 是 | string | 待查询的IP地址 |
返回数据格式
{
"code": 200,
"msg": "SUCCESS",
"ipinfo": {
"type": "ipv4",
"text": "121.8.215.106",
"cnip": true
},
"ipdata": {
"info1": "广东省",
"info2": "广州市",
"info3": "增城",
"isp": "电信"
},
"adcode": {
"o": "广东省广州市增城 - 电信"
},
"tips": "接口由VORE-API(https://api.vore.top/)免费提供"
}
4. 百度地图IP定位接口
请求地址
https://api.map.baidu.com/location/ip?ak=LA46NZu12hG3MHAfH9jhDRhObBd0uR9t&ip=121.8.215.106
请求方法
参数说明
参数名 | 必选 | 类型 | 说明 |
---|
ak | 是 | string | API密钥 |
ip | 是 | string | 待查询的IP地址 |
返回数据格式
{
"address": "CN|广东省|广州市|None|None|100|100",
"content": {
"address_detail": {
"province": "广东省",
"city": "广州市",
"district": ""
},
"address": "广东省广州市",
"point": {
"x": "12609455.26",
"y": "2631453.98"
}
},
"status": 0
}
5. IP.cn API
请求地址
https://www.ip.cn/api/index?ip=121.8.215.106&type=1
请求方法
参数说明
参数名 | 必选 | 类型 | 说明 |
---|
ip | 是 | string | 待查询的IP地址 |
type | 是 | int | 查询类型 |
返回数据格式
{
"rs": 1,
"code": 0,
"address": "中国 广东省 广州市 电信",
"ip": "121.8.215.106",
"isDomain": 0
}
6. db-ip.com API
请求地址
https://db-ip.com/demo/home.php?s=121.8.215.106
请求方法
返回数据格式
{
"demoInfo": {
"ipAddress": "121.8.215.106",
"continentName": "Asia",
"countryName": "中国",
"stateProv": "广东",
"city": "广州",
"timezone": "Asia/Shanghai",
"latitude": 23.1317,
"longitude": 113.266,
"isp": "Chinanet",
"organization": "Chinanet GD"
}
}
7. OpenData百度API
请求地址
https://opendata.baidu.com/api.php?co=&resource_id=6006&oe=utf8&query=121.8.215.106
请求方法
参数说明
参数名 | 必选 | 类型 | 说明 |
---|
query | 是 | string | 待查询的IP地址 |
resource_id | 是 | int | 资源ID |
oe | 是 | string | 输出编码 |
返回数据格式
{
"status": "0",
"data": [
{
"location": "广东省广州市 电信",
"origip": "121.8.215.106"
}
]
}
8. Whois.pconline.com.cn API
请求地址
https://whois.pconline.com.cn/ipJson.jsp?ip=121.8.215.106&json=true
请求方法
参数说明
参数名 | 必选 | 类型 | 说明 |
---|
ip | 是 | string | 待查询的IP地址 |
json | 是 | bool | 是否返回JSON |
返回数据格式
{
"ip": "121.8.215.106",
"pro": "广东省",
"city": "广州市",
"addr": "广东省广州市 电信"
}
9. API.IP.SB GeoIP接口
请求地址
https://api.ip.sb/geoip/121.8.215.106
请求方法
返回数据格式
{
"organization": "China Telecom",
"longitude": 113.2539,
"city": "Guangzhou",
"timezone": "Asia/Shanghai",
"isp": "China Telecom",
"offset": 28800,
"region": "Guangdong",
"asn": 4134,
"asn_organization": "Chinanet",
"country": "China",
"ip": "121.8.215.106",
"latitude": 23.1181,
"continent_code": "AS",
"country_code": "CN",
"region_code": "GD"
}
10. IPINFO.IO JSON接口
请求地址
https://ipinfo.io/121.8.215.106/json
请求方法
返回数据格式
{
"ip": "121.8.215.106",
"city": "Shenzhen",
"region": "Guangdong",
"country": "CN",
"loc": "22.5455,114.0683",
"org": "AS4134 CHINANET-BACKBONE",
"postal": "518000",
"timezone": "Asia/Shanghai",
"readme": "https://ipinfo.io/missingauth"
}
11. IPINFO.IO Widget接口
请求地址
https://ipinfo.io/widget/demo/121.8.215.106
请求方法
返回数据格式
{
"input": "121.8.215.106",
"data": {
"ip": "121.8.215.106",
"city": "Shenzhen",
"region": "Guangdong",
"country": "CN",
"loc": "22.5455,114.0683",
"org": "AS4134 CHINANET-BACKBONE",
"postal": "518000",
"timezone": "Asia/Shanghai",
"is_anycast": false,
"is_mobile": false,
"is_anonymous": false,
"is_satellite": false,
"is_hosting": false,
"asn": {
"asn": "AS4134",
"name": "CHINANET-BACKBONE",
"domain": "chinatelecom.com.cn",
"route": "121.8.0.0/13",
"type": "isp"
},
"company": {
"name": "CHINANET Guangdong province network",
"domain": "chinatelecom.cn",
"type": "isp"
},
"privacy": {
"vpn": false,
"proxy": false,
"tor": false,
"relay": false,
"hosting": false,
"service": ""
},
"abuse": {
"address": "No.31 ,jingrong street,beijing, 100032",
"country": "CN",
"email": "anti-spam@chinatelecom.cn",
"name": "ABUSE CHINANETCN",
"network": "121.8.0.0/13",
"phone": "+000000000"
}
}
}
12. API.IPBASE.COM IP查询接口
请求地址
https://api.ipbase.com/v1/json/121.8.215.106
请求方法
返回数据格式
{
"ip": "121.8.215.106",
"country_code": "CN",
"country_name": "China",
"region_code": "CN-GD",
"region_name": "Guangdong",
"city": "Guangzhou",
"zip_code": "510140",
"time_zone": "Asia/Shanghai",
"latitude": 23.1273612976074,
"longitude": 113.264572143555,
"metro_code": 0
}
13. IP-API.IO JSON接口
请求地址
https://ip-api.io/json?ip=121.8.215.106
请求方法
返回数据格式
{
"ip": "27.158.109.238",
"countryCode": "CN",
"country_code": "CN",
"countryName": "China",
"country_name": "China",
"isInEuropeanUnion": false,
"is_in_european_union": false,
"regionName": "Guangdong",
"region_name": "Guangdong",
"regionCode": "GD",
"region_code": "GD",
"city": "Guangzhou",
"zipCode": "",
"zip_code": "",
"timeZone": "Asia/Shanghai",
"time_zone": "Asia/Shanghai",
"latitude": 23.1181,
"longitude": 113.2539,
"metroCode": 0,
"metro_code": 0,
"organisation": "Chinanet",
"flagUrl": "https://www.countryflags.io/CN/flat/64.png",
"emojiFlag": "https://www.countryflags.io/CN/emoji.png",
"currencySymbol": "",
"currency": "",
"callingCode": "",
"countryCapital": "",
"suspiciousFactors": {
"isProxy": false,
"isTorNode": false,
"isSpam": false,
"isSuspicious": false
}
}
14. API.IPAPI.IS 查询接口
请求地址
https://api.ipapi.is/?ip=121.8.215.106
请求方法
返回数据格式
{
"ip": "121.8.215.106",
"rir": "APNIC",
"is_bogon": false,
"is_mobile": false,
"is_crawler": false,
"is_datacenter": false,
"is_tor": false,
"is_proxy": true,
"is_vpn": false,
"is_abuser": true,
"company": {
"name": "CHINANET Guangdong province network",
"abuser_score": "0.0003 (Very Low)",
"domain": "chinatelecom.cn",
"type": "isp",
"network": "121.8.0.0 - 121.15.255.255",
"whois": "https://api.ipapi.is/?whois=121.8.0.0"
},
"abuse": {
"name": "IPMASTER CHINANET-GD",
"address": "NO.18,RO. ZHONGSHANER,YUEXIU DISTRIC,GUANGZHOU",
"email": "anti-spam@chinatelecom.cn",
"phone": "+86-20-87189274"
},
"asn": {
"asn": 4134,
"abuser_score": "0.001 (Low)",
"route": "121.8.0.0/13",
"descr": "CHINANET-BACKBONE No.31,Jin-rong Street, CN",
"country": "cn",
"active": true,
"org": "CHINANET BACKBONE",
"domain": "chinatelecom.cn",
"abuse": "anti-spam@chinatelecom.cn",
"type": "business",
"updated": "2021-06-15",
"rir": "APNIC",
"whois": "https://api.ipapi.is/?whois=AS4134"
},
"location": {
"is_eu_member": false,
"calling_code": "86",
"currency_code": "CNY",
"continent": "AS",
"country": "China",
"country_code": "CN",
"state": "Guangdong",
"city": "Guangzhou",
"latitude": 23.11667,
"longitude": 113.25,
"zip": "510000",
"timezone": "Asia/Shanghai",
"local_time": "2025-01-26T17:34:38+08:00",
"local_time_unix": 1737884078,
"is_dst": false
},
"elapsed_ms": 0.92
}
15. IPAPI.COM 查询接口
请求地址
https://ipapi.com/ip_api.php?ip=121.8.215.106
请求方法
返回数据格式
{
"ip": "121.8.215.106",
"hostname": "121.8.215.106",
"type": "ipv4",
"continent_code": "AS",
"continent_name": "Asia",
"country_code": "CN",
"country_name": "China",
"region_code": "GD",
"region_name": "Guangdong",
"city": "Guangzhou",
"zip": "510000",
"latitude": 23.124719619751,
"longitude": 113.238609313965,
"msa": null,
"dma": null,
"radius": null,
"ip_routing_type": "fixed",
"connection_type": "tx",
"location": {
"geoname_id": 1809858,
"capital": "Beijing",
"languages": [
{
"code": "zh",
"name": "Chinese",
"native": "中文"
}
],
"country_flag": "https://assets.ipstack.com/flags/cn.svg",
"country_flag_emoji": "🇨🇳",
"country_flag_emoji_unicode": "U+1F1E8 U+1F1F3",
"calling_code": "86",
"is_eu": false
},
"time_zone": {
"id": "Asia/Shanghai",
"current_time": "2025-01-26T17:27:58+08:00",
"gmt_offset": 28800,
"code": "CST",
"is_daylight_saving": false
},
"currency": {
"code": "CNY",
"name": "Chinese Yuan",
"plural": "Chinese yuan",
"symbol": "CN¥",
"symbol_native": "CN¥"
},
"connection": {
"asn": 4134,
"isp": "Chinanet",
"sld": "kj-textile",
"tld": "com",
"carrier": "chinanet",
"home": true,
"organization_type": "Internet Service Provider",
"isic_code": "J6110",
"naics_code": "517311"
},
"security": {
"is_proxy": false,
"proxy_type": null,
"is_crawler": false,
"crawler_name": null,
"crawler_type": null,
"is_tor": false,
"threat_level": "low",
"threat_types": null,
"proxy_last_detected": null,
"proxy_level": null,
"vpn_service": null,
"anonymizer_status": null,
"hosting_facility": false
}
}
16. API.IP2LOCATION.IO 查询接口
请求地址
https://api.ip2location.io/?ip=121.8.215.106
请求方法
返回数据格式
{
"ip": "121.8.215.106",
"country_code": "CN",
"country_name": "China",
"region_name": "Guangdong",
"city_name": "Guangzhou",
"latitude": 23.12736,
"longitude": 113.26457,
"zip_code": "510140",
"time_zone": "+08:00",
"asn": "4134",
"as": "Asia Pacific Network Information Centre",
"is_proxy": true,
"message": "Limit to 500 queries per day. Sign up for a Free plan at https://www.ip2location.io to get 30K queries per month."
}
17. REALIP.CC 查询接口
请求地址
https://realip.cc/?ip=121.8.215.106
请求方法
返回数据格式
{
"ip": "121.8.215.106",
"city": "Guangzhou",
"province": "Guangdong",
"country": "China",
"continent": "Asia",
"isp": "Chinanet",
"time_zone": "Asia/Shanghai",
"latitude": 23.1181,
"longitude": 113.2539,
"postal_code": null,
"iso_code": "CN",
"network": "121.8.128.0/17",
"notice": "api文档在/docs路径下,调用并发数是有限制的 ©2021-09-27->now",
"provider": "Powered by Bboysoul",
"blog": "https://www.bboy.app",
"tg_group": "https://t.me/bboyapp",
"data_updatetime": 20250102,
"count": 195369546
}
18. IPAPI.CO 查询接口
请求地址
https://ipapi.co/121.8.215.106/json/
请求方法
返回数据格式
{
"ip": "121.8.215.106",
"network": "121.8.128.0/17",
"version": "IPv4",
"city": "Guangzhou",
"region": "Guangdong",
"region_code": "GD",
"country": "CN",
"country_name": "China",
"country_code": "CN",
"country_code_iso3": "CHN",
"country_capital": "Beijing",
"country_tld": ".cn",
"continent_code": "AS",
"in_eu": false,
"postal": null,
"latitude": 23.1181,
"longitude": 113.2539,
"timezone": "Asia/Shanghai",
"utc_offset": "+0800",
"country_calling_code": "+86",
"currency": "CNY",
"currency_name": "Yuan Renminbi",
"languages": "zh-CN,yue,wuu,dta,ug,za",
"country_area": 9596960.0,
"country_population": 1411778724,
"asn": "AS4134",
"org": "Chinanet"
}
19. GET.GEOJS.IO 查询接口
请求地址
https://get.geojs.io/v1/ip/geo/121.8.215.106.json
请求方法
返回数据格式
{
"country_code3": "CHN",
"continent_code": "AS",
"region": "Guangdong",
"latitude": "23.1181",
"longitude": "113.2539",
"accuracy": 20,
"organization_name": "Chinanet",
"timezone": "Asia/Shanghai",
"asn": 4134,
"organization": "AS4134 Chinanet",
"city": "Guangzhou",
"ip": "121.8.215.106",
"area_code": "0",
"country": "China",
"country_code": "CN"
}
结语
通过上述多个接口的对比和使用,开发者可以根据自身需求选择最适合的API进行IP地址查询。无论是获取详细的地理位置信息,还是简单的城市级别定位,这些接口都能提供丰富的支持。
评论 (0)