開發者

SpeakNotes API 驗證

API 接受三種憑證:API 金鑰、OAuth 存取權杖,或來自已登入工作階段的 Firebase ID 權杖。

API 金鑰

在每個請求中將金鑰作為 bearer token 發送。任何已登入的帳戶都可以建立金鑰,並可立即使用。

curl https://api.speaknotes.io/v1/notes \
  -H "Authorization: Bearer sn_live_YOUR_API_KEY"

正式環境金鑰以 sn_live_ 開頭,並作用於您的真實資料庫。沙盒金鑰以 sn_test_ 開頭,並針對固定輸出進行測試。在範圍功能出現前核發的金鑰仍然有效,並擁有完整存取權。

範圍 (Scopes)

每個金鑰和每個 OAuth 權杖都帶有範圍。讀取並不代表可以寫入,因此範圍限制為 notes:read 的金鑰無法刪除任何內容。缺少範圍的請求會收到 403 錯誤,並指出缺少了什麼。

  • notes:readRead notes, transcripts, and summaries.
  • notes:writeCreate, update, and delete notes.
  • folders:readRead folders.
  • folders:writeCreate, update, and delete folders.
  • transcriptions:writeTranscribe audio and video.
  • summaries:writeGenerate summaries from audio, text, and YouTube URLs.
  • usage:readRead credit balance and usage history.

速率限制

限制是按憑證計算,而非按 IP 計算,因此一個整合不會耗盡另一個的資源。每個回應都包含 X-RateLimit-Limit、X-RateLimit-Remaining 和 X-RateLimit-Reset,而 429 回應則包含 Retry-After。

120
讀取 每分鐘
30
寫入 每分鐘
10
處理 每分鐘
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer realm="SpeakNotes API", error="invalid_token",
  resource_metadata="https://api.speaknotes.io/.well-known/oauth-protected-resource"

{
  "error": {
    "type": "authentication_error",
    "code": "invalid_token",
    "message": "The API key is invalid, expired, or revoked.",
    "doc_url": "https://speaknotes.io/developers/errors#invalid_token"
  }
}

OAuth

正在開發其他 SpeakNotes 使用者會登入的應用程式嗎?請使用 OAuth,而不是要求他們貼上金鑰。 /developers/oauth

輪替與撤銷

金鑰僅在建立時顯示一次,並僅以雜湊形式儲存。撤銷金鑰會立即生效。您也可以在建立金鑰時為其設定過期日期。