API接口

调用接口

接口地址

https://ipip.help/apicall.php

参数说明

参数名 类型 是否必选 描述
ip string IPv4地址

调用方式

cURL

curl "https://ipip.help/apicall.php?ip=8.8.8.8"

PHP

<?php
$ip = '8.8.8.8';
$url = "https://ipip.help/apicall.php?ip={$ip}";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);

echo $response;
?>

Python

import requests

ip = '8.8.8.8'
url = f"https://ipip.help/apicall.php?ip={ip}"

response = requests.get(url)
print(response.json())

JavaScript (Fetch)

const ip = '8.8.8.8';
const url = `https://ipip.help/apicall.php?ip=${ip}`;

fetch(url)
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));

输出信息示例

成功响应

{"status": "success",
"message": "API查询成功",
"data": {
  "ip": "8.8.8.8",
  "country": "United States",
  "region": "California",
  "city": "Mountain View",
  "isp": "Google LLC",
  "asn": "15169",
  "lat": 37.3860517,
  "lon": -122.0838511
}}

错误响应

{"status": "error",
"message": "无效的IPv4地址格式",
"data": null
}