Integrate other apps and scripts with your MacroLog diary. All endpoints live under
api/v1.php and return JSON.
Create an API key in Settings → API keys. The key is shown once — store it safely. Send it with every request as a Bearer token:
Authorization: Bearer mlog_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Keys can be revoked at any time from Settings. A missing or invalid key returns
401 with an error field.
Every diary entry for one day.
curl -H "Authorization: Bearer mlog_..." \
"https://example.com/food/api/v1.php?action=day&date=2026-07-03"
{ "date": "2026-07-03",
"entries": [
{ "id": 91, "meal": "breakfast", "quantity_g": "60.00", "calories": "226.20",
"protein_g": "7.50", "carbs_g": "41.20", "fat_g": "3.10",
"food_id": 12, "name": "Porridge Oats", "brand": "Quaker", "unit": "g" } ] }
Dashboard-friendly view of one day: your daily target (including any per-day
adjustment), consumed totals, calories remaining, and a per-meal breakdown
with each meal's items. date is optional and defaults to today. target and
remaining are null if you haven't set a target.
curl -H "Authorization: Bearer mlog_..." \
"https://example.com/food/api/v1.php?action=summary&date=2026-07-03"
{ "date": "2026-07-03",
"target": { "calories": 2200, "protein_g": 160, "carbs_g": 200, "fat_g": 70 },
"consumed": { "calories": 1470, "protein_g": 96, "carbs_g": 150, "fat_g": 52 },
"remaining": 730,
"meals": {
"breakfast": { "calories": 320, "items": [ { "name": "Porridge Oats (Quaker)", "calories": 226 } ] },
"lunch": { "calories": 0, "items": [] },
"dinner": { "calories": 0, "items": [] },
"snacks": { "calories": 0, "items": [] } } }
Daily calorie/macro totals for a date range (max 1 year).
{ "days": [
{ "log_date": "2026-07-01", "calories": "1890.40", "protein_g": "141.00",
"carbs_g": "180.20", "fat_g": "61.90" } ] }
Search your foods and the local food cache (min 2 characters). Returns an array of
foods; use a food's id as food_item_id when logging.
Log a food to your diary. Body (JSON):
| Field | Required | Notes |
|---|---|---|
food_item_id | yes | From search or create_food |
meal | yes | breakfast, lunch, dinner or snacks |
quantity_g | yes | Grams (or ml for liquid foods), 1–5000 |
date | yes | YYYY-MM-DD |
curl -X POST -H "Authorization: Bearer mlog_..." -H "Content-Type: application/json" \
-d '{"food_item_id":12,"meal":"lunch","quantity_g":150,"date":"2026-07-03"}' \
"https://example.com/food/api/v1.php?action=log"
{ "logged": true, "id": 231 }
Create a custom food (appears in "My Foods"). Nutrients are per 100 g / 100 ml.
| Field | Required | Notes |
|---|---|---|
name | yes | Up to 255 chars |
calories_per_100g | yes | kcal per 100 g/ml |
protein_per_100g, carbs_per_100g, fat_per_100g | no | Grams per 100 g/ml (default 0) |
brand | no | |
unit | no | g (default) or ml |
serving_desc | no | e.g. "1 bar (45 g)" |
serving_size_g | no | Numeric serving size |
curl -X POST -H "Authorization: Bearer mlog_..." -H "Content-Type: application/json" \
-d '{"name":"Protein Flapjack","brand":"HomeMade","calories_per_100g":420,
"protein_per_100g":22,"carbs_per_100g":40,"fat_per_100g":18,
"serving_desc":"1 bar (60 g)","serving_size_g":60}' \
"https://example.com/food/api/v1.php?action=create_food"
{ "food": { "id": 87, "name": "Protein Flapjack", ... } }
Log a body weight — ideal for smart scales or shortcuts. Weights are always in kg. One weight is kept per day; logging again on the same date replaces it. Subscribed devices get a push notification for every weight logged or changed via the API. Logging a weight also refreshes your maintenance-calorie estimate, and a change there triggers its own notification.
| Field | Required | Notes |
|---|---|---|
weight_kg | yes | 25–400 kg |
date | no | YYYY-MM-DD, defaults to today; cannot be in the future |
note | no | Up to 255 chars |
curl -X POST -H "Authorization: Bearer mlog_..." -H "Content-Type: application/json" \
-d '{"weight_kg":82.4}' \
"https://example.com/food/api/v1.php?action=log_weight"
{ "logged": true, "date": "2026-07-14", "weight_kg": 82.4,
"maintenance": { "status": "ok", "kcal": 2450, "avg_intake": 2280,
"trend_kg_per_wk": -0.15, "confidence": "medium", ... } }
Weigh-ins in a date range (both bounds optional — omit for everything), plus the
current maintenance-calorie estimate. maintenance.status is
ok, insufficient (with a reason) or
unreliable.
{ "weights": [
{ "log_date": "2026-07-13", "weight_kg": "82.60", "note": null, "source": "api" } ],
"maintenance": { "status": "ok", "kcal": 2450, "confidence": "medium", ... } }
Errors return an appropriate HTTP status (400, 401, 404,
405) and a JSON body: { "error": "message" }.