Quickstart
Get from API key → first results in under 5 minutes.
Base URL
https://api.macrofy.com
Authentication
Include your API key in every request:
x-api-key: YOUR_API_KEY
1) Food search
curl -H "x-api-key: $MACROFY_API_KEY" \
"https://api.macrofy.com/foods/search?q=banana"
Response:
[
{
"id": "food_123",
"name": "Banana",
"serving": { "amount": 118, "unit": "g" },
"macros": { "calories": 105, "protein": 1.3, "carbs": 27, "fat": 0.4 }
}
]
2) Barcode lookup
curl -H "x-api-key: $MACROFY_API_KEY" \
"https://api.macrofy.com/foods/barcode/012000161155"
Response:
{
"id": "food_coke",
"name": "Coca-Cola Classic",
"brand": "Coca-Cola",
"serving": { "amount": 12, "unit": "fl_oz" },
"macros": { "calories": 140, "protein": 0, "carbs": 39, "fat": 0 }
}
3) Image scan (async)
Image scanning uses an async job pipeline:
- Create job → get
jobId+uploadUrl - Upload image → PUT bytes to signed URL
- Poll status → until
status: complete
# 1. Create job
curl -X POST "https://api.macrofy.com/scan/image" \
-H "x-api-key: $MACROFY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"clientId": "my-app", "contentType": "image/jpeg"}'
# 2. Upload to uploadUrl (from response)
curl -X PUT "$UPLOAD_URL" \
-H "Content-Type: image/jpeg" \
--data-binary @photo.jpg
# 3. Poll
curl -H "x-api-key: $MACROFY_API_KEY" \
"https://api.macrofy.com/scan/image/$JOB_ID"
Final response:
{
"status": "complete",
"result": {
"items": [
{
"name": "Chicken bowl",
"macros": { "calories": 540, "protein": 42, "carbs": 55, "fat": 18 }
}
]
}
}
Next steps
- Node.js SDK — Full server-side reference
- React Native SDK — Mobile integration guide
- API Reference — Complete endpoint documentation