# Besin Değerleri ve Kalori (SBX-BESIN)

Yaklaşık 7.800 gıdanın kalorisi ve besin değerleri (100 g başına); Türkçe ve İngilizce arama, porsiyon ağırlıkları, öğün ve tarif kalori hesaplama.

Sürüm: v1.0

## Kimlik doğrulama

API anahtarınızı her istekte Bearer token olarak ya da `apikey` sorgu parametresiyle gönderin:

```
Authorization: Bearer <API_ANAHTARINIZ>
https://api.servicebox.io/v1/nutrition/...?apikey=<API_ANAHTARINIZ>
```

Anahtar almak için https://servicebox.io/signup adresinden kaydolun ve panelden bir anahtar oluşturun. Bir ajan `POST https://api.servicebox.io/v1/accounts` ve `{"email": "...", "apis": ["nutrition"]}` ile kendisi kaydolabilir: e-posta sahibi e-postadaki bağlantıyla onaylar, ajan dönen `poll_url` adresini yoklayarak kısa ömürlü bir anahtar alır.

## Temel URL

`https://api.servicebox.io`

## Uç noktalar

### GET /v1/nutrition/calculate

**Calculate a meal or recipe**

The nutrients of a meal or recipe: `items` lists `<food>:<grams>` pairs, comma-separated (up to 30). A food is an id or a name (the best match is used and named in the answer, so check it); grams as `150`, `150g` or `1.5kg`. Answers each item's amounts and `meta.totals`; `meta.partial` lists nutrients some item had no value for (their totals add the known ones). Use when the user asks for the calories or macros of a dish, a recipe or a day's meals.

**Kredi:** çağrı başına 1

**Parametreler**

| Ad | Yer | Tür | Zorunlu | Açıklama |
|---|---|---|---|---|
| `items` | query | string | evet | e.g. `domates:150,beyaz peynir:50,zeytinyağı:10g` or `170457:150`. |

**Örnek**

```bash
curl "https://api.servicebox.io/v1/nutrition/calculate?items=<items>" \
  -H "Authorization: Bearer $SBX_API_KEY"
```

### GET /v1/nutrition/categories

**List food categories**

The 25 food categories (vegetables, fruits, legumes, dairy and eggs, meats, fish…) in English and Turkish with how many foods each has. Free.

**Kredi:** ücretsiz (çağrı başına 0 kredi)

Parametre yok.

**Örnek**

```bash
curl "https://api.servicebox.io/v1/nutrition/categories" \
  -H "Authorization: Bearer $SBX_API_KEY"
```

### GET /v1/nutrition/foods

**Search foods**

About 7,800 foods with calories, protein, fat, carbohydrate, sugars, fibre and salt per 100 g. Search with `q` in Turkish or English (Turkish letters optional: `domates`, `tomato`, `tavuk gogsu`, `beyaz peynir`); the everyday food comes first (raw before prepared). Narrow with `category`. Use when the user asks how many calories or how much protein, fat or carbohydrate a food has, or to find a food's id for /nutrition/foods/{id} or /nutrition/calculate.

**Kredi:** çağrı başına 1

**Parametreler**

| Ad | Yer | Tür | Zorunlu | Açıklama |
|---|---|---|---|---|
| `q` | query | string | hayır | Words to find at the start of words of the Turkish or English names, Turkish letters optional. |
| `category` | query | string | hayır | A category id from /nutrition/categories, e.g. vegetables. |
| `limit` | query | integer | hayır | Items per page, 1–200. |
| `cursor` | query | string | hayır | The `next_cursor` of the previous page, with the same filters. |

**Örnek**

```bash
curl "https://api.servicebox.io/v1/nutrition/foods" \
  -H "Authorization: Bearer $SBX_API_KEY"
```

### GET /v1/nutrition/foods/{id}

**Get a food**

One food: every nutrient per 100 g (energy, macronutrients, fats incl. saturated, trans, cholesterol and omega-3, sugars, fibre, sodium and salt, 9 minerals, 13 vitamins, caffeine) and its household portions with their weight (e.g. 1 medium tomato = 123 g). Use after a search when the user wants vitamins, minerals or a portion's weight.

**Kredi:** çağrı başına 1

**Parametreler**

| Ad | Yer | Tür | Zorunlu | Açıklama |
|---|---|---|---|---|
| `id` | path | integer | evet | A food id from /nutrition/foods, e.g. 170457. |

**Örnek**

```bash
curl "https://api.servicebox.io/v1/nutrition/foods/1" \
  -H "Authorization: Bearer $SBX_API_KEY"
```

### GET /v1/nutrition/nutrients

**List nutrients**

The nutrients served — key, English and Turkish name, unit and group — and which of them lists carry. Free.

**Kredi:** ücretsiz (çağrı başına 0 kredi)

Parametre yok.

**Örnek**

```bash
curl "https://api.servicebox.io/v1/nutrition/nutrients" \
  -H "Authorization: Bearer $SBX_API_KEY"
```

## Hatalar

Hatalar, makinece okunabilir bir `type` taşıyan RFC 9457 `application/problem+json` gövdeleridir.

- `401` — anahtar eksik, bilinmiyor, süresi dolmuş ya da iptal edilmiş.
- `402` — kredi yetersiz: gövde `credits_required` ve `upgrade_url` (https://servicebox.io/pricing) taşır.
- `403` — anahtarın bu API'yi çağırma izni yok.
- `429` — hız sınırı: `retry_after` saniye bekleyin (`Retry-After` başlığıyla da gönderilir); `upgrade_url` daha büyük bir plana yönlendirir.

## Bağlantılar

- OpenAPI belgesi: https://api.servicebox.io/v1/nutrition/openapi.json
- Fiyatlandırma: https://servicebox.io/pricing?api=SBX-BESIN
- API sayfası: https://servicebox.io/apis/nutrition
