API 概覽
群組GM API 遵循 RESTful 設計原則,使用 JSON 作為資料交換格式。
| 項目 | 值 |
|---|---|
| Base URL | https://api.gm.kamigo.tw |
| 協定 | HTTPS |
| 認證方式 | Bearer Token |
| 回應格式 | JSON |
| 字元編碼 | UTF-8 |
API 端點列表
Section titled “API 端點列表”| 方法 | 端點 | 說明 |
|---|---|---|
| GET | /api/me | 取得目前使用者資訊 |
| GET | /api/usage | 取得用量統計 |
| 方法 | 端點 | 說明 |
|---|---|---|
| GET | /api/channels | 取得群組列表 |
| GET | /api/channels/:id | 取得群組詳情 |
| GET | /api/channels/:id/members | 取得群組成員 |
| 方法 | 端點 | 說明 |
|---|---|---|
| GET | /api/channels/:id/assistant/config | 取得助理設定 |
| PUT | /api/channels/:id/assistant/config | 更新助理設定 |
| GET | /api/channels/:id/assistant/qa | 取得自動回覆規則 |
| POST | /api/channels/:id/assistant/qa | 新增自動回覆規則 |
| PUT | /api/channels/:id/assistant/qa/:qaId | 更新自動回覆規則 |
| DELETE | /api/channels/:id/assistant/qa/:qaId | 刪除自動回覆規則 |
| GET | /api/channels/:id/assistant/welcome | 取得歡迎訊息 |
| PUT | /api/channels/:id/assistant/welcome | 更新歡迎訊息 |
| GET | /api/channels/:id/assistant/rules | 取得群組規則 |
| PUT | /api/channels/:id/assistant/rules | 更新群組規則 |
| 方法 | 端點 | 說明 |
|---|---|---|
| POST | /api/channels/:id/backup/subscribe | 訂閱備份 |
| DELETE | /api/channels/:id/backup/subscribe | 取消訂閱 |
| GET | /api/channels/:id/backup/messages | 取得訊息列表 |
| GET | /api/channels/:id/backup/messages/:msgId | 取得單一訊息 |
| GET | /api/channels/:id/backup/media | 取得媒體列表 |
| GET | /api/channels/:id/backup/media/:msgId | 下載媒體檔案 |
Headers
Section titled “Headers”Authorization: Bearer YOUR_API_KEYContent-Type: application/jsoncurl -X POST https://api.gm.kamigo.tw/api/channels/C123/assistant/qa \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "keywords": ["營業時間"], "question": "營業時間是?", "answer": "週一至週五 9:00-18:00" }'{ "data": { ... }}或直接回傳資料物件:
{ "channelId": "C123", "name": "我的群組", ...}{ "error": "錯誤訊息描述"}HTTP 狀態碼
Section titled “HTTP 狀態碼”| 狀態碼 | 說明 |
|---|---|
| 200 | 成功 |
| 201 | 建立成功 |
| 400 | 請求參數錯誤 |
| 401 | 認證失敗 |
| 403 | 權限不足 |
| 404 | 資源不存在 |
| 429 | 請求過於頻繁 |
| 500 | 伺服器錯誤 |
使用游標(cursor)進行分頁:
GET /api/channels/C123/backup/messages?limit=50&cursor=msg_100回應包含 nextCursor:
{ "messages": [...], "nextCursor": "msg_150"}當 nextCursor 為 null 時,表示沒有更多資料。
日期時間格式
Section titled “日期時間格式”所有日期時間使用 ISO 8601 格式:
2025-01-15T08:30:00Z查詢日期參數使用 YYYY-MM-DD:
?date=2025-01-15