CookToolAPI

API Reference

API Reference

Base URL: https://api.cooktool.org/v1. All endpoints require the x-api-key header. Responses are JSON. HTTP status codes follow REST conventions.

Quick start

  1. Create a free account to get your API key.
  2. Copy the key — it is only shown once. Store it securely.
  3. Pass the key in every request via the x-api-key header.

cURL

bash
# 1. Get your free API key at api.cooktool.org/signup
# 2. Make your first request
curl "https://api.cooktool.org/v1/search?q=chicken" \
  -H "x-api-key: ctk_live_YOUR_KEY_HERE"

JavaScript

javascript
const res = await fetch(
  'https://api.cooktool.org/v1/ingredients/42?',
  { headers: { 'x-api-key': 'ctk_live_YOUR_KEY_HERE' } }
);
const data = await res.json();
console.log(data.name, data.nutrients[0]);

Python

python
import requests

r = requests.get(
    'https://api.cooktool.org/v1/ingredients/42',
    headers={'x-api-key': 'ctk_live_YOUR_KEY_HERE'}
)
print(r.json()['name'])

Authentication

All API requests must include your API key in the x-api-key HTTP header. Keys follow the format ctk_live_<32-hex-chars>.

bash
curl https://api.cooktool.org/v1/nutrients \
  -H "x-api-key: ctk_live_a1b2c3d4e5f6..."

200 OK

Request succeeded

401 Unauthorized

Missing or invalid API key

429 Too Many Requests

Rate limit exceeded — slow down or upgrade

Rate limits

PlanRequests / dayRequests / secondAPI keys
Free1,00051
Pro20,000202
Enterprise20,000505

When you exceed the rate limit, the API returns 429 Too Many Requests. The daily counter resets at UTC midnight.

Ingredients

GET/v1/ingredients

List canonical ingredients. Supports free-text search, category filter, and allergen filter.

Parameters

NameTypeDescription
qstringFree-text search on ingredient name
categoryintegerFilter by category_id
allergenstringFilter by allergen (gluten, dairy, eggs, nuts…)
limitintegerMax results (default 20, max 100)
offsetintegerPagination offset (default 0)

Example

bash
curl "https://api.cooktool.org/v1/ingredients?q=chicken&allergen=eggs&limit=5" \
  -H "x-api-key: ctk_live_..."

Response

json
{ "data": [ { "id": 42, "name": "Chicken breast, raw", "category_id": 5, "data_type": "sr_legacy" } ], "limit": 5, "offset": 0 }
GET/v1/ingredients/:id

Get a single ingredient with full nutrient profile, density data, and allergen list.

Parameters

NameTypeDescription
id*integerIngredient ID

Example

bash
curl "https://api.cooktool.org/v1/ingredients/42" -H "x-api-key: ctk_live_..."

Response

json
{
  "id": 42, "name": "Chicken breast, raw", "category_id": 5,
  "nutrients": [ { "nutrient_id": 1, "name": "Energy", "unit": "kcal", "amount": 165 } ],
  "density": { "g_per_ml": 1.02, "g_per_cup": 240.5, "source": "usda" },
  "allergens": []
}

Nutrients (country-resolved)

GET/v1/ingredients/:id/nutrients

Returns the best verified national nutrient values for the requested country, falling back to USDA SR for any nutrient not covered by the national database.

Parameters

NameTypeDescription
id*integerIngredient ID
countrystringISO 3166-1 alpha-2 country code (GB, DE, FR, SE, NO, DK). Defaults to US.

Example

bash
curl "https://api.cooktool.org/v1/ingredients/42/nutrients?country=DE" \
  -H "x-api-key: ctk_live_..."

Response

json
{
  "id": 42, "name": "Chicken breast, raw", "country": "DE",
  "nutrients": [
    { "nutrient_id": 1, "name": "Energy", "unit": "kcal", "amount": 110, "source": "bls" },
    { "nutrient_id": 2, "name": "Protein", "unit": "g",   "amount": 23.1, "source": "bls" },
    { "nutrient_id": 3, "name": "Omega-3", "unit": "g",   "amount": 0.04, "source": "usda_fallback" }
  ]
}

CO₂ footprint

GET/v1/ingredients/:id/carbon

Returns the ISO 14040-compliant GHG intensity (kg CO₂e / kg food) for the ingredient, with source dataset, DQR score, and uncertainty range.

Parameters

NameTypeDescription
id*integerIngredient ID
countrystringPrefer AGRIBALYSE values for FR/EU context when country=FR. Defaults to global average.

Example

bash
curl "https://api.cooktool.org/v1/ingredients/42/carbon?country=FR" \
  -H "x-api-key: ctk_live_..."

Response

json
{
  "id": 42, "name": "Chicken breast, raw",
  "carbon": {
    "kg_co2e_per_kg": 6.9,
    "source": "poore_nemecek_2018",
    "dqr": 1,
    "boundary": "cradle_to_retail",
    "uncertainty_low": 5.1,
    "uncertainty_high": 10.2,
    "unit": "kg CO2e / kg food"
  }
}

Yield factors

GET/v1/ingredients/:id/yield

Returns the yield factor and nutrient retention factors for a given cooking method. Multiply raw nutrient amounts by the retention factor to get cooked values.

Parameters

NameTypeDescription
id*integerIngredient ID
methodstringCooking method: boiling, frying, baking, steaming, grilling. Default: boiling.

Example

bash
curl "https://api.cooktool.org/v1/ingredients/42/yield?method=grilling" \
  -H "x-api-key: ctk_live_..."

Response

json
{
  "id": 42, "name": "Chicken breast, raw", "method": "grilling",
  "yield_factor": 0.74,
  "nutrient_retention": {
    "protein": 1.00, "fat": 0.96, "energy": 0.97,
    "vitamin_b1": 0.79, "vitamin_b6": 0.77
  }
}

Unit conversion

GET/v1/ingredients/:id/convert

Convert between weight, volume, and piece units using ingredient-specific density and piece-weight data.

Parameters

NameTypeDescription
id*integerIngredient ID
from*stringSource unit (g, kg, oz, lb, ml, l, cup, tbsp, tsp, piece)
to*stringTarget unit (same set as from)
amount*numberAmount in source unit

Example

bash
curl "https://api.cooktool.org/v1/ingredients/1001/convert?from=cup&to=g&amount=2" \
  -H "x-api-key: ctk_live_..."

Response

json
{
  "id": 1001, "name": "Butter, salted",
  "from": { "unit": "cup", "amount": 2 },
  "to":   { "unit": "g",   "amount": 454 },
  "density_source": "usda"
}

Survey foods

GET/v1/survey-foods

List FNDDS survey foods (Tier 2). Filter by WWEIA category code.

Parameters

NameTypeDescription
qstringFree-text search
wweiaintegerWWEIA category code filter
limitintegerMax results (default 20, max 100)
offsetintegerPagination offset

Example

bash
curl "https://api.cooktool.org/v1/survey-foods?q=pizza&limit=5" -H "x-api-key: ctk_live_..."
GET/v1/survey-foods/:id/components

Decompose a survey food into its Tier-1 canonical ingredients with gram amounts.

Parameters

NameTypeDescription
id*integerSurvey food ID

Example

bash
curl "https://api.cooktool.org/v1/survey-foods/1001/components" -H "x-api-key: ctk_live_..."

Branded products

GET/v1/branded

Search 2M+ branded food products. Look up by GTIN/UPC barcode or brand name.

Parameters

NameTypeDescription
qstringFree-text search on product name
gtinstringExact GTIN/UPC barcode lookup
brandstringPartial brand owner name match
limitintegerMax results (default 20, max 100)
offsetintegerPagination offset

Example

bash
curl "https://api.cooktool.org/v1/branded?gtin=00038000138416" -H "x-api-key: ctk_live_..."

Nutrient list

GET/v1/nutrients

List all nutrient definitions (id, usda_id, name, unit). Useful for mapping nutrient_id values in other responses.

Example

bash
curl "https://api.cooktool.org/v1/nutrients" -H "x-api-key: ctk_live_..."

Categories

GET/v1/categories

List all ingredient categories for use as filter values in /v1/ingredients.

Example

bash
curl "https://api.cooktool.org/v1/categories" -H "x-api-key: ctk_live_..."