将 EstaCaido 与您的应用程序整合
EstaCaido API 让你可以通过自己的代码管理监控、查看事件、配置告警等。所有 API 端点的请求和响应正文都使用 JSON。
https://www.estacaido.com/api/v1/
每个 API 令牌每分钟最多可发出 100 个请求。超过限制将返回 429 Too Many Requests 响应。
所有 API 请求都使用基于令牌的身份验证。请在 Authorization 请求头中包含你的令牌。
/api/v1/auth/token/
curl -X POST https://www.estacaido.com/api/v1/auth/token/ \
-H "Content-Type: application/json" \
-d '{"username": "your@email.com", "password": "yourpassword"}'
{
"token": "your-api-token-here"
}
Authorization: Token your-api-token-here
管理你的网站监控。
/api/v1/monitors/
[
{
"id": 1,
"name": "Production API",
"company": {
"id": 1,
"website": "api.example.com"
},
"check_type": "http",
"check_interval": 300,
"is_active": true,
"is_paused": false,
"last_check_at": "2024-01-15T10:30:00Z",
"created_at": "2024-01-01T00:00:00Z"
}
]
/api/v1/monitors/
name |
必填 | 监控名称 |
domain |
必填 | 要监控的域名,例如 example.com |
check_interval |
可选 | 检查间隔(秒),可选值:30, 60, 300, 600, 900, 1800, 3600。默认:300 |
check_type |
可选 | 以下值之一:http, https, ping。默认值:https |
/api/v1/monitors/{id}/
/api/v1/monitors/{id}/
/api/v1/monitors/{id}/
/api/v1/monitors/{id}/pause/
/api/v1/monitors/{id}/resume/
/api/v1/monitors/{id}/statistics/
days |
可选 | 包含的天数。默认: 30 |
查看宕机事件及其历史记录。
/api/v1/incidents/
status |
可选 | 按状态筛选: ongoing, resolved |
monitor |
可选 | 按监控 ID 筛选 |
/api/v1/incidents/{id}/
为你的监控配置告警通知。
/api/v1/alerts/
/api/v1/alerts/
monitor |
必填 | 监控 ID |
alert_type |
必填 | 以下值之一:email, sms, slack, discord, webhook, pagerduty, teams |
recipients |
必填 | 收件人地址或 Webhook URL |
alert_on_down |
可选 | 网站宕机时通知 (默认: true) |
alert_on_recovery |
可选 | 网站恢复时通知 (默认: true) |
/api/v1/alerts/{id}/
/api/v1/alerts/{id}/
创建和管理公开状态页。
/api/v1/status-pages/
/api/v1/status-pages/
title |
必填 | 状态页标题 |
slug |
必填 | URL 别名 (例如 my-status-page) |
description |
可选 | 描述文本 |
is_public |
可选 | 设为公开访问 (默认: true) |
管理团队访问和协作。
/api/v1/teams/
/api/v1/teams/
/api/v1/teams/{id}/
import requests
API_TOKEN = 'your-api-token'
BASE_URL = 'https://www.estacaido.com/api/v1'
headers = {
'Authorization': f'Token {API_TOKEN}',
'Content-Type': 'application/json'
}
# List all monitors
response = requests.get(f'{BASE_URL}/monitors/', headers=headers)
monitors = response.json()
print(monitors)
# Create a new monitor
new_monitor = {
'name': 'My Website',
'domain': 'example.com',
'check_interval': 300
}
response = requests.post(f'{BASE_URL}/monitors/', json=new_monitor, headers=headers)
print(response.json())
const API_TOKEN = 'your-api-token';
const BASE_URL = 'https://www.estacaido.com/api/v1';
const headers = {
'Authorization': `Token ${API_TOKEN}`,
'Content-Type': 'application/json'
};
// List all monitors
fetch(`${BASE_URL}/monitors/`, { headers })
.then(res => res.json())
.then(monitors => console.log(monitors));
// Create a new monitor
fetch(`${BASE_URL}/monitors/`, {
method: 'POST',
headers,
body: JSON.stringify({
name: 'My Website',
domain: 'example.com',
check_interval: 300
})
})
.then(res => res.json())
.then(data => console.log(data));
# List all monitors
curl -X GET https://www.estacaido.com/api/v1/monitors/ \
-H "Authorization: Token your-api-token"
# Create a new monitor
curl -X POST https://www.estacaido.com/api/v1/monitors/ \
-H "Authorization: Token your-api-token" \
-H "Content-Type: application/json" \
-d '{"name": "My Website", "domain": "example.com", "check_interval": 300}'