Skip to main content

Food & Nutrient Database

Comprehensive laboratory-verified nutritional catalog. Query whole ingredients and packaged foods by exact calorie bounds, minimum/maximum protein, fat and carb macros, micronutrient density, and allergen exclusions.

Pełny adres URL https://www.dietspremium.com/api/v1/food
Format odpowiedzi application/json; charset=utf-8
Autoryzacja Authorization: Bearer <API_KEY>
Specyfikacja Parametrów HTTP

Request Parameters

7 Parameter
Parameter Data Type Requirement Description Example
query string Required Food item or ingredient (e.g. "grilled chicken breast", "avocado") —
locale string Optional Language locale en
kcal_min / kcal_max integer Optional Calorie thresholds per 100g 0
proteins_min integer Optional Minimum protein content in grams 0
allergen_exclude string Optional Comma-separated allergens to exclude —
food_nutrient_include string Optional Include specific micronutrient (e.g. "iron", "calcium") —
ai boolean Optional AI semantic search true
Diagnostyka i Odporność

HTTP Status Codes

Kod HTTP Status Znaczenie i Obsługa
200 OK Sukces Request processed successfully
400 Bad Request Błąd walidacji Invalid request parameters
401 Unauthorized Brak autoryzacji Missing or invalid X-API-KEY
429 Too Many Requests Rate Limit Rate limit or quota exceeded
500 Server Error Błąd serwera Internal server error

Example HTTP Request

POST /api/v1/food
terminal — POST /api/v1/food
REST HTTP/2 REQUEST
curl -X POST 'https://www.dietspremium.com/api/v1/food'
curl -X POST "https://www.dietspremium.com/api/v1/food" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
  "query": "chicken breast",
  "locale": "en",
  "proteins_min": 25,
  "kcal_max": 250,
  "allergen_exclude": "gluten,lactose",
  "ai": true
}'

Example JSON Response (200 OK)

HTTP/2 200 OK • application/json
response — /api/v1/food (200 OK)
JSON Payload 200 OK
{
  "items": [
    {"id": 12, "name": "Chicken Breast Raw", "kcal": 165, "proteins": 31.0, "fats": 3.6, "carbs": 0.0}
  ],
  "total": 1
}
Obsługa paginacji i filtrów dla /api/v1/food Best Practice

Zalecenia produkcyjne dla deweloperów

1
Kontrola strony i rozmiaru kolekcji page / max_results

Sprawdzaj flagę "hasMore" oraz "total" w odpowiedzi JSON przed pobraniem kolejnej strony.

2
Wyszukiwanie semantyczne vs dokładne ai=true

Ustaw ai=true dla zapytań w języku naturalnym lub ai=false dla ścisłego dopasowania słów kluczowych.

ApiClient_food 200 OK

Klient HTTP dla zasobu Food & Nutrient Database

REST API v1 + OpenSearch
Prompt Wejściowy Agenta AI

“Pobierz dane z /api/v1/food dla języka EN z użyciem wektora k-NN.”

Wykorzystywane Narzędzia MCP / Endpointy
POST /api/v1/food
Ślad Wywołania (Execution Trace)
→ POST /api/v1/food (locale=en, ai=true)
← 200 OK (application/json)

Other REST API Endpoints

Pełny katalog REST API →

Share