API文档
v1.0
基础URL:
https://amd.ltzy.top 或 http://127.0.0.1:5002
API接口列表
1. 获取CPU列表
接口地址: GET /api/cpu
请求参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| limit | int | 否 | 返回数量限制,默认返回全部 |
| format | string | 否 | 返回格式: json(默认) / xml |
请求示例:
GET /api/cpu?limit=5
GET /api/cpu?format=xml
返回示例:
{
"success": true,
"total": 5,
"data": [
{
"model_full_name": "AMD Ryzen 9 9950X",
"total_cores": 16,
"total_threads": 32,
"base_frequency_ghz": 4.3,
"max_boost_frequency_ghz": 5.7,
"tdp_w": 170,
...
}
]
}
2. 获取CPU详情
接口地址: GET /api/cpu/{slug}
路径参数:
| 参数名 | 类型 | 说明 |
|---|---|---|
| slug | string | CPU的URL标识,如 amd-ryzen-9-9950x |
请求示例:
GET /api/cpu/amd-ryzen-9-9950x
GET /api/cpu/amd-ryzen-7-7800x3d
返回示例:
{
"success": true,
"data": {
"brand": "AMD",
"model_full_name": "AMD Ryzen 9 9950X",
"series": "Ryzen 9000 Series",
"codename": "Granite Ridge",
"architecture_codename": "Zen 5",
"cpu_microarchitecture": "Zen 5",
"process_node": "TSMC 4nm FinFET",
"total_cores": 16,
"total_threads": 32,
"base_frequency_ghz": 4.3,
"max_boost_frequency_ghz": 5.7,
"tdp_w": 170,
"socket": "Socket AM5",
"l3_cache_total": "64 MB",
...
}
}
3. 搜索CPU
接口地址: GET /api/search
请求参数:
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| q | string | 是 | 搜索关键词 |
| limit | int | 否 | 返回数量限制,默认20 |
请求示例:
GET /api/search?q=ryzen
GET /api/search?q=9950x&limit=5
GET /api/search?q=zen+5
返回示例:
{
"success": true,
"query": "ryzen",
"total": 15,
"data": [...]
}
4. 获取统计数据
接口地址: GET /api/statistics
请求示例:
GET /api/statistics
返回示例:
{
"success": true,
"data": {
"total": 202,
"year_span": 33,
"architectures": {
"Zen 5": 5,
"Zen 4": 8,
"Zen 3": 5,
...
},
"decades": {
"1980": 5,
"1990": 25,
"2000": 35,
"2010": 45,
"2020": 92
}
}
}
5. 获取系列列表
接口地址: GET /api/series
请求示例:
GET /api/series
返回示例:
{
"success": true,
"data": {
"ryzen": {"name": "Ryzen系列", "families": [...]},
"epyc": {"name": "EPYC系列", "families": [...]},
...
}
}
数据字段说明
| 字段名 | 类型 | 说明 |
|---|---|---|
| brand | string | 品牌 (AMD) |
| model_full_name | string | 产品型号全称 |
| series | string | 所属系列 |
| codename | string | 产品代号 |
| architecture_codename | string | 架构代号 |
| cpu_microarchitecture | string | CPU微架构 |
| process_node | string | 制程工艺 |
| total_cores | int | 总核心数 |
| total_threads | int | 总线程数 |
| base_frequency_ghz | float | 基础频率 (GHz) |
| max_boost_frequency_ghz | float | 最大加速频率 (GHz) |
| tdp_w | int | 热设计功耗 (W) |
| socket | string | 插槽类型 |
| l3_cache_total | string | 三级缓存总量 |
| release_year | string | 发布日期 |
| msrp_usd | int | 官方建议零售价 (美元) |
| url_slug | string | URL标识 |
错误码说明
| HTTP状态码 | 说明 |
|---|---|
| 200 | 请求成功 |
| 400 | 请求参数错误 |
| 404 | 资源不存在 |
| 500 | 服务器内部错误 |
调用示例
JavaScript (Fetch API)
fetch('https://amd.ltzy.top/api/cpu?limit=5')
.then(response => response.json())
.then(data => console.log(data));
Python (requests)
import requests
response = requests.get('https://amd.ltzy.top/api/cpu/amd-ryzen-9-9950x')
data = response.json()
print(data)
cURL
curl "https://amd.ltzy.top/api/statistics"
curl "https://amd.ltzy.top/api/search?q=ryzen"
注意: API调用频率建议不超过每秒10次,请合理使用。