# Search the food database

`GET https://api.coach-platform.com/api/public/food-items`

Search the food database the dashboard searches: the shared catalog plus the coach's own items. Use it to build meals with real nutrition data — copy productCode, the per-100g macros and a unit/unitWeight pair onto each meal food item. Omit search and barcode to browse the catalog.

- Resource: Nutrition Menus
- Authentication: API key in the `Authorization: Bearer cp_live_...` header
- HTML version: https://www.coach-platform.com/docs/api/reference/get-food-items
- OpenAPI spec: https://www.coach-platform.com/openapi.json

## Query parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `page` | integer | No | Page number (1-based, default 1) Minimum: `1`. |
| `limit` | integer | No | Number of items to return (default 25, max 500) Minimum: `1`. Maximum: `500`. |
| `search` | string | No | Food name to search for. Matches anywhere in the name, best matches first. |
| `barcode` | string | No | Exact barcode lookup. Takes precedence over search. |

## Responses

| Status | Description |
|---|---|
| `200` OK | Successful response |
| `400` Bad Request |  |
| `401` Unauthorized |  |
| `403` Forbidden |  |
| `429` Too Many Requests |  |
| `500` Internal Server Error |  |

### 200 OK

Content type: `application/json`

| Field | Type | Description |
|---|---|---|
| `data` | object[] |   |
| `data[].id` | string |   |
| `data[].productCode` | number | Send this as productCode on a meal food item to link it to this entry. |
| `data[].name` | string |   |
| `data[].manufacturer` | string |   |
| `data[].barcode` | string |   |
| `data[].caloriesPer100g` | number |   |
| `data[].proteinPer100g` | number |   |
| `data[].carbsPer100g` | number |   |
| `data[].fatPer100g` | number |   |
| `data[].isFavorite` | boolean |   |
| `data[].isCustom` | boolean | True when the coach created this item, false when it comes from the shared database. |
| `data[].units` | object[] | Units this food can be measured in. unitWeight is how many grams one unit weighs — copy the pair onto a meal food item as unit + unitWeight. |
| `data[].units[].unit` | string |   |
| `data[].units[].unitWeight` | number |   |
| `pagination` | object |   |
| `pagination.page` | number |   |
| `pagination.limit` | number |   |
| `pagination.total` | number \| null | Total number of matching items. null when the underlying source cannot report an exact count for this page; use hasMore to keep paging. |
| `pagination.hasMore` | boolean |   |
| `pagination.truncated` | boolean | Present and true when the result set exceeded the in-memory scan cap and was truncated. Narrow your filters to page through all items. |

Example:

```json
{
  "data": [
    {
      "id": "<string>",
      "productCode": 123,
      "name": "<string>",
      "manufacturer": "<string>",
      "barcode": "<string>",
      "caloriesPer100g": 123,
      "proteinPer100g": 123,
      "carbsPer100g": 123,
      "fatPer100g": 123,
      "isFavorite": true,
      "isCustom": true,
      "units": [
        {
          "unit": "<string>",
          "unitWeight": 123
        }
      ]
    }
  ],
  "pagination": {
    "page": 123,
    "limit": 123,
    "total": 123,
    "hasMore": true,
    "truncated": true
  }
}
```

### Error responses 400, 401, 403, 429, 500

Content type: `application/json`

| Field | Type | Description |
|---|---|---|
| `error` | object |   |
| `error.code` | string |   |
| `error.message` | string |   |
| `error.fix` | string \| null |   |
| `error.details` | object \| null |   |
| `error.retryAfterMs` | number \| null |   |

Example:

```json
{
  "error": {
    "code": "<string>",
    "message": "<string>",
    "fix": "<string>",
    "details": {},
    "retryAfterMs": 123
  }
}
```

## Examples

### cURL

```bash
curl --request GET \
  --url 'https://api.coach-platform.com/api/public/food-items' \
  --header 'Authorization: Bearer cp_live_...'
```

### JavaScript (fetch)

```js
const response = await fetch('https://api.coach-platform.com/api/public/food-items', {
  method: 'GET',
  headers: {
    Authorization: 'Bearer cp_live_...',
  },
});

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

## Related endpoints

- [Get a trainee's daily nutrition log](https://www.coach-platform.com/docs/api/reference/get-trainees-trainee-id-nutrition-log/index.md): `GET /api/public/trainees/{traineeId}/nutrition-log`. What a trainee actually ate on ONE day: the food log for that date, per-meal and per-day calorie/macro totals, and the times of day the food was logged.
- [List nutrition menus](https://www.coach-platform.com/docs/api/reference/get-nutrition-menus/index.md): `GET /api/public/nutrition-menus`. List nutrition menus.
- [Create a nutrition menu](https://www.coach-platform.com/docs/api/reference/post-nutrition-menus/index.md): `POST /api/public/nutrition-menus`. Create a nutrition menu.
- [Get a nutrition menu](https://www.coach-platform.com/docs/api/reference/get-nutrition-menus-menu-id/index.md): `GET /api/public/nutrition-menus/{menuId}`. Get a nutrition menu by id (with full meals breakdown).
- [Update a nutrition menu](https://www.coach-platform.com/docs/api/reference/patch-nutrition-menus-menu-id/index.md): `PATCH /api/public/nutrition-menus/{menuId}`. Partially update a nutrition menu.
- [Delete a nutrition menu](https://www.coach-platform.com/docs/api/reference/delete-nutrition-menus-menu-id/index.md): `DELETE /api/public/nutrition-menus/{menuId}`. Delete a nutrition menu permanently.
- [Get a trainee's active nutrition menu](https://www.coach-platform.com/docs/api/reference/get-trainees-trainee-id-active-nutrition-menu/index.md): `GET /api/public/trainees/{traineeId}/active-nutrition-menu`. Get a trainee's currently active nutrition menu (resolved via the active coaching period).
- [Add an alternative meal](https://www.coach-platform.com/docs/api/reference/post-nutrition-menus-menu-id-meals-meal-id-alternatives/index.md): `POST /api/public/nutrition-menus/{menuId}/meals/{mealId}/alternatives`. Add an alternative meal to one meal of a menu — the same "add alternative meal" the dashboard offers.
- [Remove an alternative meal](https://www.coach-platform.com/docs/api/reference/delete-nutrition-menus-menu-id-meals-meal-id-alternatives-alternative-id/index.md): `DELETE /api/public/nutrition-menus/{menuId}/meals/{mealId}/alternatives/{alternativeId}`. Remove one alternative meal from a meal.
- Previous: [Remove an alternative meal](https://www.coach-platform.com/docs/api/reference/delete-nutrition-menus-menu-id-meals-meal-id-alternatives-alternative-id/index.md): `DELETE /api/public/nutrition-menus/{menuId}/meals/{mealId}/alternatives/{alternativeId}`. Remove one alternative meal from a meal.
- Next: [List meetings](https://www.coach-platform.com/docs/api/reference/get-meetings/index.md): `GET /api/public/meetings`. List meetings in a time window.
