🌐 IP 地址查询工具

查询中...
IP 地址 -
国家 -
省份/地区 -
城市 -
运营商 -
时区 -

    

📖 对接 API 代码示例

接口地址https://api.i110.cn/api/api.php
请求方式GET
返回格式JSON
认证方式URL 参数 key

📋 请求参数

参数名类型必填说明
keystringAPI 密钥(示例:无测试密钥
ipstring待查询的 IP 地址,留空自动获取请求方 IP

🔖 返回字段

codeint
状态码(0=成功)
messagestring
状态描述
data.ipstring
IP 地址
data.typestring
IP 类型(v4/v6)
data.countrystring
国家/地区
data.regionstring
省份/地区
data.citystring
城市
data.ispstring
运营商
data.continentstring
大洲
data.timezonestring
时区
data.offsetint
UTC 偏移(秒)

💻 代码示例

PHP
Python
Java
Node.js
C#
Go
Shell
<?php
// IP 地址查询 - PHP 示例
$apiKey = '无测试密钥';
$ip     = '8.8.8.8'; // 留空则查询本机

$url = "https://api.i110.cn/api/api.php?key=" . urlencode($apiKey)
     . "&ip=" . urlencode($ip);

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

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($httpCode === 200) {
    $data = json_decode($response, true);
    if ($data['code'] === 0) {
        echo "IP: " . $data['data']['ip'] . "\n";
        echo "国家: " . $data['data']['country'] . "\n";
        echo "省份: " . $data['data']['region'] . "\n";
        echo "城市: " . $data['data']['city'] . "\n";
        echo "运营商: " . $data['data']['isp'] . "\n";
    } else {
        echo "查询失败: " . $data['message'] . "\n";
    }
} else {
    echo "HTTP 请求失败,状态码: $httpCode\n";
}
?>
import requests

API_URL = "https://api.i110.cn/api/api.php"
API_KEY = "无测试密钥"

def query_ip(ip=""):
    params = {"key": API_KEY}
    if ip:
        params["ip"] = ip

    response = requests.get(API_URL, params=params, timeout=10)
    data = response.json()

    if data.get("code") == 0:
        info = data["data"]
        print(f"IP      : {info.get('ip')}")
        print(f"类型    : {info.get('type')}")
        print(f"国家    : {info.get('country')}")
        print(f"省份    : {info.get('region')}")
        print(f"城市    : {info.get('city')}")
        print(f"运营商  : {info.get('isp')}")
        print(f"时区    : {info.get('timezone')}")
    else:
        print(f"查询失败: {data.get('message')}")

# 查询指定 IP
query_ip("8.8.8.8")

# 查询本机 IP
# query_ip()
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Scanner;

public class IPQuery {
    private static final String API_URL = "https://api.i110.cn/api/api.php?key=无测试密钥&ip=8.8.8.8";

    public static void main(String[] args) {
        try {
            URL url = new URL(API_URL);
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setRequestMethod("GET");
            conn.setConnectTimeout(10000);

            Scanner scanner = new Scanner(conn.getInputStream(), "UTF-8");
            StringBuilder json = new StringBuilder();
            while (scanner.hasNext()) {
                json.append(scanner.nextLine());
            }
            scanner.close();
            conn.disconnect();

            System.out.println(json.toString());
            // 建议使用 Gson / Jackson 等库解析 JSON
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
const https = require('https');

const API_KEY = '无测试密钥';
const ip = '8.8.8.8'; // 留空查询本机

const url = `https://api.i110.cn/api/api.php?key=${API_KEY}&ip=${ip}`;

https.get(url, (res) => {
    let data = '';
    res.on('data', chunk => data += chunk);
    res.on('end', () => {
        const json = JSON.parse(data);
        if (json.code === 0) {
            console.log('IP      :', json.data.ip);
            console.log('国家    :', json.data.country);
            console.log('省份    :', json.data.region);
            console.log('城市    :', json.data.city);
            console.log('运营商  :', json.data.isp);
            console.log('时区    :', json.data.timezone);
        } else {
            console.error('查询失败:', json.message);
        }
    });
}).on('error', err => {
    console.error('请求错误:', err.message);
});
using System;
using System.Net.Http;
using System.Threading.Tasks;
using System.Text.Json;

class Program {
    static async Task Main() {
        using var client = new HttpClient();
        string url = "https://api.i110.cn/api/api.php?key=无测试密钥&ip=8.8.8.8";

        try {
            string json = await client.GetStringAsync(url);
            using var doc = JsonDocument.Parse(json);
            var root = doc.RootElement;

            if (root.GetProperty("code").GetInt32() == 0) {
                var data = root.GetProperty("data");
                Console.WriteLine($"IP      : {data.GetProperty("ip").GetString()}");
                Console.WriteLine($"国家    : {data.GetProperty("country").GetString()}");
                Console.WriteLine($"省份    : {data.GetProperty("region").GetString()}");
                Console.WriteLine($"城市    : {data.GetProperty("city").GetString()}");
                Console.WriteLine($"运营商  : {data.GetProperty("isp").GetString()}");
            }
        } catch (Exception ex) {
            Console.WriteLine($"请求失败: {ex.Message}");
        }
    }
}
package main

import (
	"encoding/json"
	"fmt"
	"io"
	"net/http"
	"time"
)

type APIResponse struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Data    struct {
		IP        string `json:"ip"`
		Type      string `json:"type"`
		Country   string `json:"country"`
		Region    string `json:"region"`
		City      string `json:"city"`
		Isp       string `json:"isp"`
		Timezone  string `json:"timezone"`
		Offset    int    `json:"offset"`
	} `json:"data"`
}

func main() {
	url := "https://api.i110.cn/api/api.php?key=无测试密钥&ip=8.8.8.8"

	client := &http.Client{Timeout: 10 * time.Second}
	resp, err := client.Get(url)
	if err != nil {
		fmt.Println("请求失败:", err)
		return
	}
	defer resp.Body.Close()

	body, _ := io.ReadAll(resp.Body)
	var result APIResponse
	json.Unmarshal(body, &result)

	if result.Code == 0 {
		fmt.Printf("IP      : %s\n", result.Data.IP)
		fmt.Printf("国家    : %s\n", result.Data.Country)
		fmt.Printf("省份    : %s\n", result.Data.Region)
		fmt.Printf("城市    : %s\n", result.Data.City)
		fmt.Printf("运营商  : %s\n", result.Data.Isp)
	} else {
		fmt.Printf("查询失败: %s\n", result.Message)
	}
}
# IP 地址查询 - Shell / cURL 示例
API_KEY="无测试密钥"
IP="8.8.8.8"

# 查询指定 IP
curl -s "https://api.i110.cn/api/api.php?key=${API_KEY}&ip=${IP}" | jq '.'

# 查询本机 IP(留空)
curl -s "https://api.i110.cn/api/api.php?key=${API_KEY}" | jq '.'

# 只提取城市
curl -s "https://api.i110.cn/api/api.php?key=${API_KEY}&ip=${IP}" \
  | jq -r '.data.city'