Skip to content
CARP Docs
Ask AISystemLightDark
On this page

Health Connect limits

The Health Connect API quotas per app, the calls each read costs and how to stay within the quotas.

Copy MarkdownOpen inOpen in GitHubView as MarkdownOpen in Scira AIOpen in ChatGPTOpen in ClaudeOpen in Cursor

Health Connect limits how often each app may call it. When a quota is used up, reads throw a HealthPlatformException with HealthErrorCode.rateLimitExceeded until the quota has refilled. Writes return false, and finishWorkoutRoute throws a PlatformException with code ROUTE_ERROR.

API quotas

The quotas are part of the Health Connect module, so they vary with the Health Connect version and may change at any time. These values were measured on three devices:

Pixel 8a, Android 17Android 16 emulatorAndroid 15 emulator (SDK extension 13)
Reads in the foreground80,000 per 15 min, 80,000 per 24 h2,000 per 15 min, 16,000 per 24 h2,000 per 15 min, 16,000 per 24 h
Reads in the background1,000 per 15 min, 8,000 per 24 h1,000 per 15 min, 8,000 per 24 h1,000 per 15 min, 8,000 per 24 h
Writes1,000 per 15 min, 8,000 per 24 h1,000 per 15 min, 8,000 per 24 h1,000 per 15 min, 8,000 per 24 h
Data written35 MB per 15 min35 MB per 15 min35 MB per 15 min
Size of a request5 MB, and 1 MB per record5 MB, and 1 MB per recordNot checked

A quota refills continuously, not all at once when its window ends. On the Android 15 emulator, 2,075 one-record reads went through in the foreground after 15 idle minutes. After that, reads came back at about 2.2 per second, and an emptied 15-minute quota was full again after about 15 minutes.

The quotas of Android 14 and of the Health Connect app on Android 13 and lower were not measured. Checking the granted permissions did not count against the read quota on the Android 16 emulator.

Quota errors

rateLimitExceeded is retryable, but the plugin never retries on its own. Catch the error and read again later:

try {
  await for (final page in health.getHealthDataPages(
    types: [HealthDataType.HEART_RATE],
    startTime: start,
    endTime: end,
  )) {
    await store(page.points);
  }
} on HealthPlatformException catch (e) {
  if (e.errorCode == HealthErrorCode.rateLimitExceeded) {
    // Read the rest of the range again later
  }
}

The error ends the stream, and the pages that arrived before it stay valid. To resume a long sync from where it stopped, see Data pages. For the other error codes, see Error handling.

Calls per read

The plugin reads Health Connect page by page, and every page costs at least one call. Health Connect returns at most 5,000 records per call. A read costs these calls:

ReadHealth Connect calls
A type with one value per record, such as steps or weight1 permission check + 1 per 5,000 records, or per pageSize records if that is smaller
Heart rate1 permission check + 1 per page + 1 count of the samples per about 8 pages + 1 per record that holds more than pageSize / 2 samples, and the look-back of the first page
Speed, power, cycling cadence and skin temperature1 permission check + 1 look-back read + 1 per pageSize / 3600 records, which is 5 at the default pageSize
WorkoutsPer 20 workouts: 1 permission check + 1 read + up to 3 per workout for its distance, calories and steps, and 1 more per further 5,000 records of a total
Workout routes1 permission check + 1 per 5 sessions
Sleep types1 permission check + 1 per 500 sleep sessions, or per pageSize sessions if that is smaller
getHealthDataFromTypes() with a limit1 permission check + 1 per page, reading the pages newest first until limit points are in
getTotalStepsInInterval(includeManualEntry: false)1 per 5,000 step records
getHealthIntervalDataFromTypes()1 per type, or 1 per 500 sessions for a sleep type
getChanges()1 per call

Some reads cost more than the table shows:

  • Speed, power, cycling cadence and skin temperature: a record may hold an hour of samples at one per second. Health Connect has no count of these samples to plan by. A page whose records hold more than twice pageSize samples is read again with the records that fit in pageSize. Each such read costs 1 more call, at most 3 per page.
  • Workouts and routes on Android 14 and 15: both cost 1 more call for each page that Health Connect fails to read for a route outside it. See Workouts on Android 14 and 15.
  • Sleep stages: a stage type, not SLEEP_SESSION, also reads the sessions that began in the 24 hours before startTime: 1 more call per 500 sessions.
  • Reads with a limit: the first page asks for at most limit records, and the read makes no look-back for records that began before startTime. Workouts also read their totals, as above. The latest weight, with limit: 1, costs 1 permission check + 1 read.
  • Interval reads of a sleep type: the read covers the sleep sessions from 24 hours before startDate to endDate.
  • Changes: getChanges() costs 1 more call each time a page of changes that holds more than 100,000 data points is read again with fewer changes.
  • Records that share a start time: on Android 14 and later, every read whose page ends among records that share one start time costs 1 more call. This applies to the totals and look-backs above too, and goes beyond the caps of 24 and 40 calls for heart rate. See Records that share a start time.

Heart rate

The plugin reads heart rate in time slices of at most about pageSize samples, give or take one record. Besides 1 call per page, a heart rate read costs 1 count of the samples per about 8 pages. It also costs 1 call per record that holds more than pageSize / 2 samples.

The first page also looks for the records that began in the 24 hours before startTime and reach into the read. This look-back makes at most 24 calls:

  • 2 if those hours hold no heart rate;
  • otherwise about 1 per 15,000 samples in them, or fewer with a pageSize above 20,000;
  • about 1 per 4,000 records where each record holds one sample.

A day at one sample per second therefore takes about 6 calls in records of a minute or an hour. As one record per sample, it takes all 24: 86,400 records did on the Android 15 emulator.

Where those hours hold more than 24 calls can cover, only the newest records are looked at, and the plugin logs a warning. Examples are such a day of one-sample records from two apps, or more than about 250,000 to 350,000 samples in longer records. The exact amount depends on the records and the Android version.

Every Android version makes this look-back, except for one kind of read on Android 16 and later. That is a read of only the app's own heart rate, with WRITE permission but not READ permission, that fits in one page. It makes the look-back only when Health Connect's sample count shows a record that began before startTime.

Each page makes at most 40 calls, whatever the data and pageSize.

Take a read with no heart rate in the day before startTime. A week of heart rate at one sample per second, 600,000 samples, then costs about 40 calls at the default pageSize. Reading 30 days at one sample per minute, a record per sample, costs about 15.

Reads of the app's own records

A read of heart rate, speed, power, cycling cadence or skin temperature with only the type's WRITE permission returns the app's own records. It costs as much as with READ permission: heart rate in time slices, the other types as for speed.

Health Connect refuses to count the app's own heart rate samples in an Android 14 Health Connect older than Quarterly Platform Release 2 (QPR2). It also refuses in a read started in the background without READ_HEALTH_DATA_IN_BACKGROUND. The Health Connect app on Android 13 and lower may refuse too.

Where it refuses, heart rate costs 1 refused count, and the rest as for speed. A week of heart rate written once a minute with writeHealthData(), one record per sample, then costs about 2,000 calls. That is the whole 15-minute foreground quota of Android 15 and 16, against about 10 calls in time slices.

Records that share a start time

Health Connect returns a type's records in the order of their start times, a limited number per call:

  • pageSize records, at most 5,000, for most types;
  • 20 workouts, 5 workout routes or 500 sleep sessions;
  • fewer for heart rate, speed, power, cycling cadence and skin temperature, whose records can hold many samples each.

Imported or synced data is often written with identical timestamps. Since Android 14 QPR2, Health Connect's page tokens lose count of records that share one start time, to the millisecond. This happens where a page ends among them.

Following the tokens then returns some of those records twice, or the same records on every further call. On Android 15, it also returns records without some of their samples, sleep stages or laps. This was measured on Android 15, 16 and 17.

An Android 14 Health Connect older than QPR2 fails in another way. Where more records share the first start time of a call than it asks for, it returns an empty page, also on every further call.

Where a page ends among such records, or is such an empty page, the plugin makes one more call. That call reads all records of the type that start at that millisecond. The next page starts after them, so each record is returned once, whole and in order.

The reads behind workout totals, sleep intervals, getTotalStepsInInterval(includeManualEntry: false) and the look-back for sleep sessions and heart rate records that began before startTime do the same.

Each such page costs that one more call and holds more records than asked for: all those of its last start time. For heart rate, speed, power, cycling cadence and skin temperature, these can be many more samples than pageSize.

Where more than 5,000 records of a type start at the same millisecond, one call cannot hold them. The read then fails with HealthErrorCode.unknown instead of reading the same records forever. A read on Android 13 and lower also fails this way if the Health Connect app returns the same page token twice.

Before 14.0.0, such reads returned records twice or in part. Some read again and again until the app ran out of memory or Health Connect quota.

Workouts on Android 14 and 15

The plugin reads workouts 20 per page and workout routes 5 per page, or fewer if pageSize is smaller. Health Connect on Android 14 and 15 fails such a read when both of these hold:

  • the app may read routes: it has READ_EXERCISE_ROUTES, or WRITE_EXERCISE_ROUTE for its own routes, which the plugin requests for WORKOUT_ROUTE writes;
  • a session with such a route starts in the range but outside the page.

This is a Health Connect bug, fixed in Android 16. A Health Connect that a system update brought up to date may not have it.

The plugin catches exactly this error and reads the page again together with the rest of the range, up to 5,000 sessions with their routes. It still returns a page of the usual size: 20 workouts or 5 routes. The page also holds any further sessions that start at the same time as its last one.

The next page goes on with the first session left out, so each session is returned once, in order. A workout page reads the totals of its own workouts only.

Each such page costs one more Health Connect call, and the failed call counts against the quota too. Every read again also returns the rest of the range with its routes. Such pages therefore take more time and memory the more sessions with long routes follow them, and reading shorter time ranges keeps them small.

With a limit, only the newest sessions are converted until limit points are in, and the read ends there.

If a session with a route lies more than 5,000 sessions after the start of such a page, the read again fails. It then throws a HealthPlatformException with HealthErrorCode.unknown (platform code HEALTH_ERROR).

Reads within the quotas

To stay within the quotas:

  • read large ranges in the foreground, as the background quota is much smaller;
  • prefer a few long reads over many short ones;
  • when you read in time windows, prefer a week or a month to a day: every read has a fixed cost in calls;
  • keep the default pageSize of 20,000, or raise it for heart rate data, up to 50,000;
  • call getChanges() instead of reading data you already have again.

For change tracking, see Change tracking.

Quick links

Page · DocumentationCARP DocumentationPage · DocumentationIntroductionPage · DocumentationQuickstartPage · DocumentationTerminologyPage · DocumentationArchitecture