---
name: "readQuantityDataWithTypeSync"
mode: "kit"
versionRequirements:
  - { name: "HealthKit", version: "5.18.3" }
  - { name: "@ray-js/ray", version: "1.6.17" }
platform:
  - "iOS"
title: "health.readQuantityDataWithTypeSync - Read Quantity data [iOS only]"
---

## readQuantityDataWithTypeSync

> [VERSION] HealthKit >= 5.18.3 | @ray-js/ray >= 1.6.17

> [PLATFORM] iOS

### Description

Read Quantity health data by type and time range [iOS only]

### Parameters

| Property | Type | Required | Default | Since | Description |
| --- | --- | --- | --- | --- | --- |
| `permissions` | `string[]` | No | - | `5.18.3` | Permission types (used by the API to request read/write permissions). See the enum list below for specific values. e.g., ["1","2"] |
| `readPermissions` | `string[]` | No | - | `5.18.3` | Read permission types (used by the API that checks whether the user has already authorized). See the enum list below for specific values. e.g., ["1","2"] |
| `writePermissions` | `string[]` | No | - | `5.18.3` | Write permission types (used by the API that checks whether the user has already authorized). See the enum list below for specific values. e.g., ["1","2"] |
| `writePermission` | `number` | No | - | `5.18.3` | Write permission types (used by the API that checks whether write permission is granted). See the enum list below for specific values. |
| `value` | `number` | No | - | `5.18.3` | Value to write (the specific measurement for Quantity or Category data types). |
| `unitType` | `string` | No | - | `5.18.3` | Unit to pass in, such as "mg/dL", "g", "cm", "count"; required when querying or writing Quantity-type data. For the units corresponding to each data type, refer to Apple’s official HKTypeIdentifiers.h file. |
| `startTime` | `number` | No | - | `5.18.3` | Start time, Unix timestamp in seconds |
| `endTime` | `number` | No | - | `5.18.3` | End time, Unix timestamp in seconds |
| `type` | `number` | No | - | `5.18.3` | Data types to read/write (used by the data read/write APIs). See the enum list below for specific values. |

### Error Codes

| Error Code | Error Message |
| --- | --- |
| `1` | AppleHealthParamsError |

### Examples

#### Basic usage

```tsx
import { health } from '@ray-js/ray'

const { readQuantityDataWithTypeSync } = health;

const result = readQuantityDataWithTypeSync({
  type: 1,
  unitType: 'count',
  startTime: 1700000000,
  endTime: 1700086400,
});
console.log('readQuantityDataWithTypeSync result', result.value);
```
