APP API 文件

将 EstaCaido 与您的应用程序整合

快速入门

EstaCaido API 让你可以通过自己的代码管理监控、查看事件、配置告警等。所有 API 端点的请求和响应正文都使用 JSON。

基础 URL

https://www.estacaido.com/api/v1/

速率限制

每个 API 令牌每分钟最多可发出 100 个请求。超过限制将返回 429 Too Many Requests 响应。

身份验证

所有 API 请求都使用基于令牌的身份验证。请在 Authorization 请求头中包含你的令牌。

获取身份验证令牌

POST /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 请求头中使用令牌

Authorization: Token your-api-token-here

监控

管理你的网站监控。

监控列表

GET /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"
  }
]

创建监视器

POST /api/v1/monitors/
参数
name 必填 监控名称
domain 必填 要监控的域名,例如 example.com
check_interval 可选 检查间隔(秒),可选值:30, 60, 300, 600, 900, 1800, 3600。默认:300
check_type 可选 以下值之一:http, https, ping。默认值:https

获取监控

GET /api/v1/monitors/{id}/

更新监控

PUT /api/v1/monitors/{id}/

删除监控

DELETE /api/v1/monitors/{id}/

暂停监控

POST /api/v1/monitors/{id}/pause/

恢复监控

POST /api/v1/monitors/{id}/resume/

获取监控统计

GET /api/v1/monitors/{id}/statistics/
参数
days 可选 包含的天数。默认: 30

事件

查看宕机事件及其历史记录。

事件列表

GET /api/v1/incidents/
参数
status 可选 按状态筛选: ongoing, resolved
monitor 可选 按监控 ID 筛选

获取事件

GET /api/v1/incidents/{id}/

告警

为你的监控配置告警通知。

告警列表

GET /api/v1/alerts/

创建告警

POST /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)

更新告警

PUT /api/v1/alerts/{id}/

删除告警

DELETE /api/v1/alerts/{id}/

状态页

创建和管理公开状态页。

状态页列表

GET /api/v1/status-pages/

创建状态页

POST /api/v1/status-pages/
参数
title 必填 状态页标题
slug 必填 URL 别名 (例如 my-status-page)
description 可选 描述文本
is_public 可选 设为公开访问 (默认: true)

团队

管理团队访问和协作。

团队列表

GET /api/v1/teams/

创建团队

POST /api/v1/teams/

获取团队

GET /api/v1/teams/{id}/

代码示例

Python

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())

JavaScript

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));

cURL

# 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}'

准备好开始了吗?

免费注册并获取 API 令牌,即可开始集成。

免费注册 获取 API 令牌