# Anlık ve tahmin (SBX-WTHR)

Her şehir ya da koordinat için anlık durum, 48 saatlik saatlik ve 9 günlük günlük tahmin; durumlar Türkçe.

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/...?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"]}` 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/conditions

**List conditions**

Every condition code the forecasts use, with English and Turkish names. Free.

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

Parametre yok.

**Örnek**

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

### GET /v1/weather/current

**Current weather**

The conditions now at a city or point: temperature, feels-like, humidity, dew point, pressure, clouds, wind and gusts, UV index, the next hour's precipitation and the condition (English and Turkish). From MET Norway's forecast model for this hour.

**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/current" \
  -H "Authorization: Bearer $SBX_API_KEY"
```

### GET /v1/weather/forecasts/daily

**Daily forecast**

Day by day for up to 9 local calendar days from today (default 7): high, low, precipitation, strongest wind and the day's condition. Today covers only the hours still ahead.

**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. |
| `days` | query | integer | hayır | Days, 1–9. |

**Örnek**

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

### GET /v1/weather/forecasts/hourly

**Hourly forecast**

Hour by hour for the next `hours` (1–48, default 24; MET gives hourly steps for about the next 2.5 days), with local times.

**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. |
| `hours` | query | integer | hayır | Hours ahead, 1–48. |

**Örnek**

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