Foods Endpoint
Search the food database for nutrition information.
Endpoint
GET
/v1/foodsSearch for foods by name
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
q | string | Yes | Search query (minimum 2 characters) |
limit | integer | No | Maximum results to return (default: 20, max: 100) |
Example Request
curl "https://api.macroestimator.com/v1/foods?q=chicken%20breast&limit=10" \
-H "Authorization: Bearer YOUR_API_KEY"Response
Success responsejson
{
"foods": [
{
"id": "abc123",
"source": "usda",
"name": "Chicken breast, grilled",
"brand": null,
"calories": 165,
"protein": 31,
"carbs": 0,
"fat": 4,
"fiber": 0,
"serving_description": "100g",
"serving_grams": 100
},
{
"id": "def456",
"source": "usda",
"name": "Chicken breast, roasted",
"brand": null,
"calories": 197,
"protein": 30,
"carbs": 0,
"fat": 8,
"fiber": 0,
"serving_description": "100g",
"serving_grams": 100
}
],
"query": "chicken breast"
}Response Fields
| Field | Type | Description |
|---|---|---|
id | string | Unique identifier for the food |
source | string | Data source (e.g., "usda", "branded") |
name | string | Food name |
brand | string | null | Brand name (if applicable) |
calories | number | Calories per serving |
protein | number | Protein in grams per serving |
carbs | number | Carbohydrates in grams per serving |
fat | number | Fat in grams per serving |
fiber | number | Fiber in grams per serving |
serving_description | string | Human-readable serving description |
serving_grams | number | Serving size in grams |
Error Responses
400Bad Request
Search query must be at least 2 characters
{
"error": "Search query must be at least 2 characters",
"foods": []
}