レート制限を回避する計画
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
最適なシステムの安定性とパフォーマンスを維持するため、ヘルスコネクトはヘルスコネクト API へのクライアント接続に対してレート制限を行っています。
このガイドでは、ヘルスコネクトの読み取りおよび書き込み API 操作に対する上限と、効率的なアプリ設計を通じてレート制限を回避する方法について説明します。
API の上限
上限は固定リクエスト レートに基づく割り当てとして、フォアグラウンドとバックグラウンドの両方の API 操作に適用されます。
レートとメモリの上限は、アプリが実行している操作の種類と、その操作がフォアグラウンドとバックグラウンドのどちらで発生するかによって異なります。
読み取りと変更履歴の上限
ヘルスコネクトでは、読み取りと変更履歴に関して、アプリで利用できる API 呼び出し回数に対して次の 2 種類の上限を設けています。
- 一定期間にアプリが API に対して実行できる API 呼び出し回数の上限
- アプリが実行できる 1 日あたりの API 呼び出し回数の上限
挿入、更新、削除の上限
ヘルスコネクトでは、挿入、更新、削除の操作に対して 4 種類の異なる上限を設けています。
- 一定期間にアプリが API に対して実行できる呼び出し回数の上限
- アプリが API に対して実行できる 1 日あたりの呼び出し回数の上限
- 一括挿入のメモリ上限
- 単一レコード挿入のメモリ上限
ベスト プラクティス
アプリでヘルスコネクト API を利用する際には、バッテリー使用量を最小限に抑え、最適なシステムの状態を維持し、すべての CRUD 操作で効率的なデータ管理を実現できる形で利用することをおすすめします。
実施をおすすめするベスト プラクティスには次のものがあります。
バックグラウンドでの API 呼び出し
バックグラウンド処理のバッテリー使用量によってユーザー エクスペリエンスが低下し、データのプライバシーに対する懸念が生まれます。
そのような理由から、バックグラウンドでのレート制限は、フォアグラウンドでのレート制限よりも厳格になっています。そのため、アプリがバックグラウンドで実行する API 呼び出し回数を抑えることが重要です。
例外の処理
ヘルスコネクトへのデータの書き込み時にアプリで例外が発生した場合は、例外が発生した時点から再試行することをおすすめします。
問題のデータをすべて削除して、書き込みリクエスト全体を再試行しないようにしてください。この方法は挿入割り当てを消費し、パフォーマンスを低下させ、バッテリー駆動時間に悪影響を及ぼします。
変更履歴の処理
アプリがレート制限されるリスクを最小限に抑えるためには、未加工の読み取りリクエストに過度に依存するのではなく、変更履歴の処理を利用して、データベースをヘルスコネクトのデータと同期するようにします。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-07-27 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-07-27 UTC。"],[],[],null,["# Plan to avoid rate limiting\n\nTo maintain optimal system stability and performance, Health Connect imposes\nrate limits on client connections to the Health Connect API.\n\nThis guide outlines the limits imposed on read and write API operations in\nHealth Connect, and how to avoid rate limiting through efficient app design.\n\nAPI limits\n----------\n\nLimits are placed on both foreground and background API operations as **fixed\nrequest rate quotas**.\n\nRate and memory limits are variable based on the type of operation your app is\nperforming, and whether that operation occurs in the foreground or background.\n\n### Read and changelog limits\n\nFor read and changelog limits, Health Connect imposes two limits on the number\nof API calls available to your app:\n\n- A periodic limit on the number of API calls your app can make to the API.\n- A daily limit on the number of API calls your app can make.\n\n### Insert, update and delete limits\n\nHealth Connect places four distinct limits on insertion, update and deletion\noperations:\n\n- A periodic limit on the number of calls your app can make to the API.\n- A daily limit on the number of calls your app can make to the API.\n- A memory limit for bulk insertions.\n- A memory limit for single record insertions.\n\nBest practices\n--------------\n\nWe recommend that apps interact with the Health Connect API in a way that\nminimizes battery use, maintains optimal system health and promotes efficient\ndata management across all CRUD operations.\n\nHere are some best practice guidelines to adhere to.\n\n### Background API calls\n\nBattery usage for background operations reduces the user experience and raises\nquestions regarding [data privacy](/guide/health-and-fitness/health-connect/develop/read-data#foreground-restriction).\n\nAs such, background rate limiting is stricter than foreground rate limiting.\nIt's therefore important to limit the amount of API calls your app carries out\nin the background.\n\n### Exception handling\n\nIf your app experiences an exception when writing data to Health Connect, we\nrecommend retrying from where the exception occurred.\n\nDon't simply delete all the data in question and retry the entire write request.\nThis approach eats into your insert quota, reduces performance, and has a\nnegative impact on battery life.\n\n### Changelog handling\n\nTo minimize the risk of your app being rate limited, you should utilize\n[changelog handling](/guide/health-and-fitness/health-connect/develop/sync-data#pull-data) to synchronize your database with data from Health\nConnect, rather than over-relying on raw read requests."]]