# Health data

> Daily steps, active calories, resting heart rate and sleep from Apple Health or Health Connect.

Source: https://hubfit.com/developers/api/health


The daily health data a client's phone sends from Apple Health or Health Connect. The client's phone sends its data only while they have the HubFit app open, so the data is as recent as `lastSyncedAt`, and today's numbers grow until it next syncs. To compare clients' health data over a period, use `GET /client-summaries` with `include=health`.

Endpoints:

- `GET /v1/clients/{clientId}/health-data`: [Get a client's health data](https://hubfit.com/developers/api/health#get-client-health-data)

## Health data object

### Attributes

- `source` (enum, nullable): Where the data comes from, or `null` if the client hasn't connected Apple Health or Health Connect. New sources can appear. Known values `apple_health`, `health_connect`.
- `lastSyncedAt` (timestamp, nullable)
- `days` (array of objects)
  - `date` (date): The day on the client's phone.
  - `steps` (integer, nullable)
  - `activeCalories` (integer, nullable): Calories burned by activity, in kcal. Not total energy.
  - `restingHeartRateBpm` (number, nullable)
  - `sleep` (object, nullable): The night that ended this morning, or `null`.
    - `durationSeconds` (integer): Time asleep, awake time not included.
    - `deepSeconds` (integer, nullable): `null` if the phone recorded no sleep stages.
    - `lightSeconds` (integer, nullable): Light sleep, which Apple Health calls core sleep. `null` if the phone recorded no sleep stages.
    - `remSeconds` (integer, nullable): `null` if the phone recorded no sleep stages.
    - `awakeSeconds` (integer, nullable): Time awake during the night. `null` if the phone recorded no sleep stages and no time awake.
    - `startAt` (timestamp, nullable)
    - `endAt` (timestamp, nullable)

### Example

```json
{
  "source": "apple_health",
  "lastSyncedAt": "2026-10-26T14:32:05.000Z",
  "days": [
    {
      "date": "2026-10-26",
      "steps": 9412,
      "activeCalories": 612,
      "restingHeartRateBpm": 57,
      "sleep": {
        "durationSeconds": 27300,
        "deepSeconds": 5400,
        "lightSeconds": 14400,
        "remSeconds": 6300,
        "awakeSeconds": 1200,
        "startAt": "2026-10-25T23:05:00.000Z",
        "endAt": "2026-10-26T06:40:00.000Z"
      }
    }
  ]
}
```

## Get a client's health data

`GET https://api.hubfit.com/v1/clients/{clientId}/health-data`

The client's daily health data from Apple Health or Health Connect, newest day first. Days with no data are left out. The client's phone sends its data only while they have the HubFit app open, so the data is as recent as `lastSyncedAt`, and today's numbers grow until it next syncs. A client who switched phones has data from both; this is the one that synced last. Requires `clients:read`.

### Path parameters

- `clientId` (string, required): The client's `id`.

### Query parameters

- `startDate` (date, required): The first day, included, as `YYYY-MM-DD`.
- `endDate` (date, required): The last day, included, as `YYYY-MM-DD`. The period is at most 90 days, counting both ends.

### Returns

The client's health data.

### Example request

cURL:

```bash
curl -G https://api.hubfit.com/v1/clients/6ad6af41d3199442d31b2743/health-data \
  -H "Authorization: Bearer $HUBFIT_API_KEY" \
  -d startDate=2026-10-20 \
  -d endDate=2026-10-26
```

Node.js:

```javascript
const response = await fetch("https://api.hubfit.com/v1/clients/6ad6af41d3199442d31b2743/health-data?startDate=2026-10-20&endDate=2026-10-26", {
  headers: {
    Authorization: `Bearer ${process.env.HUBFIT_API_KEY}`,
  },
});

const { data } = await response.json();
```

Python:

```python
import os
import requests

response = requests.get(
    "https://api.hubfit.com/v1/clients/6ad6af41d3199442d31b2743/health-data",
    headers={"Authorization": f"Bearer {os.environ['HUBFIT_API_KEY']}"},
    params={
        "startDate": "2026-10-20",
        "endDate": "2026-10-26",
    },
)

data = response.json()["data"]
```

### Example response (200 OK)

```json
{
  "data": {
    "source": "apple_health",
    "lastSyncedAt": "2026-10-26T14:32:05.000Z",
    "days": [
      {
        "date": "2026-10-26",
        "steps": 9412,
        "activeCalories": 612,
        "restingHeartRateBpm": 57,
        "sleep": {
          "durationSeconds": 27300,
          "deepSeconds": 5400,
          "lightSeconds": 14400,
          "remSeconds": 6300,
          "awakeSeconds": 1200,
          "startAt": "2026-10-25T23:05:00.000Z",
          "endAt": "2026-10-26T06:40:00.000Z"
        }
      }
    ]
  }
}
```
