# Geçmiş hava durumu (SBX-WHIST)

1981'den günlük, 2001'den saatlik geçmiş hava; aylık iklim normalleri ve ısıtma/soğutma derece-günleri.

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/weather-history/...?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": ["weather-history"]}` 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/weather-history/days

**Daily history**

Daily mean, high and low temperature, precipitation, humidity and wind for `start`–`end` (inclusive, at most 366 days), from 1981-01-01 to a few days ago. Recent days NASA POWER has not filled yet are null.

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

**Parametreler**

| Ad | Yer | Tür | Zorunlu | Açıklama |
|---|---|---|---|---|
| `cityId` | query | string | hayır | A city id from the Cities API, e.g. 745044 (İstanbul). |
| `lat` | query | number | hayır | Latitude (WGS84), with `lon`. |
| `lon` | query | number | hayır | Longitude (WGS84), with `lat`. |
| `timezone` | query | string | hayır | IANA timezone for local times. Default: the city's, or the nearest city's for a point. |
| `start` | query | string | evet | First day, YYYY-MM-DD. |
| `end` | query | string | evet | Last day, YYYY-MM-DD. |

**Örnek**

```bash
curl "https://api.servicebox.io/v1/weather-history/days?start=<start>&end=<end>" \
  -H "Authorization: Bearer $SBX_API_KEY"
```

### GET /v1/weather-history/degree-days

**Heating and cooling degree days**

Heating degree days (below `heatingBase`, default 18 °C) and cooling degree days (above `coolingBase`, default 22 °C) from the daily mean temperature over `start`–`end` (at most 366 days), in total (`meta`) and per month.

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

**Parametreler**

| Ad | Yer | Tür | Zorunlu | Açıklama |
|---|---|---|---|---|
| `cityId` | query | string | hayır | A city id from the Cities API, e.g. 745044 (İstanbul). |
| `lat` | query | number | hayır | Latitude (WGS84), with `lon`. |
| `lon` | query | number | hayır | Longitude (WGS84), with `lat`. |
| `timezone` | query | string | hayır | IANA timezone for local times. Default: the city's, or the nearest city's for a point. |
| `start` | query | string | evet | First day, YYYY-MM-DD. |
| `end` | query | string | evet | Last day, YYYY-MM-DD. |
| `heatingBase` | query | number | hayır | °C, -10 to 40. |
| `coolingBase` | query | number | hayır | °C, -10 to 40. |

**Örnek**

```bash
curl "https://api.servicebox.io/v1/weather-history/degree-days?start=<start>&end=<end>" \
  -H "Authorization: Bearer $SBX_API_KEY"
```

### GET /v1/weather-history/hours

**Hourly history**

Hourly temperature, precipitation, humidity and wind for `start`–`end` (at most 7 days), from 2001-01-01, in local time.

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

**Parametreler**

| Ad | Yer | Tür | Zorunlu | Açıklama |
|---|---|---|---|---|
| `cityId` | query | string | hayır | A city id from the Cities API, e.g. 745044 (İstanbul). |
| `lat` | query | number | hayır | Latitude (WGS84), with `lon`. |
| `lon` | query | number | hayır | Longitude (WGS84), with `lat`. |
| `timezone` | query | string | hayır | IANA timezone for local times. Default: the city's, or the nearest city's for a point. |
| `start` | query | string | evet | First day, YYYY-MM-DD. |
| `end` | query | string | evet | Last day, YYYY-MM-DD. |

**Örnek**

```bash
curl "https://api.servicebox.io/v1/weather-history/hours?start=<start>&end=<end>" \
  -H "Authorization: Bearer $SBX_API_KEY"
```

### GET /v1/weather-history/normals

**Monthly normals**

The climate normals for each month over NASA POWER's 20-year climatology (2001–2020): mean temperature, the highest and lowest hourly temperature seen in that month, monthly precipitation, humidity and wind.

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

**Parametreler**

| Ad | Yer | Tür | Zorunlu | Açıklama |
|---|---|---|---|---|
| `cityId` | query | string | hayır | A city id from the Cities API, e.g. 745044 (İstanbul). |
| `lat` | query | number | hayır | Latitude (WGS84), with `lon`. |
| `lon` | query | number | hayır | Longitude (WGS84), with `lat`. |
| `timezone` | query | string | hayır | IANA timezone for local times. Default: the city's, or the nearest city's for a point. |

**Örnek**

```bash
curl "https://api.servicebox.io/v1/weather-history/normals" \
  -H "Authorization: Bearer $SBX_API_KEY"
```

### GET /v1/weather-history/parameters

**List parameters**

The variables the history answers carry, their units, and the dates the data covers. Free.

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

Parametre yok.

**Örnek**

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