Files
aiaa-notification-server/docs/httpie/curls.md
T
ryan 0d0cd0c510 feat: 新增 SafeW 出站通知渠道
通过 Bot API sendMessage 投递渲染后的通知,MarkdownV2 自动转义标题与正文。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-14 00:58:44 +08:00

414 lines
8.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# HTTPie 可导入 cURL 集合
**推荐:** 直接导入 Postman 集合(一次导入全部)
```
docs/httpie/postman_collection.json
```
HTTPie → Import → Postman → 选择该文件。
**单条导入:** Import → cURL → 粘贴下方某一条完整 `curl`
替换占位符:
| 占位符 | 说明 |
|--------|------|
| `http://localhost:8080` | 服务地址 |
| `admin-sk-change-me` | `config.yaml``server.admin_key` |
| `SOURCE_API_KEY` | 创建 Source 返回的 `api_key` |
| `:id` / `1` | 资源数字 ID |
---
## Health
### 健康检查
```bash
curl -X GET 'http://localhost:8080/health'
```
---
## Notify
### 发送通知(JSON
```bash
curl -X POST 'http://localhost:8080/api/v1/notify' \
-H 'Authorization: Bearer SOURCE_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"event": "trade.open",
"data": {
"symbol": "BTC",
"price": 65000
}
}'
```
### 发送通知(Regex
```bash
curl -X POST 'http://localhost:8080/api/v1/notify' \
-H 'Authorization: Bearer SOURCE_API_KEY' \
-H 'Content-Type: text/plain' \
--data-binary 'trade.open BTC 开仓 价格:65000'
```
### 发送通知(Textevent=default
```bash
curl -X POST 'http://localhost:8080/api/v1/notify' \
-H 'Authorization: Bearer SOURCE_API_KEY' \
-H 'Content-Type: text/plain' \
--data-binary 'BTC 突破 68000,请注意风险'
```
---
## Sources
### 创建 SourceJSON
```bash
curl -X POST 'http://localhost:8080/api/v1/sources' \
-H 'Authorization: Bearer admin-sk-change-me' \
-H 'Content-Type: application/json' \
-d '{
"name": "trading-system",
"parse_mode": "json",
"status": 1
}'
```
### 创建 SourceRegex
```bash
curl -X POST 'http://localhost:8080/api/v1/sources' \
-H 'Authorization: Bearer admin-sk-change-me' \
-H 'Content-Type: application/json' \
-d '{
"name": "legacy-monitor",
"parse_mode": "regex",
"parse_pattern": "(?P<event>\\w+)\\s+(?P<message>.+)"
}'
```
### 创建 SourceText
```bash
curl -X POST 'http://localhost:8080/api/v1/sources' \
-H 'Authorization: Bearer admin-sk-change-me' \
-H 'Content-Type: application/json' \
-d '{
"name": "alert-bot",
"parse_mode": "text"
}'
```
### 列出 Source
```bash
curl -X GET 'http://localhost:8080/api/v1/sources?page=1&page_size=20' \
-H 'Authorization: Bearer admin-sk-change-me'
```
### 获取 Source
```bash
curl -X GET 'http://localhost:8080/api/v1/sources/1' \
-H 'Authorization: Bearer admin-sk-change-me'
```
### 更新 Source
```bash
curl -X PUT 'http://localhost:8080/api/v1/sources/1' \
-H 'Authorization: Bearer admin-sk-change-me' \
-H 'Content-Type: application/json' \
-d '{
"name": "trading-system",
"parse_mode": "json",
"status": 1
}'
```
### 删除 Source
```bash
curl -X DELETE 'http://localhost:8080/api/v1/sources/1' \
-H 'Authorization: Bearer admin-sk-change-me'
```
---
## Templates
### 创建 Template
```bash
curl -X POST 'http://localhost:8080/api/v1/templates' \
-H 'Authorization: Bearer admin-sk-change-me' \
-H 'Content-Type: application/json' \
-d '{
"name": "trade_open",
"content": "### {{.symbol}} 开仓\n价格: {{.price}}"
}'
```
### 列出 Template
```bash
curl -X GET 'http://localhost:8080/api/v1/templates?page=1&page_size=20' \
-H 'Authorization: Bearer admin-sk-change-me'
```
### 获取 Template
```bash
curl -X GET 'http://localhost:8080/api/v1/templates/1' \
-H 'Authorization: Bearer admin-sk-change-me'
```
### 更新 Template
```bash
curl -X PUT 'http://localhost:8080/api/v1/templates/1' \
-H 'Authorization: Bearer admin-sk-change-me' \
-H 'Content-Type: application/json' \
-d '{
"name": "trade_open",
"content": "### {{.symbol}} 开仓\n价格: {{.price}}"
}'
```
### 删除 Template
```bash
curl -X DELETE 'http://localhost:8080/api/v1/templates/1' \
-H 'Authorization: Bearer admin-sk-change-me'
```
---
## Channels
### 创建 ChannelEmail
```bash
curl -X POST 'http://localhost:8080/api/v1/channels' \
-H 'Authorization: Bearer admin-sk-change-me' \
-H 'Content-Type: application/json' \
-d '{
"name": "email-ops",
"type": "email",
"config": {
"to": ["148516886@qq.com"]
},
"status": 1
}'
```
### 创建 Channel(钉钉)
```bash
curl -X POST 'http://localhost:8080/api/v1/channels' \
-H 'Authorization: Bearer admin-sk-change-me' \
-H 'Content-Type: application/json' \
-d '{
"name": "dingtalk-prod",
"type": "dingtalk",
"config": {
"webhook_url": "https://oapi.dingtalk.com/robot/send?access_token=xxx",
"secret": "SEC..."
},
"status": 1
}'
```
### 创建 Channel(企业微信)
```bash
curl -X POST 'http://localhost:8080/api/v1/channels' \
-H 'Authorization: Bearer admin-sk-change-me' \
-H 'Content-Type: application/json' \
-d '{
"name": "wecom-ops",
"type": "wecom",
"config": {
"webhook_url": "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxx"
},
"status": 1
}'
```
### 创建 ChannelBark
```bash
curl -X POST 'http://localhost:8080/api/v1/channels' \
-H 'Authorization: Bearer admin-sk-change-me' \
-H 'Content-Type: application/json' \
-d '{
"name": "bark-phone",
"type": "bark",
"config": {
"url": "https://api.day.app/<device_key>"
},
"status": 1
}'
```
### 创建 ChannelSafeW
```bash
curl -X POST 'http://localhost:8080/api/v1/channels' \
-H 'Authorization: Bearer admin-sk-change-me' \
-H 'Content-Type: application/json' \
-d '{
"name": "safew-ops",
"type": "safew",
"config": {
"token": "<bot token>",
"chat_id": "123456789"
},
"status": 1
}'
```
### 列出 Channel
```bash
curl -X GET 'http://localhost:8080/api/v1/channels?page=1&page_size=20' \
-H 'Authorization: Bearer admin-sk-change-me'
```
### 获取 Channel
```bash
curl -X GET 'http://localhost:8080/api/v1/channels/1' \
-H 'Authorization: Bearer admin-sk-change-me'
```
### 更新 Channel
```bash
curl -X PUT 'http://localhost:8080/api/v1/channels/1' \
-H 'Authorization: Bearer admin-sk-change-me' \
-H 'Content-Type: application/json' \
-d '{
"name": "email-ops",
"type": "email",
"config": {
"to": ["148516886@qq.com"]
},
"status": 1
}'
```
### 删除 Channel
```bash
curl -X DELETE 'http://localhost:8080/api/v1/channels/1' \
-H 'Authorization: Bearer admin-sk-change-me'
```
---
## Rules
### 创建 Rule
```bash
curl -X POST 'http://localhost:8080/api/v1/rules' \
-H 'Authorization: Bearer admin-sk-change-me' \
-H 'Content-Type: application/json' \
-d '{
"source_name": "trading-system",
"event": "trade.open",
"template_name": "trade_open",
"channels": ["email-ops"],
"conditions": [
{"field": "symbol", "op": "exists"},
{"field": "price", "op": "gt", "value": "0"}
],
"enabled": 1
}'
```
### 列出 Rule
```bash
curl -X GET 'http://localhost:8080/api/v1/rules?page=1&page_size=20' \
-H 'Authorization: Bearer admin-sk-change-me'
```
### 获取 Rule
```bash
curl -X GET 'http://localhost:8080/api/v1/rules/1' \
-H 'Authorization: Bearer admin-sk-change-me'
```
### 更新 Rule
```bash
curl -X PUT 'http://localhost:8080/api/v1/rules/1' \
-H 'Authorization: Bearer admin-sk-change-me' \
-H 'Content-Type: application/json' \
-d '{
"source_name": "trading-system",
"event": "trade.open",
"template_name": "trade_open",
"channels": ["email-ops"],
"enabled": 1
}'
```
### 删除 Rule
```bash
curl -X DELETE 'http://localhost:8080/api/v1/rules/1' \
-H 'Authorization: Bearer admin-sk-change-me'
```
### 启用 Rule
```bash
curl -X PATCH 'http://localhost:8080/api/v1/rules/1/enable' \
-H 'Authorization: Bearer admin-sk-change-me'
```
### 禁用 Rule
```bash
curl -X PATCH 'http://localhost:8080/api/v1/rules/1/disable' \
-H 'Authorization: Bearer admin-sk-change-me'
```
### 启用规则下某渠道
```bash
curl -X PATCH 'http://localhost:8080/api/v1/rules/1/channels/1/enable' \
-H 'Authorization: Bearer admin-sk-change-me'
```
### 禁用规则下某渠道
```bash
curl -X PATCH 'http://localhost:8080/api/v1/rules/1/channels/1/disable' \
-H 'Authorization: Bearer admin-sk-change-me'
```
---
## Message Logs
### 查询消息记录
```bash
curl -X GET 'http://localhost:8080/api/v1/message-logs?source=trading-system&event=trade.open&status=success&page=1&page_size=20' \
-H 'Authorization: Bearer admin-sk-change-me'
```