API reference
Weather snapshots
weather.get
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.
from cwa import weather
result = weather.get("臺北市信義區", days=1) 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
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.
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
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
class WeatherCollection Weather snapshots indexed by township.