# Altın ve emtia (SBX-GOLD)

Gram, çeyrek, Cumhuriyet ve ons altının günlük has değeri (TL, USD, EUR; 2013'ten beri); Brent, WTI, doğal gaz ve akaryakıtın günlük spot fiyatları; 67 emtianın aylık fiyatları.

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/gold/...?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": ["gold"]}` 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/gold/commodities

**List commodities**

Every commodity series: daily energy spot prices (EIA) and monthly prices of metals, energy, agriculture, fertilizers and raw materials (World Bank), with the span held. Free.

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

**Parametreler**

| Ad | Yer | Tür | Zorunlu | Açıklama |
|---|---|---|---|---|
| `category` | query | string (`energy`, `precious-metals`, `base-metals`, `agriculture`, `fertilizers`, `raw-materials`) | hayır | Only this category. |

**Örnek**

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

### GET /v1/gold/commodity-prices

**Latest commodity prices**

Each series' latest price and the one before it, with the change. EIA's daily prices are released weekly (Wednesdays), the World Bank's monthly averages in the first days of each month.

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

**Parametreler**

| Ad | Yer | Tür | Zorunlu | Açıklama |
|---|---|---|---|---|
| `codes` | query | string | hayır | Comma-separated codes from /gold/commodities, e.g. brent,wti,gold. Default: every series. |
| `category` | query | string (`energy`, `precious-metals`, `base-metals`, `agriculture`, `fertilizers`, `raw-materials`) | hayır | Only this category. |

**Örnek**

```bash
curl "https://api.servicebox.io/v1/gold/commodity-prices" \
  -H "Authorization: Bearer $SBX_API_KEY"
```

### GET /v1/gold/commodity-prices/{code}

**One commodity over time**

One series between `start` and `end`. Daily series: at most 366 days (default: the last 30). Monthly series: YYYY-MM or YYYY-MM-DD, at most 600 months (default: the last 24).

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

**Parametreler**

| Ad | Yer | Tür | Zorunlu | Açıklama |
|---|---|---|---|---|
| `code` | path | string | evet | A code from /gold/commodities, e.g. brent. |
| `start` | query | string | hayır | YYYY-MM-DD (monthly series: also YYYY-MM). |
| `end` | query | string | hayır | YYYY-MM-DD (monthly series: also YYYY-MM). Default: today. |

**Örnek**

```bash
curl "https://api.servicebox.io/v1/gold/commodity-prices/<code>" \
  -H "Authorization: Bearer $SBX_API_KEY"
```

### GET /v1/gold/prices

**Gold prices on a date**

The intrinsic value of gram gold (24, 22, 18 and 14 karat), the troy ounce and the Turkish coins (çeyrek, yarım, tam, ikibuçuk, beşli, Cumhuriyet, Ata beşli) on `date` (default: the latest price), from the price of 1 g of fine gold calculated by Narodowy Bank Polski each Polish business day. USD and EUR use NBP's mid rates of that day; TRY goes through USD at TCMB's forex midpoint of the latest bulletin on or before that day (`meta.rates`). These are melt values, without workmanship or a dealer's spread.

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

**Parametreler**

| Ad | Yer | Tür | Zorunlu | Açıklama |
|---|---|---|---|---|
| `currency` | query | string (`TRY`, `USD`, `EUR`) | hayır | `TRY` (default), `USD` or `EUR`. |
| `date` | query | string | hayır | YYYY-MM-DD, since 2013-01-02. A day without a price answers the latest one before it (`meta.date`). |

**Örnek**

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

### GET /v1/gold/prices/{product}

**One product over time**

One product's intrinsic value on every NBP business day between `start` and `end` (default: the last 30 days; at most 366 days), since 2013-01-02.

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

**Parametreler**

| Ad | Yer | Tür | Zorunlu | Açıklama |
|---|---|---|---|---|
| `product` | path | string | evet | A product id from /gold/products, e.g. gram-24k or ceyrek. |
| `currency` | query | string (`TRY`, `USD`, `EUR`) | hayır | `TRY` (default), `USD` or `EUR`. |
| `start` | query | string | hayır | YYYY-MM-DD. |
| `end` | query | string | hayır | YYYY-MM-DD. Default: today. |

**Örnek**

```bash
curl "https://api.servicebox.io/v1/gold/prices/<product>" \
  -H "Authorization: Bearer $SBX_API_KEY"
```

### GET /v1/gold/products

**List gold products**

Gram gold by karat, the troy ounce and the Turkish coins, with their weight and fine-gold content. Free.

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

Parametre yok.

**Örnek**

```bash
curl "https://api.servicebox.io/v1/gold/products" \
  -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/gold/openapi.json
- Fiyatlandırma: https://servicebox.io/pricing?api=SBX-GOLD
- API sayfası: https://servicebox.io/apis/gold
