Files
aiaa-notification-server/docs/httpie/curls.md
T
ryan 0f9f154969 feat(规则): 支持名称代号,便于区分和管理
创建与更新规则时必填全局唯一 name,已有规则迁移回填为 rule-{id}。
2026-08-17 00:01:34 +08:00

8.8 KiB
Raw Blame History

HTTPie 可导入 cURL 集合

推荐: 直接导入 Postman 集合(一次导入全部)

docs/httpie/postman_collection.json

HTTPie → Import → Postman → 选择该文件。

单条导入: Import → cURL → 粘贴下方某一条完整 curl

替换占位符:

占位符 说明
http://localhost:8080 服务地址
admin-sk-change-me config.yamlserver.admin_key
SOURCE_API_KEY 创建 Source 返回的 api_key
:id / 1 资源数字 ID

Health

健康检查

curl -X GET 'http://localhost:8080/health'

Notify

发送通知(JSON

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

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

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

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

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

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

curl -X GET 'http://localhost:8080/api/v1/sources?page=1&page_size=20' \
  -H 'Authorization: Bearer admin-sk-change-me'

获取 Source

curl -X GET 'http://localhost:8080/api/v1/sources/1' \
  -H 'Authorization: Bearer admin-sk-change-me'

更新 Source

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

curl -X DELETE 'http://localhost:8080/api/v1/sources/1' \
  -H 'Authorization: Bearer admin-sk-change-me'

Templates

创建 Template

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

curl -X GET 'http://localhost:8080/api/v1/templates?page=1&page_size=20' \
  -H 'Authorization: Bearer admin-sk-change-me'

获取 Template

curl -X GET 'http://localhost:8080/api/v1/templates/1' \
  -H 'Authorization: Bearer admin-sk-change-me'

更新 Template

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

curl -X DELETE 'http://localhost:8080/api/v1/templates/1' \
  -H 'Authorization: Bearer admin-sk-change-me'

Channels

创建 ChannelEmail

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

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(企业微信)

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

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

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

列出 SafeW 群(创建渠道时)

curl -X POST 'http://localhost:8080/api/v1/channels/safew/chats' \
  -H 'Authorization: Bearer admin-sk-change-me' \
  -H 'Content-Type: application/json' \
  -d '{"token":"<bot token>","q":"测试AI"}'

列出 SafeW 群(已有渠道)

curl -X GET 'http://localhost:8080/api/v1/channels/1/chats?q=' \
  -H 'Authorization: Bearer admin-sk-change-me'

列出 Channel

curl -X GET 'http://localhost:8080/api/v1/channels?page=1&page_size=20' \
  -H 'Authorization: Bearer admin-sk-change-me'

获取 Channel

curl -X GET 'http://localhost:8080/api/v1/channels/1' \
  -H 'Authorization: Bearer admin-sk-change-me'

更新 Channel

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

curl -X DELETE 'http://localhost:8080/api/v1/channels/1' \
  -H 'Authorization: Bearer admin-sk-change-me'

Rules

创建 Rule

curl -X POST 'http://localhost:8080/api/v1/rules' \
  -H 'Authorization: Bearer admin-sk-change-me' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "trade-open-alert",
    "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

curl -X GET 'http://localhost:8080/api/v1/rules?page=1&page_size=20' \
  -H 'Authorization: Bearer admin-sk-change-me'

获取 Rule

curl -X GET 'http://localhost:8080/api/v1/rules/1' \
  -H 'Authorization: Bearer admin-sk-change-me'

更新 Rule

curl -X PUT 'http://localhost:8080/api/v1/rules/1' \
  -H 'Authorization: Bearer admin-sk-change-me' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "trade-open-alert",
    "source_name": "trading-system",
    "event": "trade.open",
    "template_name": "trade_open",
    "channels": ["email-ops"],
    "enabled": 1
  }'

删除 Rule

curl -X DELETE 'http://localhost:8080/api/v1/rules/1' \
  -H 'Authorization: Bearer admin-sk-change-me'

启用 Rule

curl -X PATCH 'http://localhost:8080/api/v1/rules/1/enable' \
  -H 'Authorization: Bearer admin-sk-change-me'

禁用 Rule

curl -X PATCH 'http://localhost:8080/api/v1/rules/1/disable' \
  -H 'Authorization: Bearer admin-sk-change-me'

启用规则下某渠道

curl -X PATCH 'http://localhost:8080/api/v1/rules/1/channels/1/enable' \
  -H 'Authorization: Bearer admin-sk-change-me'

禁用规则下某渠道

curl -X PATCH 'http://localhost:8080/api/v1/rules/1/channels/1/disable' \
  -H 'Authorization: Bearer admin-sk-change-me'

Message Logs

查询消息记录

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'