# Nöbetçi Eczane (SBX-ECZ)

81 il ve yaklaşık 960 ilçede 30 binden fazla eczane (nöbetçi ve normal); nöbet durumu ve nöbet saat aralığıyla, konumdan en-yakın-nokta araması dahil, günde 3 defaya kadar güncellenir.

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

**List cities**

All 81 provinces with pharmacy and on-duty counts, sorted by pharmacy count descending. A city's `id` is its name, which is what `city=` accepts. Not paged: the whole list in one answer.

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

Parametre yok.

**Örnek**

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

### GET /v1/pharmacy/districts

**List districts**

Districts (roughly 960 nationwide) with pharmacy and on-duty counts, optionally filtered to one city. A district's `id` is its name; `cityId` is its city's. Not paged: the whole list in one answer.

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

**Parametreler**

| Ad | Yer | Tür | Zorunlu | Açıklama |
|---|---|---|---|---|
| `city` | query | string | hayır | Restrict to districts of this city (case- and accent-insensitive). Omit to list all districts nationwide. |

**Örnek**

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

### GET /v1/pharmacy/pharmacies

**Search pharmacies**

All pharmacies (on-duty and regular) matching the given filters.

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

**Parametreler**

| Ad | Yer | Tür | Zorunlu | Açıklama |
|---|---|---|---|---|
| `city` | query | string | hayır | Filter by city name (case- and accent-insensitive). Up to 120 characters. |
| `district` | query | string | hayır | Filter by district name (case- and accent-insensitive). Up to 120 characters. |
| `name` | query | string | hayır | Turkish-aware substring match on pharmacy name. Up to 120 characters. `q` is an alias for this parameter. |
| `q` | query | string | hayır | Alias for `name`. |
| `duty` | query | boolean | hayır | Filter to on-duty (`true`) or off-duty (`false`) pharmacies. Omit to return both. |
| `activelyOnDuty` | query | boolean | hayır | `true` = duty shift active now (Europe/Istanbul, start inclusive, end exclusive); `false` = not active now. Such answers carry `Cache-Control: no-store`, no `ETag`, and are never answered `304`. `false` does not mean closed. |
| `sort` | query | string (`id`, `name`, `city`) | hayır | Sort order for the result set. |
| `limit` | query | integer | hayır | Maximum number of items on this page. |
| `cursor` | query | string | hayır | Opaque; the `next_cursor` of the previous page. Keep every other parameter unchanged, or the call is a 400. |

**Örnek**

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

### GET /v1/pharmacy/pharmacies/nearby

**Find nearby pharmacies**

Pharmacies within a radius of a coordinate, nearest first and annotated with `distanceKm`. Pages through at most the 500 nearest: at 500 `next_cursor` is null.

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

**Parametreler**

| Ad | Yer | Tür | Zorunlu | Açıklama |
|---|---|---|---|---|
| `lat` | query | number | evet | Latitude of the search center (WGS84). |
| `lon` | query | number | evet | Longitude of the search center (WGS84). |
| `radiusKm` | query | number | hayır | Search radius in kilometers. |
| `city` | query | string | hayır | Filter by city name (case- and accent-insensitive). Up to 120 characters. |
| `district` | query | string | hayır | Filter by district name (case- and accent-insensitive). Up to 120 characters. |
| `name` | query | string | hayır | Turkish-aware substring match on pharmacy name. Up to 120 characters. `q` is an alias for this parameter. |
| `q` | query | string | hayır | Alias for `name`. |
| `duty` | query | boolean | hayır | Filter to on-duty (`true`) or off-duty (`false`) pharmacies. Omit to return both. |
| `activelyOnDuty` | query | boolean | hayır | `true` = duty shift active now (Europe/Istanbul, start inclusive, end exclusive); `false` = not active now. Such answers carry `Cache-Control: no-store`, no `ETag`, and are never answered `304`. `false` does not mean closed. |
| `limit` | query | integer | hayır | Maximum number of items on this page. |
| `cursor` | query | string | hayır | Opaque; the `next_cursor` of the previous page. Keep every other parameter unchanged, or the call is a 400. |

**Örnek**

```bash
curl "https://api.servicebox.io/v1/pharmacy/pharmacies/nearby?lat=0&lon=0" \
  -H "Authorization: Bearer $SBX_API_KEY"
```

### GET /v1/pharmacy/pharmacies/on-duty

**List on-duty pharmacies**

Pharmacies currently on duty, sorted by city. Always returns on-duty pharmacies only — the shared `duty` filter does not apply here.

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

**Parametreler**

| Ad | Yer | Tür | Zorunlu | Açıklama |
|---|---|---|---|---|
| `city` | query | string | hayır | Filter by city name (case- and accent-insensitive). Up to 120 characters. |
| `district` | query | string | hayır | Filter by district name (case- and accent-insensitive). Up to 120 characters. |
| `name` | query | string | hayır | Turkish-aware substring match on pharmacy name. Up to 120 characters. `q` is an alias for this parameter. |
| `q` | query | string | hayır | Alias for `name`. |
| `activelyOnDuty` | query | boolean | hayır | `true` = duty shift active now (Europe/Istanbul, start inclusive, end exclusive); `false` = not active now. Such answers carry `Cache-Control: no-store`, no `ETag`, and are never answered `304`. `false` does not mean closed. |
| `limit` | query | integer | hayır | Maximum number of items on this page. |
| `cursor` | query | string | hayır | Opaque; the `next_cursor` of the previous page. Keep every other parameter unchanged, or the call is a 400. |

**Örnek**

```bash
curl "https://api.servicebox.io/v1/pharmacy/pharmacies/on-duty" \
  -H "Authorization: Bearer $SBX_API_KEY"
```

### GET /v1/pharmacy/pharmacies/{id}

**Get a pharmacy by id**

A single pharmacy by its numeric id.

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

**Parametreler**

| Ad | Yer | Tür | Zorunlu | Açıklama |
|---|---|---|---|---|
| `id` | path | integer | evet | Positive integer pharmacy id. |

**Örnek**

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