默认
IP地址信息
IP地址信息
GET / POST
https://api.qzqi.com/api/v1/iPAddress
所需点数免费
平均响应280ms
限流策略无限制
近 7 日调用趋势
- 接口信息
- 参数文档
- 在线调试
- 代码示例
接口简介
IP地址信息
基本参数
接口分类默认
请求方式GET / POST
请求地址https://api.qzqi.com/api/v1/iPAddress
认证方式无需认证
限流策略无限制
平均响应280ms
请求参数 1 个
| 参数名 | 类型 | 必填 | 示例 | 说明 |
|---|---|---|---|---|
| ip | string | 否 | 待查询的 IP 地址(IPv4/IPv6),不传则默认获取请求端 IP |
响应字段 6 个
| 字段名 | 类型 | 说明 |
|---|---|---|
| msg | string | 响应信息(success = 成功,fail = 失败) |
| location | object | IP 归属信息对象 |
| location.ip | string | 查询的 IP 地址 |
| location.address | string | IP 归属地(如:中国福建省泉州市) |
| location.isp | string | 运营商(如:电信 / 移动 / 联通) |
| location.type | string | IP 类型(如:IPv4/IPv6) |
在线调试
响应结果
—
// 点击「发送请求」开始调试…
代码示例
PHP
<?php
/**
* 调用IPAddress接口示例
* 接口地址:https://api.nmmp.cn/api/v1/iPAddress
*/
function getIpInfo($ip = '') {
$url = 'https://api.nmmp.cn/api/v1/iPAddress';
// 拼接参数(不传ip则自动获取请求端IP)
if (!empty($ip)) {
$url .= '?ip=' . urlencode($ip);
}
// 发起请求
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36');
$response = curl_exec($ch);
curl_close($ch);
// 解析响应
if ($response) {
return json_decode($response, true);
}
return ['code' => 500, 'msg' => '请求失败'];
}
// 调用示例
$ipInfo = getIpInfo('27.149.74.91');
if ($ipInfo['code'] == 200) {
echo 'IP归属地:' . $ipInfo['location']['address'];
} else {
echo '查询失败:' . $ipInfo['msg'];
}