Skip to content
API最後更新

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 除外)時,這把金鑰會立即撤銷,請求回 401 api_key_exposed。
  • 一把金鑰只讀得到建立它的那家店的資料。

權限 ​

建立金鑰時至少選一個權限。

權限可用端點
不需要權限GET /merchant
catalog:readGET /services、GET /services/{id}、GET /staff、GET /staff/{id}
appointments:readGET /appointments、GET /appointments/{id}
customers:readGET /customers、GET /customers/{id}
payments:readGET /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"
}

實作要點 ​

  • 回應裡不認得的欄位直接略過。
  • 列表以 next_cursor 逐頁讀取,到 has_more 是 false 為止,見〈分頁與篩選〉。
  • 收到 429 時,等 Retry-After 的秒數後重試,見〈錯誤與限流〉。
  • 以 updated_at[gte] 定期取回有變動的預約或顧客時,起點設在上一次查詢開始的時間之前;重複取到的資料以 id 覆寫。