# 使用方法

### 接口地址

```
https://api.8i5.net/ip/
```

### 请求方式

```
GET/POST
```

### 返回实例

```
{"ip_address":"122.248.18.7","country":"Hong Kong","current_time":"2023-03-30 14:16:56"}
```

### 调用方法(PHP)

```
<?php
// 调用API
$response = file_get_contents('https://api.8i5.net/ip');

// 解析响应
$data = json_decode($response);

// 显示数据
echo 'IP地址：' . $_SERVER['REMOTE_ADDR'] . '<br>';
echo '国家/地区：' . $data->country . '<br>';
echo '当前时间：' . date('Y-m-d H:i:s') . '<br>';
?>
```

{% hint style="info" %}
这里包含了省市的归属地
{% endhint %}

JavaScript:

```
fetch('https://api.8i5.net/ip')
    .then(response => response.json())
    .then(data => {
        console.log(data.ip); // IP地址
        console.log(data.country); // 国家/地区信息
        console.log(data.time); // 当前时间
        // 在页面中显示数据
        document.getElementById("ip-address").textContent = data.ip;
        document.getElementById("country").textContent = data.country;
        document.getElementById("time").textContent = data.time;
    })
    .catch(error => console.error(error));

```

```
<p>IP地址：<span id="ip-address"></span></p>
<p>国家/地区：<span id="country"></span></p>
<p>当前时间：<span id="time"></span></p>
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://api-doc.8i5.net/ip-attribution/shi-yong-fang-fa.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
