# Weather snapshots (https://nolantw.github.io/cwa/en/reference/weather/)

## `weather.get`

```python
def get(location: TownshipInput, *, days: int = 7) -> Weather
def get(location: BatchScope, *, days: int = 7, errors: Literal['raise'] = 'raise') -> WeatherCollection
def get(location: BatchScope, *, days: int = 7, errors: Literal['collect']) -> BatchResult[Township, Weather]
```

Get the township forecast, current observation, and active warnings.

**Parameters**

- `location` — Township name or object, county, or sequence of locations.
- `days` — Number of Taiwan calendar dates, from 1 to 7.
- `errors` — Pass collect for a batch to keep its successes and failures.

**Returns**

One snapshot or a collection. With errors=collect, returns a BatchResult.

**Raises**

- `ValueError` — The number of days is outside the supported range.
- `BatchError` — At least one batch item failed and errors is raise.

```python
from cwa import weather

result = weather.get("臺北市信義區", days=1)
```

```python
client.weather.get(location: TownshipInput, *, days: int = 7) -> Weather
client.weather.get(location: BatchScope, *, days: int = 7, errors: Literal['raise'] = 'raise') -> WeatherCollection
client.weather.get(location: BatchScope, *, days: int = 7, errors: Literal['collect']) -> BatchResult[Township, Weather]
await async_client.weather.get(location: TownshipInput, *, days: int = 7) -> Weather
await async_client.weather.get(location: BatchScope, *, days: int = 7, errors: Literal['raise'] = 'raise') -> WeatherCollection
await async_client.weather.get(location: BatchScope, *, days: int = 7, errors: Literal['collect']) -> BatchResult[Township, Weather]
```

## `weather.get_all`

```python
def get_all(*, days: int = 7, errors: Literal['raise'] = 'raise') -> WeatherCollection
def get_all(*, days: int = 7, errors: Literal['collect']) -> BatchResult[Township, Weather]
```

Get weather snapshots for all catalog townships.

```python
client.weather.get_all(*, days: int = 7, errors: Literal['raise'] = 'raise') -> WeatherCollection
client.weather.get_all(*, days: int = 7, errors: Literal['collect']) -> BatchResult[Township, Weather]
await async_client.weather.get_all(*, days: int = 7, errors: Literal['raise'] = 'raise') -> WeatherCollection
await async_client.weather.get_all(*, days: int = 7, errors: Literal['collect']) -> BatchResult[Township, Weather]
```

## `Weather`

```python
location: Township
as_of: datetime
current: LocatedObservation | None
forecast: Forecast
alerts: AlertSet
today: DayForecast | None
tomorrow: DayForecast | None
```

Forecast, nearest eligible station observation, and active warnings.

## `WeatherCollection`

```python
class WeatherCollection
```

Weather snapshots indexed by township.