用量限制和配額
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
限制和配額可避免 Google 基礎架構受到以不當方式使用 Data Transfer API 的自動化程序。來自 API 的過多要求可能是因拼寫無害的錯字而產生,或是系統設計效率不佳且需要進行無用 API 呼叫的系統。無論原因為何,只要特定來源的流量達到一定程度,Google Workspace 系統的整體健康狀態就會需要封鎖。可確保單一開發人員的行為不會對較大社群產生負面影響。
API 要求失敗
萬一 API 要求失敗,應用程式會收到 HTTP 狀態碼回應。403
狀態碼含有輸入內容有誤的錯誤資訊,503
的 HTTP 狀態碼會包含錯誤資訊,指出已超過哪些 API 配額。這些回應可讓您的自訂應用程式偵測這些錯誤,並採取適當行動。
在固定時間範圍內完成要求
如果要求必須在固定的時間內完成,請同時傳送要求,或是在 Java 或 C# 應用程式中使用多個執行緒。例如按照月份或其他時間範圍細分要求。如果是執行緒,請嘗試從 10 個執行緒開始,每項要求一個執行緒。執行緒建議有取捨,對所有 API 情況來說都不適用。如果要求數量過大,就會發生配額錯誤。
以時間為準的錯誤
如果是基於時間限制的所有錯誤 (每個執行緒最多 N 個項目,尤其是 503
狀態碼錯誤),建議您讓程式碼擷取例外狀況,並使用指數輪詢演算法,等到一點點延遲後,再重試失敗的呼叫。其中一個執行緒的 Data Transfer API 範例是等待 5 秒,然後重試失敗的呼叫。如果要求成功,請為其他執行緒重複這個模式。如果第二個要求失敗,應用程式應依要求頻率縮減規模,直到呼叫成功為止。例如,請將初始延遲時間延長為 10 秒,然後重新重試失敗的呼叫。此外,您也可以決定重試限制。例如,以不同的延遲時間重新傳送要求 5 至 7 次,應用程式會將錯誤傳回給使用者。
限制
API 限制類別 |
限制 |
每秒查詢次數 (QPS) |
開發人員專案數量上限為每個帳戶每秒 10 次查詢 (QPS)。 |
配額
API 配額類別 |
配額 |
每日的 API 要求數量上限 |
每日的 API 要求數量上限為 500,000 個。 |
封存 (郵件到期日) |
群組封存內容不會過期。封存功能會一直保留郵件,直到群組遭到刪除為止。電子郵件保留政策不會影響群組封存資料中的訊息。 |
郵件大小 |
郵件大小上限為 25 MB。這項限制包括郵件的中繼資料標頭、內文和所有附件。 |
其他限制類型
其他限制類型 |
限制與規範 |
內容類型格式 |
電子郵件必須採用標準 RFC 822 文字格式。
用來上傳已遷移電子郵件的要求內容類型格式會使用 Content-type: message/rfc822 標頭。 |
API 回應中的資料格式 |
回應的資料格式為 JavaScript Object Notation (JSON)。 |
資料位置政策 |
Data Transfer API 不支援基於合約規定,將資料儲存在特定地理或政治邊界的資料位置政策。如果您的帳戶需要資料位置,則請勿使用 Data Transfer API。 |
平行插入訊息 |
Data Transfer API 支援將電子郵件插入至不同群組封存的平行要求。不過,Data Transfer API 不支援將平行訊息插入同一個群組封存。這個版本的 API 也不支援批次要求。 |
未經授權的要求 |
Data Transfer API 不接受任何未經授權的要求。如未提供授權權杖,系統就會將要求視為未經授權的要求。 |
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-29 (世界標準時間)。
[null,null,["上次更新時間:2025-08-29 (世界標準時間)。"],[],[],null,["# Usage limits and quotas\n\nLimits and quotas protect the Google infrastructure from an automated process that uses the\nData Transfer API in an inappropriate way. Excessive requests from an API might result from a\nharmless typo, or might result from an inefficiently designed system that makes needless API\ncalls. Regardless of the cause, blocking traffic from a specific source when it reaches a certain\nlevel is necessary for the overall health of the Google Workspace system. It ensures that one\ndeveloper's actions can't negatively impact the larger community.\n\nAPI request failures\n--------------------\n\nIn the unlikely event that your API request fails, your application receives an HTTP status code\nresponse. A status code of `403` has error information about incorrect input, and an\nHTTP status code of `503` has error information indicating which API quotas have been\nexceeded. These responses let your custom application detect these errors and take appropriate\naction.\n\nComplete requests in a fixed time period\n----------------------------------------\n\nIf your requests need to be completed in a fixed period of time, send your requests in parallel\nor use multiple threads in your Java or C# application. For example, break your requests by month\nor another time period. In the case of threads, try starting with 10 threads, one thread per\nrequest. The thread recommendation has trade-offs and isn't useful for all API situations. If the\nnumber of requests gets too high, quota errors will occur.\n\nTime-based errors\n-----------------\n\nFor all errors that are time based (maximum of N things for X seconds per thread), especially the\n`503` status code errors, we recommend that your code catch the exception and by using\nan\n[exponential backoff](http://wikipedia.org/wiki/Truncated_binary_exponential_backoff)\nalgorithm, wait for a small delay before retrying the failed call. A Data Transfer API example\nfor one thread is to wait 5 seconds and retry the failed call. If the request is successful,\nrepeat this pattern for the other threads. If the second request is not successful, your\napplication should scale back on the frequency of the request until a call is successful. For\nexample, increase the initial 5 second delay to 10 seconds and retry your failed call again. Also,\ndecide on a retry limit. For example retry a request 5 to 7 times with different delay times\nbefore your application returns an error to the user.\n\nLimits\n------\n\n| API limit categories | Limits |\n|--------------------------|-------------------------------------------------------------------------|\n| Queries per second (QPS) | The developer project limit is 10 queries per second (QPS) per account. |\n\nQuotas\n------\n\n| API quota categories | Quotas |\n|---------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Maximum API requests per day | The maximum API requests per day is 500,000. |\n| Archive, expiration of messages | Group archives don't expire. Messages remain in an archive until the group is deleted. The email retention policy doesn't affect messages in a group's archive. |\n| Mail message size | The maximum mail message size is 25MB. This limit includes the message's meta data headers, body, and any attachments. |\n\nOther types of limits\n---------------------\n\n| Other types of limits | Limitations and guidelines |\n|------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Content type formats | An email message must be in the standard [RFC 822 text format](http://www.w3.org/Protocols/rfc822/). A request's content-type format for uploading migrated emails use the `Content-type: message/rfc822` header. |\n| Data format in API responses | The response's data format is Javascript Object Notation ([JSON](http://json.org/)). |\n| Data location policies | The Data Transfer API doesn't support data location policies requiring data be stored in specific geographic or political boundaries for contractual reasons. Don't use the Data Transfer API if data location is required for your account. |\n| Parallel message insertions | The Data Transfer API supports parallel requests for email insertions into different group archives. But the Data Transfer API doesn't support parallel message insertions into the same group archive. Nor are batch requests supported in this version of the API. |\n| Unauthorized requests | The Data Transfer API doesn't accept any unauthorized requests. A request is considered unauthorized if no authorization token is provided. |"]]