To maintain optimal system stability and performance, Health Connect imposes rate limits on client connections to the Health Connect API.
This guide outlines the limits imposed on read and write API operations in Health Connect, and how to avoid rate limiting through efficient app design.
Limits are placed on both foreground and background API operations as fixed request rate quotas.
Rate and memory limits are variable based on the type of operation your app is performing, and whether that operation occurs in the foreground or background.
Read and changelog limits
For read and changelog limits, Health Connect imposes two limits on the number of API calls available to your app:
- A periodic limit on the number of API calls your app can make to the API.
- A daily limit on the number of API calls your app can make.
Insert, update and delete limits
Health Connect places four distinct limits on insertion, update and deletion operations:
- A periodic limit on the number of calls your app can make to the API.
- A daily limit on the number of calls your app can make to the API.
- A memory limit for bulk insertions.
- A memory limit for single record insertions.
We recommend that apps interact with the Health Connect API in a way that minimizes battery use, maintains optimal system health and promotes efficient data management across all CRUD operations.
Here are some best practice guidelines to adhere to.
Background API calls
Battery usage for background operations reduces the user experience and raises questions regarding data privacy.
As such, background rate limiting is stricter than foreground rate limiting. It's therefore important to limit the amount of API calls your app carries out in the background.
If your app experiences an exception when writing data to Health Connect, we recommend retrying from where the exception occurred.
Don't simply delete all the data in question and retry the entire write request. This approach eats into your insert quota, reduces performance, and has a negative impact on battery life.
To minimize the risk of your app being rate limited, you should utilize changelog handling to synchronize your database with data from Health Connect, rather than over-relying on raw read requests.