API 總覽與認證
公開 API 讀取商家的服務、人員、預約、顧客、收款與退款資料。欄位見〈資源與欄位〉,列表參數見〈分頁與篩選〉,錯誤格式見〈錯誤與限流〉。
請求格式
| 項目 | 內容 |
|---|---|
| 基底網址 | https://api.dolyu.com/v1 |
| 方法 | GET |
| 認證標頭 | Authorization: Bearer <API 金鑰> |
| 回應 | JSON |
| 回應標頭 | X-Request-Id:這次請求的編號,與錯誤內容的 request_id 相同 |
其他方法回 405 method_not_allowed。
API 金鑰
- 金鑰以
dolyu_sk_開頭。 - 擁有者與管理員在後台建立與撤銷金鑰,每家店最多 5 把。步驟、權限與到期見〈API 金鑰〉。
- 金鑰全文只在建立時顯示一次。
- 建立時可設定到期日。已撤銷或已到期的金鑰回 401
invalid_api_key。 - 金鑰只放在
Authorization標頭。GET請求的金鑰出現在網址或其他標頭(Cookie、Proxy-Authorization除外)時,這把金鑰會立即撤銷,請求回 401api_key_exposed。 - 一把金鑰只讀得到建立它的那家店的資料。
權限
建立金鑰時至少選一個權限。
| 權限 | 可用端點 |
|---|---|
| 不需要權限 | GET /merchant |
catalog:read | GET /services、GET /services/{id}、GET /staff、GET /staff/{id} |
appointments:read | GET /appointments、GET /appointments/{id} |
customers:read | GET /customers、GET /customers/{id} |
payments:read | GET /payments、GET /payments/{id}、GET /refunds、GET /refunds/{id} |
| 上面四個權限的任一個 | GET /events、GET /events/{id} |
- 金鑰沒有該端點需要的權限時回 403
insufficient_permission。 - 事件端點讀得到的事件類型依金鑰的權限而定,見〈事件〉。
- 金鑰沒有
customers:read時,預約裡的customer只有id與object,見〈資源與欄位〉。
端點
| 方法與路徑 | 回傳 |
|---|---|
GET /merchant | 金鑰所屬的商家 |
GET /services | 服務列表 |
GET /services/{id} | 單一服務 |
GET /staff | 人員列表 |
GET /staff/{id} | 單一人員 |
GET /appointments | 預約列表 |
GET /appointments/{id} | 單一預約 |
GET /customers | 顧客列表 |
GET /customers/{id} | 單一顧客 |
GET /payments | 收款列表 |
GET /payments/{id} | 單一收款 |
GET /refunds | 退款列表 |
GET /refunds/{id} | 單一退款 |
GET /events | 事件列表,見〈事件〉 |
GET /events/{id} | 單一事件 |
OpenAPI
端點、回應欄位與 Webhook 事件的 OpenAPI 3.1 描述檔:https://docs.dolyu.com/openapi/v1.json
範例
bash
curl https://api.dolyu.com/v1/merchant \
-H "Authorization: Bearer dolyu_sk_..."json
{
"id": "0198c5f0-0000-7000-8000-000000000001",
"object": "merchant",
"name": "範例工作室",
"slug": "example-studio",
"timezone": "Asia/Taipei",
"currency": "TWD",
"locale": "zh_TW"
}