Skip to main content

Usage: Sync health data

Learn about requests quotas and sync strategies.

Health Connect request quota

To maintain optimal system stability and performance, Health Connect imposes rate limits on client connections to the Health Connect API.

It is important to understand that every data type in rook-sdk is constructed of multiple health variables, such as heart rate, step count, hydration, etc. When a Sleep Summary is extracted, multiple calls are made to the Health Connect API. While our efforts in recent months have focused on optimizing and reducing the number of API calls required for each data type, it is still possible to reach that limit, especially during multiple extractions in a short amount of time.

Depending on the sync type you choose, keep the following in mind:

Request quota when syncing data manually

  • Extract summaries once daily: Since summaries collect health data from the previous day, there's no need to extract them more than once per day.
  • Use what you already have: If you are extracting Physical Events, you don’t need to extract Heart Rate Events ( Physical) or Oxygenation Events (Physical) as these are already included in the PhysicalEvent object.
  • Only sync the relevant health data for your use case: If you are not interested in individual events and only want to sync the summary of a specific date, use the sync functions in RookSummaryManager.
  • If you have already reached the request quota (a RequestQuotaExceededException is returned), avoid calling any sync function for the next few hours so your quota can be recovered.

Request quota when syncing data automatically

Background Sync already addresses practically all issues and limitations of Health Connect. When the quota is reached, all pending syncs are canceled, and a recovery timestamp is created. Pending syncs will not resume until 60 minutes have passed.

rookYesterdaySync already addresses practically all issues and limitations of Health Connect. When the quota is reached, all pending syncs are canceled, and a recovery timestamp is created. Pending syncs will not resume until the user re-opens the app after 60 minutes.

Sync health data

You can choose between implementing a custom sync process manually or using our automatic implementation, which handles everything (except for permissions and userId) for you.

tip

The automatic implementation is faster, easier to integrate and is what most developers need. Try to use it before attempting to create a custom sync process.