# Metrics

> What a client tracks over time, like weight, waist or body fat, and every entry.

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


A metric is something a client tracks over time, like weight, waist or body fat, in the unit the coach set. Clients log entries in the app or through check-in answers, one value for a day. To compare clients' metrics over a period, use `GET /client-summaries` with `include=metrics`.

Endpoints:

- `GET /v1/clients/{clientId}/metrics`: [List a client's metrics](https://hubfit.com/developers/api/metrics#list-client-metrics)
- `GET /v1/metrics/{metricId}/entries`: [List a metric's entries](https://hubfit.com/developers/api/metrics#list-metric-entries)

## Metric object

### Attributes

- `id` (string): Its unique ID.
- `name` (string)
- `unit` (string, nullable): The unit the coach set, as they wrote it (`kg`, `cm`, `%`). `null` if they left it blank. Values are never converted.
- `entryCount` (integer)
- `lastEntry` (object, nullable): The entry for the latest day, and of that day's entries the last added. `null` if it has none.
  - `id` (string): Its unique ID.
  - `date` (date): The client's own calendar day the entry is for.
  - `value` (number): In the metric's `unit`.

### Example

```json
{
  "id": "6ad6af776298037662967079",
  "name": "Weight",
  "unit": "lb",
  "entryCount": 24,
  "lastEntry": {
    "id": "6ad6af4305c6094205c47641",
    "date": "2026-10-26",
    "value": 182.4
  }
}
```

## Metric entry object

### Attributes

- `id` (string): Its unique ID.
- `date` (date): The client's own calendar day the entry is for.
- `value` (number): In the metric's `unit`.

### Example

```json
{
  "id": "6ad6afb5dd068db4dd04fab3",
  "date": "2026-10-26",
  "value": 182.4
}
```

## List a client's metrics

`GET https://api.hubfit.com/v1/clients/{clientId}/metrics`

The metrics the client tracks, in the order the coach added them, each with how many entries it has and the last one. A client has no more than 25 (`MAX_METRICS_PER_CLIENT`), so they all come in one response, without paging; a client given more before that limit still gets every one. Empty if the coach turned metrics off for the client. Requires `clients:read`.

### Path parameters

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

### Returns

Every metric the client tracks.

### Example request

cURL:

```bash
curl https://api.hubfit.com/v1/clients/6ad6af41d3199442d31b2743/metrics \
  -H "Authorization: Bearer $HUBFIT_API_KEY"
```

Node.js:

```javascript
const response = await fetch("https://api.hubfit.com/v1/clients/6ad6af41d3199442d31b2743/metrics", {
  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/metrics",
    headers={"Authorization": f"Bearer {os.environ['HUBFIT_API_KEY']}"},
)

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

### Example response (200 OK)

```json
{
  "data": [
    {
      "id": "6ad6af776298037662967079",
      "name": "Weight",
      "unit": "lb",
      "entryCount": 24,
      "lastEntry": {
        "id": "6ad6af4305c6094205c47641",
        "date": "2026-10-26",
        "value": 182.4
      }
    }
  ]
}
```

## List a metric's entries

`GET https://api.hubfit.com/v1/metrics/{metricId}/entries`

What the client logged for one metric, latest day first, and of one day's entries the last added first. 404 if the coach turned metrics off for the client. Requires `clients:read`.

### Path parameters

- `metricId` (string, required): A metric `id` from `GET /clients/{clientId}/metrics`.

### Query parameters

- `startDate` (date): Only days from this date, included, as `YYYY-MM-DD`. Days are the client's own calendar days.
- `endDate` (date): Only days up to this date, included, as `YYYY-MM-DD`.
- `limit` (integer): How many results to return, from 1 to 100. Default `25`.
- `cursor` (string): The `nextCursor` from the previous page.

### Returns

A page of the metric's entries.

### Example request

cURL:

```bash
curl -G https://api.hubfit.com/v1/metrics/6ad6af776298037662967079/entries \
  -H "Authorization: Bearer $HUBFIT_API_KEY" \
  -d startDate=2026-09-01
```

Node.js:

```javascript
const response = await fetch("https://api.hubfit.com/v1/metrics/6ad6af776298037662967079/entries?startDate=2026-09-01", {
  headers: {
    Authorization: `Bearer ${process.env.HUBFIT_API_KEY}`,
  },
});

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

Python:

```python
import os
import requests

response = requests.get(
    "https://api.hubfit.com/v1/metrics/6ad6af776298037662967079/entries",
    headers={"Authorization": f"Bearer {os.environ['HUBFIT_API_KEY']}"},
    params={
        "startDate": "2026-09-01",
    },
)

page = response.json()
data, next_cursor = page["data"], page["nextCursor"]
```

### Example response (200 OK)

```json
{
  "data": [
    {
      "id": "6ad6afb5dd068db4dd04fab3",
      "date": "2026-10-26",
      "value": 182.4
    }
  ],
  "nextCursor": "eyJpZCI6IjZhZDZhZjNmMjljNTk3ZjE1In0",
  "totalCount": 48
}
```
