第一個請求
本指南將帶你發送第一個 API 請求,確認金鑰設定正確。
| 項目 | 值 |
|---|---|
| Base URL | https://api.gm.kamigo.tw |
| 認證方式 | Bearer Token |
| 回應格式 | JSON |
使用 cURL
Section titled “使用 cURL”curl -X GET https://api.gm.kamigo.tw/api/me \ -H "Authorization: Bearer YOUR_API_KEY"使用 JavaScript
Section titled “使用 JavaScript”const response = await fetch('https://api.gm.kamigo.tw/api/me', { headers: { 'Authorization': 'Bearer YOUR_API_KEY' }});
const user = await response.json();console.log(user);使用 Python
Section titled “使用 Python”import requests
response = requests.get( 'https://api.gm.kamigo.tw/api/me', headers={'Authorization': 'Bearer YOUR_API_KEY'})
user = response.json()print(user)成功時(HTTP 200):
{ "userId": "U1234567890abcdef", "displayName": "你的名稱", "pictureUrl": "https://profile.line-scdn.net/...", "plan": "free", "quota": 524288000, "createdAt": "2025-01-15T08:00:00Z"}401 Unauthorized
Section titled “401 Unauthorized”{ "error": "Invalid or missing API key"}解決方式:
- 確認 API 金鑰正確
- 確認 Header 格式為
Authorization: Bearer <key> - 確認金鑰未過期或被刪除
403 Forbidden
Section titled “403 Forbidden”{ "error": "Insufficient permissions"}解決方式:
- 確認金鑰有足夠的權限
- 確認你是該群組的成員
429 Too Many Requests
Section titled “429 Too Many Requests”{ "error": "Rate limit exceeded", "retryAfter": 60}解決方式:
- 減少請求頻率
- 等待
retryAfter秒後重試
取得群組列表
Section titled “取得群組列表”確認連線成功後,試著取得你的群組列表:
curl -X GET https://api.gm.kamigo.tw/api/channels \ -H "Authorization: Bearer YOUR_API_KEY"回應:
{ "channels": [ { "channelId": "C1234567890", "name": "我的群組", "type": "group", "status": "active", "enabledAt": "2025-01-15T08:00:00Z" } ]}