入門指南

錯誤

出錯時,API 會傳回相應的 HTTP 狀態碼,而回應主體的 error 內會包含 code 及 message。

請在程式中使用 code 作判斷。message 是協助除錯的英文文字,內容可能會變更。

錯誤格式404
{
  "error": {
    "code": "not_found",
    "message": "Item not found or you do not have access to it."
  }
}
沒有金鑰401
{
  "error": {
    "code": "missing_api_key",
    "message": "Send your API key in the X-API-Key header or as Authorization: Bearer <key>."
  }
}

錯誤代碼

狀態 代碼 出現情況
400 key_in_query 金鑰經網址傳送(參數 api_key、apikey、key 或 token)。請改用標頭傳送,並產生新金鑰,因為舊金鑰可能已被記錄在日誌中。
400 invalid_parameter 某個參數的值無效,例如 per_page 超出上限。
401 missing_api_key 請求沒有附上金鑰。
401 invalid_api_key 金鑰不存在、已被撤銷,或其用戶已被停用。
404 not_found 端點不存在,或項目不存在,或項目屬於該用戶無權查看的公司。
404 organization_not_found 所提供的 organization 並非該用戶可查看此類項目的公司。
405 method_not_allowed API 只接受 GET(及 HEAD)請求。
429 rate_limited 已達到請求次數限制。請等候 Retry-After 指定的秒數。
500 server_error 內部錯誤。請稍後再試;如問題持續,請聯絡支援團隊。

何時重試

只有在收到 429(並等候 Retry-After 指定的時間)或 500 後,才值得重新發出相同請求。其他錯誤都需要修正請求或金鑰。