站点监测API文档
本文档描述了站点监测系统提供的API接口。所有API返回JSON格式的数据。
API状态
检查API服务是否正常运行。
GET /api/status
响应示例
{
"status": "ok",
"timestamp": 1629123456,
"message": "站点监测API正常运行"
}
获取所有监控
获取所有监控站点的状态信息。
GET /api/monitors
参数
参数名 | 类型 | 必填 | 描述 |
---|---|---|---|
format | string | 否 | 返回格式,默认为json |
响应示例
{
"status": "ok",
"timestamp": 1629123456,
"monitors": [
{
"id": 123456,
"name": "示例网站",
"url": "https://example.com",
"type": "HTTP(s)",
"status": "Up",
"uptime_ratio_24h": "100",
"uptime_ratio_7d": "99.98",
"uptime_ratio_30d": "99.95",
"average_response_time": 186
},
// ...更多监控
]
}
获取单个监控详情
获取指定监控站点的详细信息。
GET /api/monitor?id={monitor_id}
参数
参数名 | 类型 | 必填 | 描述 |
---|---|---|---|
id | integer | 是 | 监控ID |
format | string | 否 | 返回格式,默认为json |
响应示例
{
"status": "ok",
"timestamp": 1629123456,
"monitor": {
"id": 123456,
"name": "示例网站",
"url": "https://example.com",
"type": "HTTP(s)",
"status": "Up",
"uptime_ratio_24h": "100",
"uptime_ratio_7d": "99.98",
"uptime_ratio_30d": "99.95",
"all_time_uptime_ratio": "99.92",
"average_response_time": 186,
"logs": [
{
"datetime": 1629120000,
"type": 2,
"duration": 0,
"reason": ""
},
// ...更多日志
]
}
}