返回 API 大厅

IP归属地查询

接口信息
总调用: 41
添加时间: 2026-09-22
更新时间: 2026-10-27
访问权限: 公开访问(无需密钥)
请求信息
请求地址:
https://taoziwei.com/API/ip.php
示例地址:
https://taoziwei.com/API/ip.php?ip=1.2.3.4
请求参数
参数名 类型 必填 说明
ip string 否 要查询的IP地址,为空时返回当前出口IP
状态码说明
状态码 说明
200 请求成功,服务器已成功处理了请求。
201 已创建。请求成功并且服务器已创建了新的资源。
204 无内容。服务器成功处理了请求,但不需要返回任何实体内容。
400 错误请求。服务器无法理解请求的格式,请检查请求参数是否正确。
401 未授权。请求需要身份验证,请提供有效的身份凭据(如登录态、Token)。
403 服务器拒绝请求。这可能是由于缺少必要的认证凭据(如API密钥)或权限不足。
404 请求的资源未找到。请检查您的请求地址是否正确。
405 方法不允许。请求使用的 HTTP 方法不被该接口支持,请检查请求方式(GET/POST)。
408 请求超时。服务器等待请求时发生超时,请稍后重试。
429 请求过于频繁。您已超出速率限制,请稍后再试。
500 服务器内部错误。服务器在执行请求时遇到了问题。
502 网关错误。作为网关或代理的服务器从上游服务器收到了无效响应。
503 服务不可用。服务器暂时无法处理请求(可能正在维护或过载),请稍后重试。
504 网关超时。作为网关或代理的服务器未能及时从上游服务器收到请求。
在线测试
此处将显示接口返回结果...
调用示例
 'YOUR_VALUE'];
$url .= '?' . http_build_query($params);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
$response = curl_exec($ch);

if (curl_errno($ch)) {
    die('请求失败: ' . curl_error($ch));
}
curl_close($ch);

// 解析 JSON 响应
$data = json_decode($response, true);
echo "code: " . ($data['code'] ?? 'N/A') . "\n";
echo "msg:  " . ($data['msg'] ?? $response);
?>
import requests

# 调用 API
url = "https://taoziwei.com/API/ip.php"
params = {
    'ip': 'YOUR_VALUE',
}

try:
    response = requests.get(url, params=params, timeout=10)
    response.raise_for_status()
    data = response.json()
    print(f"code: {data.get('code')}")
    print(f"msg:  {data.get('msg')}")
except requests.exceptions.RequestException as e:
    print(f"请求失败: {e}")
// 使用原生 fetch(浏览器/现代 Node.js)
const url = new URL('https://taoziwei.com/API/ip.php');
const params = {
    'ip': 'YOUR_VALUE',
};

Object.keys(params).forEach(key => url.searchParams.append(key, params[key]));

fetch(url, { method: 'GET' })
    .then(async response => {
        const data = await response.json();
        console.log('code:', data.code);
        console.log('msg: ', data.msg);
    })
    .catch(error => console.error('请求失败:', error));
// Node.js (需要先安装: npm install axios)
const axios = require('axios');

const url = 'https://taoziwei.com/API/ip.php';
const params = {
    'ip': 'YOUR_VALUE',};

axios.get(url, { params, timeout: 10000 })
    .then(response => {
        console.log('code:', response.data.code);
        console.log('msg: ', response.data.msg);
    })
    .catch(error => {
        if (error.response) {
            console.error('服务器返回错误:', error.response.status);
        } else {
            console.error('请求失败:', error.message);
        }
    });
# 使用 cURL 命令行调用 API
curl -X GET "https://taoziwei.com/API/ip.php" \
  --data-urlencode "ip=YOUR_VALUE" \
  --connect-timeout 10 \
  --max-time 30 \
  -H "Accept: application/json"

# 带 API Key 鉴权(如需):
# curl -X GET "https://taoziwei.com/API/ip.php?apikey=YOUR_API_KEY"
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;

public class ApiClient {
    public static void main(String[] args) throws Exception {
        StringBuilder urlBuilder = new StringBuilder("https://taoziwei.com/API/ip.php?");
        urlBuilder.append("ip=YOUR_VALUE&");
        String url = urlBuilder.toString();

        HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
        conn.setRequestMethod("GET");
        conn.setConnectTimeout(5000);
        conn.setReadTimeout(10000);
        conn.setRequestProperty("Accept", "application/json");

        try (BufferedReader br = new BufferedReader(
                new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8))) {
            StringBuilder response = new StringBuilder();
            String line;
            while ((line = br.readLine()) != null) response.append(line);
            System.out.println(response);
        } finally {
            conn.disconnect();
        }
    }
}
package main

import (
    "fmt"
    "io"
    "net/http"
    "net/url"
    "time"
)

func main() {
    // 构造 URL 与参数
    base, _ := url.Parse("https://taoziwei.com/API/ip.php")
    q := base.Query()
    q.Set("ip", "YOUR_VALUE")
    base.RawQuery = q.Encode()

    // 发送请求
    client := &http.Client{Timeout: 10 * time.Second}
    resp, err := client.Get(base.String())
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}