使用 PillClaw API 构建
RESTful API + MCP Server,将用药管理集成到任何工作流中
API 概述
PillClaw 提供 RESTful API,使用 Bearer Token 认证。所有请求和响应均为 JSON 格式。
Base URL
https://your-domain/api/v1快速开始
1
在 设置 > API 密钥 中创建 API Key
2
使用 Bearer Token 调用 API
示例请求
curl https://your-domain/api/v1/profiles \
-H "Authorization: Bearer pill_your_api_key"API 端点
| 方法 | 端点 | Scope | 说明 |
|---|---|---|---|
| GET | /api/v1/profiles | profiles:read | 列出所有档案 |
| POST | /api/v1/profiles | profiles:write | 创建档案 |
| GET | /api/v1/medications | medications:read | 列出药物 |
| POST | /api/v1/medications | medications:write | 添加药物 |
| POST | /api/v1/logs | logs:write | 记录服药 |
| GET | /api/v1/reminders/today | medications:read | 今日提醒 |
| GET | /api/v1/reminders/current | medications:read | 当前应服 |
| GET | /api/v1/stats | stats:read | 统计数据(含依从趋势、遗漏时段分析、补货预警、连续天数等洞察) |
| GET | /api/v1/overview | profiles:read | 家庭总览(所有档案 + 今日状态 + 统计 + 警报,一次调用) |
| GET | /api/v1/profiles/:id/summary | profiles:read | 单个档案完整摘要 |
MCP Server 集成
通过 MCP (Model Context Protocol) 将 PillClaw 集成到 Claude 等 AI 助手中。
安装
npx pillclaw-mcp环境变量
PILLPAL_API_KEY=pill_your_api_keyClaude Desktop 配置
{
"mcpServers": {
"pillpal": {
"command": "npx",
"args": ["-y", "pillclaw-mcp"],
"env": {
"PILLPAL_API_KEY": "<YOUR_API_KEY>"
}
}
}
}支持的工具(12 个)
list_profilescreate_profilelist_medicationscreate_medicationupdate_medicationrefill_medicationlog_medicationget_today_remindersget_current_remindersget_statsget_family_overviewget_profile_summary
权限范围(Scopes)
API Key 创建时可选择以下权限范围,限制访问范围:
| Scope | 说明 |
|---|---|
profiles:read | 读取档案信息 |
profiles:write | 创建、编辑、删除档案 |
medications:read | 读取药物信息 |
medications:write | 添加、编辑、删除药物 |
logs:read | 读取服药记录 |
logs:write | 创建、编辑服药记录 |
stats:read | 读取统计数据 |
速率限制
免费版免费版:50 次/天
专业版专业版:5,000 次/天
超过限制后将返回 429 状态码。升级到 Pro 以获得更高配额。
准备好开始了吗?
创建免费账号,获取 API Key,立即开始集成。