概述
在许多情况下,我们需要查询当前服务器或设备所处的公网 IP 地址信息。通过 API 接口进行查看或二次开发,不仅高效,还能满足不同的需求。本文档将收集多个免费的 IP 地址查询 API 接口,帮助开发者快速获取所需信息。
接口列表
浏览器访问或在命令行界面使用 curl 直接请求即可。
以下是一些常用的免费 IP 地址查询 API 接口,供开发者参考和使用。
国内 IP 查询接口
太平洋电脑网
不支持跨域访问
https://whois.pconline.com.cn/ipJson.jsp?json=true
接口返回格式为:
{"ip":"223.70.0.2","pro":"北京市","proCode":"110000","city":"北京市","cityCode":"110000","region":"","regionCode":"0","addr":" 北京市 移动 ","regionNames":"","err":""}
咪咕
不支持跨域访问
https://effic.migufun.com:8443/user/queryProvince
接口返回格式为:
{"returnCode":"000000","message":"请求成功","resultData":{"ip":"222.0.0.1","ipCountry":"中国","provinceId":"100","ipProvince":"北京","cityId":"10","ipCity":"北京","ipOperator":"电信 / 联通 / 移动","ipGPS":"39.93157,116.41005"},"serverTime":1728099789323}
百度云盘
不支持跨域访问,只能查询 IP
https://d.pcs.baidu.com/rest/2.0/pcs/file?method=locateupload
接口返回内容为:
{"bak_server":["c.pcs.baidu.com"],"client_ip":"12.25.15.3","error_code":0,"error_msg":"","expire":60,"host":"c.pcs.baidu.com","newno":"","quic_server":["https://panup.pcs.baidu.com"],"request_id":6459122064932601200,"server":["bdbl-cm01.pcs.baidu.com","c.pcs.baidu.com","c2.pcs.baidu.com"],"server_time":1728100504,"sl":0}
淘宝
指定 IP 后才能访问,不允许跨域。
https://ip.taobao.com/outGetIpInfo?accessKey=alibaba-inc&ip=114.114.114.114
接口返回为:
{"data":{"area":"","country":" 中国 ","isp_id":"xx","queryIp":"114.114.114.114","city":" 南京 ","ip":"114.114.114.114","isp":"XX","county":"","region_id":"320000","area_id":"","county_id":null,"region":" 江苏 ","country_id":"CN","city_id":"320100"},"msg":"query success","code":0}
美团
指定 IP 后才能访问,不允许跨域链接。
https://apimobile.meituan.com/locate/v2/ip/loc?client_source=yourAppKey&rgeo=true&ip=1.1.11.1
接口返回:
{"data":{"lng":113.424824,"fromwhere":"mars-mt","ip":"1.1.11.1","rgeo":{"country":"中国","province":"广东省","adcode":"440115","city":"广州","district":"南沙区"},"lat":22.856135
腾讯地图
不支持跨域,可以指定 IP 查询。
以下为收集腾讯地图的接口:
https://h5gw.map.qq.com/ws/location/v1/ip?key=2J4BZ-PBHH2-VYGU4-CODCH-C4EA2-W4BAU&apptag=h5loc_ip_loc&output=json https://apis.map.qq.com/ws/location/v1/ip?key=ACEBZ-FDXWP-WFRDV-VGS5Q-S2Q5K-HQBNA https://apis.map.qq.com/ws/location/v1/ip?key=RMJBZ-2IP64-CSNUJ-DLU7O-O3DF7-MMB5E https://apis.map.qq.com/ws/location/v1/ip?key=4RYBZ-4TRHF-GDOJU-NS5TO-3PIX7-LRF5F https://apis.map.qq.com/ws/location/v1/ip?key=N7XBZ-NX764-OFOUH-D5LJY-KZ3QK-6WFNX https://apis.map.qq.com/ws/location/v1/ip?key=3JLBZ-I2OWJ-3AAFI-KDLGM-UMDPO-Q6BRM https://apis.map.qq.com/ws/location/v1/ip?key=EIMBZ-RBNH4-NZQUG-X7RKQ-3SPPH-YSFCX https://apis.map.qq.com/ws/location/v1/ip?key=IDHBZ-7F2KM-SFY6S-6OQYE-6VWRE-WVB5N https://apis.map.qq.com/ws/location/v1/ip?key=GWSBZ-HTTWJ-QJIF2-KLHLC-X3WKV-ZZFV6 https://apis.map.qq.com/ws/location/v1/ip?key=T3EBZ-TJ7LI-YRBG2-5ZLUR-KD3OS-U6BJO https://apis.map.qq.com/ws/location/v1/ip?key=PTMBZ-GCQLW-SC2RG-R2FNI-HWPNQ-4PBQM https://apis.map.qq.com/ws/location/v1/ip?key=PTMBZ-GCQLW-SC2RG-R2FNI-HWPNQ-4PBQM https://apis.map.qq.com/ws/location/v1/ip?key=EP7BZ-JAOKQ-NIV55-GPNDX-CBPOQ-PHB7E https://apis.map.qq.com/ws/location/v1/ip?key=OIVBZ-MQZ6X-V2T4C-TLTXF-2X755-6CBAZ
接口返回格式为:
{"status":0,"message":"Success","request_id":"","result":{"ip":"1.1.1.1","location":{"lat":-35.2667,"lng":149.1333},"ad_info":{"nation":" 澳大利亚 ","province":"","city":"","district":"","adcode":-1,"nation_code":36}
百度地图
不支持跨域,可以指定 IP 查询。
以下为收集百度地图的接口:
https://api.map.baidu.com/location/ip?ak=M4eExM3AxIcxOdnFGciErtK3&coor=bd09ll https://api.map.baidu.com/location/ip?ak=NRjNKoTLotrpA6bH4hUanMUbTyID1upT&coor=bd09ll https://api.map.baidu.com/location/ip?ak=edUWu66ddGavrmj9a6vcsa75&coor=bd09ll https://api.map.baidu.com/location/ip?ak=Gwb8qTDLXEYRQeeeFoSeBBvtL4CjG0oL&coor=bd09ll https://api.map.baidu.com/location/ip?ak=LC742jDXOpX0YK7zCujnaYYBUiifRHBT&coor=bd09ll https://api.map.baidu.com/location/ip?ak=wVg1oglV4BDE2DHW1EBSNuPrtfHZ4hXD&coor=bd09ll https://api.map.baidu.com/location/ip?ak=UsRSw3nTcduUNpdN1I59kZwD2ZxB5QKf&coor=bd09ll https://api.map.baidu.com/location/ip?ak=s5mH7GofLFW9ET9Et86hKxoRZWOgBuYG&coor=bd09ll https://api.map.baidu.com/location/ip?ak=NRjNKoTLotrpA6bH4hUanMUbTyID1upT&coor=bd09ll https://api.map.baidu.com/location/ip?ak=UwHxw3gMu9G3zxjC5Ug5SQhoZnSCSIei&coor=bd09ll
接口返回格式为:
{"address":"CN| 广东省 | 广州市 |None|None|98|98","content":{"address":"广东省广州市","address_detail":{"adcode":"440100","city":"广州市","city_code":257,"district":"","province":" 广东省 ","street":"","street_number":""},"point":{"x":"113.27143134","y":"23.13533631","status":0}
腾讯视频
只能查看访问者 IP 信息,不支持跨域。
https://disp-qryapi.3g.qq.com/v1/dispatch
{"code":0,"unitResults":{},"ipInfo":"中国 #北京市# 中国移动#","extra":{"ip":"120.211.1.13"
网易邮箱大师
只能查看访问者 IP 信息,不支持跨域。
https://dashi.163.com/fgw/mailsrv-ipdetail/detail
以下为查询接口返回:
{"code":200,"desc":"DONE","success":"false","result":{"country":"中国","province":"北京市","provinceEn":"Beijing","city":"北京市","org":"UNKNOWN","isp":"移动","latitude":"39.6527901184","longitude":"116.425194597","timezone":"Asia/Shanghai","countryCode":"CN","continentCode":"AS","provinceCode":"11","continent":"亚洲","county":"UNKNOWN","ispId":"10086","ip":"120.211.11.11","zone":"gz"
高德地图
单 key 每日有频率限制,支持跨域访问,支持指定 IP 查询信息。
以下为收集高德地图的接口:
https://restapi.amap.com/v3/ip?key=ba5f9b69f0541123a4dbe142da230b4d https://restapi.amap.com/v3/ip?key=ec8838f3bf4614c5627c4266b36cc813 https://restapi.amap.com/v3/ip?key=0a2a27ba5e33705826293c630a22d445 https://restapi.amap.com/v3/ip?key=407cd13370e3e36bcb96759e9b08d958 https://restapi.amap.com/v3/ip?key=0113a13c88697dcea6a445584d535837 https://restapi.amap.com/v3/ip?key=7cf01841d11f9e10ccc014b9d4ac0ee2 https://restapi.amap.com/v3/ip?key=521d56615aad7c53f930a5db86214cfd https://restapi.amap.com/v3/ip?key=b9fe1600bd434cee8375f822b3e0da15 https://restapi.amap.com/v3/ip?key=2acf0a74a75c1ded782ebbf9f3ded364 https://restapi.amap.com/v3/ip?key=4f3e4eee3efe05aa8593e438df8aed22 https://restapi.amap.com/v3/ip?key=016ad9192e40fc6d1054a83a21400429 https://restapi.amap.com/v3/ip?key=7adc97f7624ef1865767693e1b183478 https://restapi.amap.com/v3/ip?key=67953f7ce7d657144d5f3b12f84310ed
接口返回格式为:
{"status":"1","info":"OK","infocode":"10000","province":"江苏省","city":"南京市","adcode":"320100","rectangle":"118.4253323,31.80452471;119.050169,32.39401346"}
百度
指定 IP 后才能访问,不允许跨域链接。
https://opendata.baidu.com/api.php?co=&resource_id=6006&oe=utf8&query=1.1.1.1
百度查询接口返回格式为:
{"status":"0","t":"","set_cache_time":"","data":[{"ExtendedLocation":"","OriginQuery":"1.1.1.1","SchemaVer":"","appinfo":"","disp_type":0,"fetchkey":"1.1.1.1","location":" 澳大利亚 ","origip":"1.1.1.1","origipquery":"1.1.1.1","resourceid":"6006","role_id":0,"schemaID":"","shareImage":1,"showLikeShare":1,"showlamp":"1","strategyData":{},"titlecont":"IP 地址查询","tplt":"ip"}]}

