Set nutrition figures
Send your own calories, protein, carbs and fat per dish to fill the figures the restaurant left empty in Tamr.
/api/v1/catalog/nutritionServer API · secret keyYour own figures, per serving, by Tamr's dishId or your externalId. They only fill the gaps: a figure the restaurant typed in Tamr always wins, and Tamr never estimates one. A field left out is unchanged and null removes your figure. Up to 500 rows, all or nothing: a refused call is a 400 whose data.rows gives each bad row's reason (unknown_dish, unknown_external_id, out_of_range, duplicate). updated counts the dishes whose figures changed.
Per serving: calories (0 to 10,000) and proteinGrams, carbsGrams, fatGrams (0 to 2,000 each). A field left out is unchanged; null removes your figure. Your figures only fill the gaps: a figure the restaurant typed in Tamr always wins.
Authentication
Server API. Send a secret API key with the Catalog ids (SDK) permission (catalog:sdk) as Authorization: Bearer <key>. Secret keys are made in Settings > API keys by an owner or admin. Keep them on your server: no browser can call this route.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
dishes | array of object | Yes | 1 to 500 items. |
dishes[].dishId | string | No | 1 to 200 characters. |
dishes[].externalId | string | No | 1 to 200 characters. |
dishes[].calories | integer or null | No | -9,007,199,254,740,991 to 9,007,199,254,740,991. |
dishes[].proteinGrams | integer or null | No | -9,007,199,254,740,991 to 9,007,199,254,740,991. |
dishes[].carbsGrams | integer or null | No | -9,007,199,254,740,991 to 9,007,199,254,740,991. |
dishes[].fatGrams | integer or null | No | -9,007,199,254,740,991 to 9,007,199,254,740,991. |
Response
| Field | Type | Description |
|---|---|---|
updated | integer | 0 to 9,007,199,254,740,991. |
Example
curl -X PUT https://tamr.link/api/v1/catalog/nutrition \
-H "Authorization: Bearer $TAMR_SECRET_KEY" \
-H "content-type: application/json" \
-d '{
"dishes": [
{
"externalId": "SKU-1042",
"calories": 640,
"proteinGrams": 42
},
{
"dishId": "cmdish0001",
"carbsGrams": 18,
"fatGrams": null
}
]
}'import { createServerClient } from "@tamr/api/server";
const tamr = createServerClient({ secretKey: process.env.TAMR_SECRET_KEY });
const result = await tamr.nutritionPut({
dishes: [
{ externalId: "SKU-1042", calories: 640, proteinGrams: 42 },
{ dishId: "cmdish0001", carbsGrams: 18, fatGrams: null },
],
});
console.log(result);import os
import requests
API = "https://tamr.link/api/v1"
headers = {"Authorization": f"Bearer {os.environ['TAMR_SECRET_KEY']}"}
response = requests.put(
f"{API}/catalog/nutrition",
headers=headers,
json={
"dishes": [
{
"externalId": "SKU-1042",
"calories": 640,
"proteinGrams": 42,
},
{"dishId": "cmdish0001", "carbsGrams": 18, "fatGrams": None},
],
},
timeout=30,
)
response.raise_for_status()
print(response.json())Example response
{
"updated": 3
}Errors
Every error has the same body; switch on data.code. See Errors and rate limits.
data.code | Status | What to do |
|---|---|---|
other | 401 | No secret key, or one Tamr doesn't accept: wrong, revoked, or made by someone who is no longer an owner or admin. |
other | 403 | The key doesn't have the catalog:sdk permission. |
invalid_request | 400 | A field doesn't match the spec. The message says which. |
rate_limited | 429 | Wait retryAfter seconds (also in the Retry-After header), then try again. |
sdk_disabled | 403 | The SDK isn't switched on for this restaurant. Ask Tamr. |