Notify Hub API
Notify Hub 是一个面向 Android 的实时提醒中枢。本文档覆盖当前服务端提供的登录、设备、通知与用户管理接口。
Base URL
- 生产环境:
https://notify.zbcode.cn/api - 服务健康检查:
GET /api/health
Authentication
除登录与通用 webhook 外,其余接口都需要在请求头中携带:
Authorization: Bearer <access_token>
Endpoints
GET /api/health
返回当前服务状态。
POST /api/auth/login
账户登录并返回会话信息。
请求体:
{
"username": "zhubin",
"password": "zhubin666"
}
GET /api/auth/me
返回当前登录用户信息。
GET /api/devices
返回当前用户名下已注册的设备列表。
POST /api/devices/register
注册或更新当前设备。
请求体:
{
"deviceId": "android-device-id",
"deviceName": "Xiaomi 14"
}
GET /api/notifications
返回当前用户可见的通知列表,按时间倒序排列。
POST /api/notifications/webhook
通用通知接入入口,可由脚本、轮询器或外部系统直接调用。
请求体:
{
"title": "票务监测发现新的结果",
"body": "目标票档已锁定,请立即完成后续处理。",
"sourceName": "Ticket Worker",
"level": "critical",
"targetUsernames": ["zhubin"]
}
字段说明:
title:通知标题body:通知正文sourceName:来源标识level:critical/important/normaltargetUsernames:目标用户名数组
GET /api/users
管理员接口,返回全部用户列表。
POST /api/users
管理员接口,创建新用户。
请求体:
{
"username": "demo",
"password": "demo123456",
"role": "user"
}
Common Response Notes
- 成功时返回 JSON
- 参数错误时返回
400 - 未认证时返回
401 - 权限不足时返回
403
Quick Test
登录:
curl -X POST https://notify.zbcode.cn/api/auth/login \
-H 'Content-Type: application/json' \
-d '{
"username": "zhubin",
"password": "zhubin666"
}'
发送一条 webhook:
curl -X POST https://notify.zbcode.cn/api/notifications/webhook \
-H 'Content-Type: application/json' \
-d '{
"title": "新的重点提醒",
"body": "这是一条来自文档示例的通知。",
"sourceName": "Studio",
"level": "important",
"targetUsernames": ["zhubin"]
}'