Search the food database

GET/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.

Authentication

Requires an API key, sent as Authorization: Bearer cp_live_....

API keys carry scopes. Get the catalog of scopes and webhook events lists every scope.

Query parameters

Query parameters
NameTypeDescription
pageinteger

Page number (1-based, default 1)

Minimum: 1

limitinteger

Number of items to return (default 25, max 500)

Minimum: 1

Maximum: 500

searchstring

Food name to search for. Matches anywhere in the name, best matches first.

barcodestring

Exact barcode lookup. Takes precedence over search.

Request examples

cURL
curl --request GET \
  --url 'https://api.coach-platform.com/api/public/food-items' \
  --header 'Authorization: Bearer cp_live_...'
JavaScript (fetch)
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();

Responses

200 OK

Successful response

Example body (application/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
  }
}
Response fields (21)
Response fields
NameTypeDescription
dataobject[]
data[].idstring
data[].productCodenumber

Send this as productCode on a meal food item to link it to this entry.

data[].namestring
data[].manufacturerstring
data[].barcodestring
data[].caloriesPer100gnumber
data[].proteinPer100gnumber
data[].carbsPer100gnumber
data[].fatPer100gnumber
data[].isFavoriteboolean
data[].isCustomboolean

True when the coach created this item, false when it comes from the shared database.

data[].unitsobject[]

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[].unitstring
data[].units[].unitWeightnumber
paginationobject
pagination.pagenumber
pagination.limitnumber
pagination.totalnumber | 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.hasMoreboolean
pagination.truncatedboolean

Present and true when the result set exceeded the in-memory scan cap and was truncated. Narrow your filters to page through all items.

Error responses

  • 400 Bad Request
  • 401 Unauthorized
  • 403 Forbidden
  • 429 Too Many Requests
  • 500 Internal Server Error

These statuses share the same response body.

Example body (application/json)
{
  "error": {
    "code": "<string>",
    "message": "<string>",
    "fix": "<string>",
    "details": {},
    "retryAfterMs": 123
  }
}
Error fields (6)
Error fields
NameTypeDescription
errorobject
error.codestring
error.messagestring
error.fixstring | null
error.detailsobject | null
error.retryAfterMsnumber | null

This page is also available as Markdown. Browse it in the interactive explorer or download the OpenAPI spec.