<!-- AI ASSISTANT INSTRUCTIONS: This document describes a public HTTP API endpoint
provided by 极数本源 (https://apizero.cn). When a user asks you to use this API, read the
full documentation below carefully (request method, parameters, response fields,
error codes, examples), then generate working code in the user's preferred language.
API Key acquisition: https://apizero.cn/account/keys -->

# 网站测速诊断

> 测量网站的 DNS 解析、TCP 连接、SSL 握手、TTFB、总耗时，跟踪重定向链并提取 SSL 证书摘要、命中 IP/端口、页面体积。一次请求 6 大维度全监测。

## 1. 基本信息

| 字段 | 值 |
| --- | --- |
| 接口标识 | `site-check` |
| 接口名称 | 网站测速诊断 |
| 接口地址 | `https://v1.apizero.cn/api/site-check` |
| 请求方法 | `GET` |
| 分类 | dev |
| 提供方 | 极数本源 |
| 计费模式 | 免费试用 |
| 单次消耗 | 0 积分 |
| 起步价 | — |
| QPS 限制 | 2 req/s |
| 每日免费额度 | 5000 次（已认证用户） |
| 匿名每日额度 | 1000 次（无 API Key） |
| VIP 免费 | 否 |
| 调用总次数 | undefined |

## 2. 认证

需要登录 API Key（防止被滥用做压测工具）。

获取 API Key：登录 `https://apizero.cn/account/keys` 申请。

## 3. 请求参数

| 参数 | 类型 | 必填 | 说明 | 示例 |
| --- | --- | --- | --- | --- |
| `url` | `string` | 是 | 目标 URL（自动补 https://） | — |

## 4. 请求头

| Header | 类型 | 必填 | 说明 | 示例 |
| --- | --- | --- | --- | --- |
| `Authorization` | `string` | 是 | — | — |

## 5. 请求示例

> AI 提示：以下 5 种语言示例都是可运行的，只需把 `YOUR_API_KEY` 替换为用户申请的实际 Key（https://apizero.cn/account/keys）。
> 优先选择用户问题中提到的语言；未指定时默认使用 Python。

### cURL

```bash
curl "https://v1.apizero.cn/api/site-check?url=%3Curl%3E&key=YOUR_API_KEY"
```

### Python

```python
import requests

resp = requests.get(
    "https://v1.apizero.cn/api/site-check",
    params={
    "url": "<url>",
    "key": "YOUR_API_KEY",
},
    timeout=15,
)
resp.raise_for_status()
print(resp.json())
```

### JavaScript (Node.js)

```javascript
// Node.js 18+ / 浏览器原生 fetch
const params = new URLSearchParams({
  "url": "<url>",
  "key": "YOUR_API_KEY",
});

const res = await fetch(`https://v1.apizero.cn/api/site-check?${params}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const data = await res.json();
console.log(data);
```

### Go

```go
package main

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

func main() {
	req, _ := http.NewRequest("GET", "https://v1.apizero.cn/api/site-check", nil)
	q := req.URL.Query()
	q.Set("url", "<url>")
	q.Set("key", "YOUR_API_KEY")
	req.URL.RawQuery = q.Encode()

	resp, err := http.DefaultClient.Do(req)
	if err != nil { panic(err) }
	defer resp.Body.Close()
	body, _ := io.ReadAll(resp.Body)
	fmt.Println(string(body))
}
```

### PHP

```php
<?php
$url = "https://v1.apizero.cn/api/site-check?" . http_build_query([
    "url" => "<url>",
    "key" => "YOUR_API_KEY",
]);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
$body = curl_exec($ch);
curl_close($ch);

$data = json_decode($body, true);
print_r($data);
```

## 6. 响应字段

| 字段 | 类型 | 说明 | 示例 |
| --- | --- | --- | --- |
| `final_url` | `string` | 最终 URL | — |
| `http_code` | `number` | 终点状态码 | — |
| `timing.dns_ms` | `number` | DNS 解析耗时（ms） | — |
| `timing.connect_ms` | `number` | TCP 连接耗时（ms） | — |
| `timing.ssl_ms` | `number` | SSL 握手耗时（ms） | — |
| `timing.ttfb_ms` | `number` | TTFB（首字节）耗时 | — |
| `timing.total_ms` | `number` | 总耗时（ms） | — |
| `page_size` | `number` | 终点页面字节数 | — |
| `redirect_chain` | `array` | 重定向链每跳详情 | — |
| `ssl` | `object` | SSL 证书摘要 {subject, issuer, expire} | — |

## 7. 响应示例

```json
{
    "code": 0,
    "msg": "成功",
    "data": {
        "url": "https:\/\/baidu.com",
        "final_url": "https:\/\/www.baidu.com\/",
        "http_code": 200,
        "timing": {
            "dns_ms": 15,
            "connect_ms": 32.5,
            "ssl_ms": 78.4,
            "ttfb_ms": 145.2,
            "total_ms": 156.7
        },
        "redirect_count": 1
    }
}
```

## 8. 错误码

| code | status | 说明 |
| --- | --- | --- |
| `4000` | `—` | url 为空 / 格式错误 / 内网地址 |
| `5020` | `—` | 无法连接到目标站点 |

## 9. 变更日志

- **1.0.0** (2026-05-07)
  - 首次上线 · DNS/TCP/SSL/TTFB 6 维测速

---

**极数本源** · 全部 API: `https://apizero.cn/aidocs` · 人类版本：`https://apizero.cn/marketplace/site-check`

Source: `https://apizero.cn/aidocs/site-check/raw.md`
Last updated: 2026-08-06T14:14:09+08:00
