免费IP地址查询API接口推荐
作者:youqing · 2025-11-06 · 阅读时间:7分钟
文章目录
收藏它,10 分钟接入全球 IP 定位,精准到城市级别!
一、IP 地址查询 API:查询本机 IP 或通过 IP 反查 🔍
1. IP.CN API 🇨🇳
-
请求类型: GET
-
示例:
import requests response = requests.get("https://www.ip.cn/api/index?ip=121.8.215.106&type=1") print(response.json())用 代码示例讲解概念 一行行对比
type=0vstype=1返回字段差异! -
结果示例:
{ "rs": 1, "code": 0, "address": "中国 广东省 广州市 电信", "ip": "121.8.215.106", "isDomain": 0 }
2. PConline API 📡
-
示例:
response = requests.get("https://whois.pconline.com.cn/ipJson.jsp?ip=121.8.215.106&json=true") print(response.json())用 代码片段解析助手 秒懂
cityCode与国家统计局编码的对应关系! -
结果示例:
{ "ip": "121.8.215.106", "pro": "广东省", "city": "广州市", "cityCode": "440100", "addr": "广东省广州市 电信" }
3. Vore API 🌐
-
支持 CORS ✅
-
示例:
response = requests.get("https://api.vore.top/api/IPdata?ip=121.8.215.106") print(response.json())用 代码优化助手 把
requests.get改为requests.Session连接池,QPS 提升 3 倍! -
结果示例:
{ "code": 200, "ipdata": { "info1": "广东省", "info2": "广州市", "info3": "增城", "isp": "电信" }, "adcode": { "a": "440100", "i": true } }
4. IP.sb API 🗺️
-
支持 CORS ✅
-
示例:
response = requests.get("https://api.ip.sb/geoip/121.8.215.106") print(response.json())用 JavaScript代码反混淆专家 解开前端 SDK 的混淆代码,确保经纬度精度不被截断!
-
结果示例:
{ "city": "Guangzhou", "region": "Guangdong", "country": "China", "latitude": 23.1181, "longitude": 113.2539, "isp": "China Telecom" }
5. IP2Location API 📍
-
限制: 500 次/天
-
示例:
response = requests.get("https://api.ip2location.io/?ip=121.8.215.106") print(response.json())用 代码安全审查 扫描
is_proxy字段,自动标记代理 IP 并触发二次验证! -
结果示例:
{ "ip": "121.8.215.106", "country_name": "China", "region_name": "Guangdong", "city_name": "Guangzhou", "latitude": 23.127361, "longitude": 113.26457, "is_proxy": true }
二、IP 地址归属地查询 API:仅查询本机 IP 信息 🏠
Httpbin API 🕸️
- URL: http://httpbin.org/ip
- 不支持 CORS ❌
- 示例:
response = requests.get("http://httpbin.org/ip") print(response.json()) - 结果:
{ "origin": "20.249.16.173" }
三、IP 地址归属地查询 API:只可通过 IP 查询信息 🔍
Baidu OpenData API 🍴
- URL: http://opendata.baidu.com/api.php?co=&resource_id=6006&oe=utf8&query=
- 不支持 CORS ❌
- 示例:
response = requests.get("http://opendata.baidu.com/api.php?co=&resource_id=6006&oe=utf8&query=121.8.215.106") print(response.json())
GeoJS API 🌍
-
支持 CORS ✅
-
示例:
response = requests.get("https://get.geojs.io/v1/ip/geo/121.8.215.106.json") print(response.json())用 API交互代码生成 30 秒生成带「指数退避 + 缓存」的批量查询脚本,1 分钟跑完 1000 条!
-
结果示例:
{ "country": "China", "city": "Guangzhou", "latitude": "23.1181", "longitude": "113.2539", "accuracy": 1000 }
IPinfo API 🛡️
-
支持 CORS ✅
-
示例:
response = requests.get("https://ipinfo.io/widget/demo/121.8.215.106") print(response.json())用 代码优化专家助手 把
response.json()改为response.json()['data'],减少一次字典拷贝! -
结果示例:
{ "data": { "ip": "121.8.215.106", "city": "Shenzhen", "country": "CN", "loc": "22.5455,114.0683", "org": "AS4134 CHINANET-BACKBONE", "privacy": { "vpn": false, "proxy": false } } }
四、总结 🏁
IP 地址查询 API 是精准定位、数据分析、个性化营销的利器:
- 免费、易集成、多语言支持
- 支持全球定位、运营商识别、代理检测
- 10 分钟接入,立刻提升应用功能与用户体验!
现在就复制文中的 Python 代码,10 分钟跑通全球 IP 定位,让你的应用「一眼看穿」用户来源!
热门推荐
一个账号试用1000+ API
助力AI无缝链接物理世界 · 无需多次注册
3000+提示词助力AI大模型
和专业工程师共享工作效率翻倍的秘密
最新文章
- api 认证与授权的最佳实践
- 什么是GraphRAG
- 如何获取 Notion 开放平台 API Key 密钥(分步指南)
- DeepSeek-R1 调用 MCP 天气API服务教程:MCP 客户端与服务端入门
- 旅游供应商的Travel Booking APIs [Onix概览]
- 使用 Web Share API 实现图片分享
- 学习与设计rest api的顶级资源
- 十大企业级 API 管理工具全景指南
- Meta×Google 云计算协议:2025 多云/混合云 API 极速落地 AI 出海成本降 40%
- Kimi Chat API入门指南:从注册到实现智能对话
- 5种最佳API认证方法,显著提升…
- API接口重试的8种方法