# Nutrition

> The food your clients logged each day, against their daily targets.

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


A nutrition log is one day of food a client logged in HubFit, with the meals, foods, photos and note they recorded and the day's target. A day appears only once the client logs something. A client's nutrition target is the daily goal set for each weekday, by the coach or by the client in the app. Clients who track in Cronometer instead have no logs here. To compare clients' nutrition over a period, use `GET /client-summaries` with `include=nutrition`.

Endpoints:

- `GET /v1/clients/{clientId}/nutrition-target`: [Get a client's nutrition target](https://hubfit.com/developers/api/nutrition#get-client-nutrition-target)
- `GET /v1/nutrition-logs`: [List nutrition logs](https://hubfit.com/developers/api/nutrition#list-nutrition-logs)
- `GET /v1/nutrition-logs/{logId}`: [Get a nutrition log](https://hubfit.com/developers/api/nutrition#get-nutrition-log)

## Nutrition log object

### Attributes

- `id` (string): Its unique ID.
- `client` (object)
  - `id` (string): Its unique ID.
  - `name` (string)
- `date` (date): The client's calendar day the log is for.
- `totals` (object): What was eaten, in kilocalories and grams. A nutrient the food doesn't list counts as 0.
  - `calories` (number): Kilocalories.
  - `proteinGrams` (number)
  - `carbsGrams` (number)
  - `fatGrams` (number)
  - `fiberGrams` (number)
  - `sugarGrams` (number)
  - `saturatedFatGrams` (number)
  - `monounsaturatedFatGrams` (number)
  - `polyunsaturatedFatGrams` (number)
- `target` (object, nullable): The day's target as it stood when the client last saved the day, the rest-day target on a rest day. `null` if no target was set; each value is `null` if it was left empty.
  - `calories` (number, nullable)
  - `proteinGrams` (number, nullable)
  - `carbsGrams` (number, nullable)
  - `fatGrams` (number, nullable)
- `foodCount` (integer): How many foods the client logged that day.
- `photoCount` (integer): How many meal photos the client added to the day's food journal.
- `note` (string): The client's note on the day. Empty if none.
- `meals` (array of objects): The day's meals, named as the client's Daily Meals, in order.
  - `name` (string)
  - `foods` (array of objects)
    - `name` (string)
    - `servingDescription` (string): The serving the client picked, such as `1 cup` or `100 g`.
    - `servings` (number): How many of that serving the client ate.
    - `nutrients` (object): What was eaten, in kilocalories and grams. A nutrient the food doesn't list counts as 0.
      - `calories` (number): Kilocalories.
      - `proteinGrams` (number)
      - `carbsGrams` (number)
      - `fatGrams` (number)
      - `fiberGrams` (number)
      - `sugarGrams` (number)
      - `saturatedFatGrams` (number)
      - `monounsaturatedFatGrams` (number)
      - `polyunsaturatedFatGrams` (number)
  - `photoCount` (integer): How many photos the client added to this meal.

### Example

```json
{
  "id": "6ad6af7dba37657cba35d27b",
  "client": {
    "id": "6ad6af41d3199442d31b2743",
    "name": "Jordan Miller"
  },
  "date": "2026-10-26",
  "totals": {
    "calories": 2350,
    "proteinGrams": 180,
    "carbsGrams": 240,
    "fatGrams": 70,
    "fiberGrams": 32,
    "sugarGrams": 45,
    "saturatedFatGrams": 22,
    "monounsaturatedFatGrams": 28,
    "polyunsaturatedFatGrams": 14
  },
  "target": {
    "calories": 2350,
    "proteinGrams": 180,
    "carbsGrams": 240,
    "fatGrams": 70
  },
  "foodCount": 12,
  "photoCount": 2,
  "note": "Felt strong. Added 5 lb on bench.",
  "meals": [
    {
      "name": "Breakfast",
      "foods": [
        {
          "name": "Greek yogurt, plain",
          "servingDescription": "1 cup (245 g)",
          "servings": 1,
          "nutrients": {
            "calories": 2350,
            "proteinGrams": 180,
            "carbsGrams": 240,
            "fatGrams": 70,
            "fiberGrams": 32,
            "sugarGrams": 45,
            "saturatedFatGrams": 22,
            "monounsaturatedFatGrams": 28,
            "polyunsaturatedFatGrams": 14
          }
        }
      ],
      "photoCount": 2
    }
  ]
}
```

## Nutrition target object

### Attributes

- `monday` (object): Each value is `null` if it was left empty.
  - `calories` (number, nullable)
  - `proteinGrams` (number, nullable)
  - `carbsGrams` (number, nullable)
  - `fatGrams` (number, nullable)
  - `isRestDay` (boolean): Whether this weekday is marked as a rest day, which has its own target.
- `tuesday` (object): Each value is `null` if it was left empty.
  - `calories` (number, nullable)
  - `proteinGrams` (number, nullable)
  - `carbsGrams` (number, nullable)
  - `fatGrams` (number, nullable)
  - `isRestDay` (boolean): Whether this weekday is marked as a rest day, which has its own target.
- `wednesday` (object): Each value is `null` if it was left empty.
  - `calories` (number, nullable)
  - `proteinGrams` (number, nullable)
  - `carbsGrams` (number, nullable)
  - `fatGrams` (number, nullable)
  - `isRestDay` (boolean): Whether this weekday is marked as a rest day, which has its own target.
- `thursday` (object): Each value is `null` if it was left empty.
  - `calories` (number, nullable)
  - `proteinGrams` (number, nullable)
  - `carbsGrams` (number, nullable)
  - `fatGrams` (number, nullable)
  - `isRestDay` (boolean): Whether this weekday is marked as a rest day, which has its own target.
- `friday` (object): Each value is `null` if it was left empty.
  - `calories` (number, nullable)
  - `proteinGrams` (number, nullable)
  - `carbsGrams` (number, nullable)
  - `fatGrams` (number, nullable)
  - `isRestDay` (boolean): Whether this weekday is marked as a rest day, which has its own target.
- `saturday` (object): Each value is `null` if it was left empty.
  - `calories` (number, nullable)
  - `proteinGrams` (number, nullable)
  - `carbsGrams` (number, nullable)
  - `fatGrams` (number, nullable)
  - `isRestDay` (boolean): Whether this weekday is marked as a rest day, which has its own target.
- `sunday` (object): Each value is `null` if it was left empty.
  - `calories` (number, nullable)
  - `proteinGrams` (number, nullable)
  - `carbsGrams` (number, nullable)
  - `fatGrams` (number, nullable)
  - `isRestDay` (boolean): Whether this weekday is marked as a rest day, which has its own target.

### Example

```json
{
  "monday": {
    "calories": 2350,
    "proteinGrams": 180,
    "carbsGrams": 240,
    "fatGrams": 70,
    "isRestDay": true
  },
  "tuesday": {
    "calories": 2350,
    "proteinGrams": 180,
    "carbsGrams": 240,
    "fatGrams": 70,
    "isRestDay": true
  },
  "wednesday": {
    "calories": 2350,
    "proteinGrams": 180,
    "carbsGrams": 240,
    "fatGrams": 70,
    "isRestDay": true
  },
  "thursday": {
    "calories": 2350,
    "proteinGrams": 180,
    "carbsGrams": 240,
    "fatGrams": 70,
    "isRestDay": true
  },
  "friday": {
    "calories": 2350,
    "proteinGrams": 180,
    "carbsGrams": 240,
    "fatGrams": 70,
    "isRestDay": true
  },
  "saturday": {
    "calories": 2350,
    "proteinGrams": 180,
    "carbsGrams": 240,
    "fatGrams": 70,
    "isRestDay": true
  },
  "sunday": {
    "calories": 2350,
    "proteinGrams": 180,
    "carbsGrams": 240,
    "fatGrams": 70,
    "isRestDay": true
  }
}
```

## Get a client's nutrition target

`GET https://api.hubfit.com/v1/clients/{clientId}/nutrition-target`

The client's current daily target for calories and macros, for each day of the week, set by the coach or by the client in the app. A weekday marked as a rest day has the rest-day target. `data` is `null` if no target is set. Requires `clients:read`.

### Path parameters

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

### Returns

The client's target for each weekday.

### Example request

cURL:

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

Node.js:

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

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

### Example response (200 OK)

```json
{
  "data": {
    "monday": {
      "calories": 2350,
      "proteinGrams": 180,
      "carbsGrams": 240,
      "fatGrams": 70,
      "isRestDay": true
    },
    "tuesday": {
      "calories": 2350,
      "proteinGrams": 180,
      "carbsGrams": 240,
      "fatGrams": 70,
      "isRestDay": true
    },
    "wednesday": {
      "calories": 2350,
      "proteinGrams": 180,
      "carbsGrams": 240,
      "fatGrams": 70,
      "isRestDay": true
    },
    "thursday": {
      "calories": 2350,
      "proteinGrams": 180,
      "carbsGrams": 240,
      "fatGrams": 70,
      "isRestDay": true
    },
    "friday": {
      "calories": 2350,
      "proteinGrams": 180,
      "carbsGrams": 240,
      "fatGrams": 70,
      "isRestDay": true
    },
    "saturday": {
      "calories": 2350,
      "proteinGrams": 180,
      "carbsGrams": 240,
      "fatGrams": 70,
      "isRestDay": true
    },
    "sunday": {
      "calories": 2350,
      "proteinGrams": 180,
      "carbsGrams": 240,
      "fatGrams": 70,
      "isRestDay": true
    }
  }
}
```

## List nutrition logs

`GET https://api.hubfit.com/v1/nutrition-logs`

The days your clients logged food, newest first, with each day's totals and target but not its meals. Across every client you can reach (team members with the Standard role only see their assigned clients), or one client's with `clientId`. Requires `clients:read`.

### Query parameters

- `clientId` (string): Only this client's logs.
- `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 nutrition logs.

### Example request

cURL:

```bash
curl -G https://api.hubfit.com/v1/nutrition-logs \
  -H "Authorization: Bearer $HUBFIT_API_KEY" \
  -d clientId=6ad6af41d3199442d31b2743 \
  -d startDate=2026-10-20
```

Node.js:

```javascript
const response = await fetch("https://api.hubfit.com/v1/nutrition-logs?clientId=6ad6af41d3199442d31b2743&startDate=2026-10-20", {
  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/nutrition-logs",
    headers={"Authorization": f"Bearer {os.environ['HUBFIT_API_KEY']}"},
    params={
        "clientId": "6ad6af41d3199442d31b2743",
        "startDate": "2026-10-20",
    },
)

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

### Example response (200 OK)

```json
{
  "data": [
    {
      "id": "6ad6af7dba37657cba35d27b",
      "client": {
        "id": "6ad6af41d3199442d31b2743",
        "name": "Jordan Miller"
      },
      "date": "2026-10-26",
      "totals": {
        "calories": 2350,
        "proteinGrams": 180,
        "carbsGrams": 240,
        "fatGrams": 70,
        "fiberGrams": 32,
        "sugarGrams": 45,
        "saturatedFatGrams": 22,
        "monounsaturatedFatGrams": 28,
        "polyunsaturatedFatGrams": 14
      },
      "target": {
        "calories": 2350,
        "proteinGrams": 180,
        "carbsGrams": 240,
        "fatGrams": 70
      },
      "foodCount": 12,
      "photoCount": 2,
      "note": "Felt strong. Added 5 lb on bench."
    }
  ],
  "nextCursor": "eyJpZCI6IjZhZDZhZjNmMjljNTk3ZjE1In0",
  "totalCount": 48
}
```

## Get a nutrition log

`GET https://api.hubfit.com/v1/nutrition-logs/{logId}`

One day a client logged, with every meal (in the order of the client's Daily Meals) and the foods in it. Requires `clients:read`.

### Path parameters

- `logId` (string, required): The log's `id`.

### Returns

The nutrition log.

### Example request

cURL:

```bash
curl https://api.hubfit.com/v1/nutrition-logs/6ad6af7dba37657cba35d27b \
  -H "Authorization: Bearer $HUBFIT_API_KEY"
```

Node.js:

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

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

### Example response (200 OK)

```json
{
  "data": {
    "id": "6ad6af7dba37657cba35d27b",
    "client": {
      "id": "6ad6af41d3199442d31b2743",
      "name": "Jordan Miller"
    },
    "date": "2026-10-26",
    "totals": {
      "calories": 2350,
      "proteinGrams": 180,
      "carbsGrams": 240,
      "fatGrams": 70,
      "fiberGrams": 32,
      "sugarGrams": 45,
      "saturatedFatGrams": 22,
      "monounsaturatedFatGrams": 28,
      "polyunsaturatedFatGrams": 14
    },
    "target": {
      "calories": 2350,
      "proteinGrams": 180,
      "carbsGrams": 240,
      "fatGrams": 70
    },
    "foodCount": 12,
    "photoCount": 2,
    "note": "Felt strong. Added 5 lb on bench.",
    "meals": [
      {
        "name": "Breakfast",
        "foods": [
          {
            "name": "Greek yogurt, plain",
            "servingDescription": "1 cup (245 g)",
            "servings": 1,
            "nutrients": {
              "calories": 2350,
              "proteinGrams": 180,
              "carbsGrams": 240,
              "fatGrams": 70,
              "fiberGrams": 32,
              "sugarGrams": 45,
              "saturatedFatGrams": 22,
              "monounsaturatedFatGrams": 28,
              "polyunsaturatedFatGrams": 14
            }
          }
        ],
        "photoCount": 2
      }
    ]
  }
}
```
