# Current & forecast (SBX-WTHR)

Current conditions, a 48-hour hourly and a 9-day daily forecast for any city or coordinate, with conditions in Turkish.

Version: v1.0

## Authentication

Send your API key on every request, either as a Bearer token or as the `apikey` query parameter:

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

Get a key: sign up at https://servicebox.io/en/signup and create one on the dashboard. An agent can sign up itself with `POST https://api.servicebox.io/v1/accounts` and `{"email": "...", "apis": ["weather"]}`: the owner of the mailbox approves by email and the agent collects a short-lived key by polling the returned `poll_url`.

## Base URL

`https://api.servicebox.io`

## Endpoints

### GET /v1/weather/conditions

**List conditions**

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

**Credits:** free (0 credits per call)

No parameters.

**Example**

```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.

**Credits:** 1 per call

**Parameters**

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `cityId` | query | string | no | A city id from the Cities API, e.g. 745044 (İstanbul). |
| `lat` | query | number | no | Latitude (WGS84), with `lon`. |
| `lon` | query | number | no | Longitude (WGS84), with `lat`. |
| `timezone` | query | string | no | IANA timezone for local times. Default: the city's, or the nearest city's for a point. |

**Example**

```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.

**Credits:** 1 per call

**Parameters**

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `cityId` | query | string | no | A city id from the Cities API, e.g. 745044 (İstanbul). |
| `lat` | query | number | no | Latitude (WGS84), with `lon`. |
| `lon` | query | number | no | Longitude (WGS84), with `lat`. |
| `timezone` | query | string | no | IANA timezone for local times. Default: the city's, or the nearest city's for a point. |
| `days` | query | integer | no | Days, 1–9. |

**Example**

```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.

**Credits:** 1 per call

**Parameters**

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `cityId` | query | string | no | A city id from the Cities API, e.g. 745044 (İstanbul). |
| `lat` | query | number | no | Latitude (WGS84), with `lon`. |
| `lon` | query | number | no | Longitude (WGS84), with `lat`. |
| `timezone` | query | string | no | IANA timezone for local times. Default: the city's, or the nearest city's for a point. |
| `hours` | query | integer | no | Hours ahead, 1–48. |

**Example**

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

## Errors

Errors are RFC 9457 `application/problem+json` bodies with a machine-readable `type`.

- `401` — the key is missing, unknown, expired or revoked.
- `402` — not enough credits: the body carries `credits_required` and `upgrade_url` (https://servicebox.io/en/pricing).
- `403` — the key is not allowed to call this API.
- `429` — rate limited: wait `retry_after` seconds (also sent as the `Retry-After` header); `upgrade_url` points to a larger plan.

## Links

- OpenAPI document: https://api.servicebox.io/v1/weather/openapi.json
- Pricing: https://servicebox.io/en/pricing?api=SBX-WTHR
- API page: https://servicebox.io/en/apis/weather
