Metadata-Version: 2.4
Name: cwa
Version: 0.3.1
Summary: Unofficial Python SDK for Taiwan's Central Weather Administration Open Data API, providing weather forecasts, station observations, weather alerts, earthquakes, typhoons, and geospatial queries.
Keywords: cwa,taiwan,central-weather-administration,open-data,weather,weather-api,weather-forecast,weather-observation,weather-station,weather-alerts,meteorology,temperature,precipitation,rainfall,earthquake,seismology,seismic-intensity,typhoon,tropical-cyclone,disaster-prevention,geospatial,gis,data-analysis,polars,pandas,apache-arrow,中央氣象署,臺灣,氣象,天氣預報,氣象觀測,地震,颱風,災害防救,開放資料
Author: Nolan
Author-email: Nolan <300344883+nolantw@users.noreply.github.com>
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: Science/Research
Classifier: Natural Language :: Chinese (Traditional)
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Atmospheric Science
Classifier: Topic :: Scientific/Engineering :: GIS
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Classifier: Topic :: Scientific/Engineering :: Physics
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Dist: anyio>=4.16.0
Requires-Dist: anysqlite>=0.0.5
Requires-Dist: geographiclib>=2.1
Requires-Dist: hishel[httpx2]>=2.0.0
Requires-Dist: httpx2>=2.16.2
Requires-Dist: lxml>=6.1.3
Requires-Dist: pydantic>=2.14.4
Requires-Dist: pydantic-xml>=2.22.0
Requires-Dist: tenacity>=9.2.1
Requires-Dist: tzdata>=2026.6
Requires-Dist: cwa[arrow,fast,geo,pandas,polars] ; extra == 'all'
Requires-Dist: narwhals>=2.29.0 ; extra == 'arrow'
Requires-Dist: pyarrow>=26.0.1 ; extra == 'arrow'
Requires-Dist: pyproj>=3.8.0 ; extra == 'fast'
Requires-Dist: shapely>=2.2.0 ; extra == 'geo'
Requires-Dist: narwhals>=2.29.0 ; extra == 'pandas'
Requires-Dist: pandas>=3.1.1 ; extra == 'pandas'
Requires-Dist: pyarrow>=26.0.1 ; extra == 'pandas'
Requires-Dist: narwhals>=2.29.0 ; extra == 'polars'
Requires-Dist: polars>=2.2.0 ; extra == 'polars'
Requires-Python: >=3.13
Project-URL: Homepage, https://nolantw.github.io/cwa/
Project-URL: Documentation, https://nolantw.github.io/cwa/
Project-URL: Repository, https://github.com/nolantw/cwa
Project-URL: Issues, https://github.com/nolantw/cwa/issues
Project-URL: Changelog, https://github.com/nolantw/cwa/blob/main/CHANGELOG.md
Project-URL: Release Notes, https://github.com/nolantw/cwa/releases
Project-URL: Contributing, https://github.com/nolantw/cwa/blob/main/CONTRIBUTING.md
Project-URL: CWA Open Data, https://opendata.cwa.gov.tw/
Provides-Extra: all
Provides-Extra: arrow
Provides-Extra: fast
Provides-Extra: geo
Provides-Extra: pandas
Provides-Extra: polars
Description-Content-Type: text/markdown

<h1 align="center">cwa</h1>

<p align="center">中央氣象署開放資料 API 的 Python SDK。</p>

<p align="center">
<a href="https://github.com/nolantw/cwa/actions/workflows/ci.yml"><img src="https://github.com/nolantw/cwa/actions/workflows/ci.yml/badge.svg?branch=main" alt="CI"></a>
<a href="https://pypi.org/project/cwa/"><img src="https://img.shields.io/pypi/v/cwa.svg" alt="套件版本"></a>
<a href="https://pypi.org/project/cwa/"><img src="https://img.shields.io/pypi/pyversions/cwa.svg" alt="Python 版本"></a>
</p>

<p align="center"><strong>繁體中文</strong> | <a href="https://github.com/nolantw/cwa/blob/main/README.en.md">English</a></p>

輸入地名，就能取得鄉鎮預報、鄰近測站的即時觀測值及生效中的警特報。cwa 負責呼叫氣象署 API、驗證回應，並把資料整理成有型別的 Python 物件，不需要自己解析 JSON 或 XML。

## 安裝

需要 Python 3.13 以上版本。

```shell
pip install cwa
```

使用 uv 則執行 `uv add cwa`。匯出表格、座標比對等選用功能需要額外套件，見[選用功能](https://nolantw.github.io/cwa/#選用功能)。

## 設定授權碼

至中央氣象署開放資料平臺[申請授權碼](https://opendata.cwa.gov.tw/user/authkey)，並設為環境變數 `CWA_API_KEY`：

```shell
# macOS、Linux
export CWA_API_KEY="授權碼"
```

```powershell
# Windows PowerShell
$env:CWA_API_KEY = "授權碼"
```

## 範例

```python
import cwa

w = cwa.weather.get("臺北市信義區")

if w.current:  # 附近沒有符合條件的測站時為 None
    print(w.current.station.name, w.current.temperature)  # 信義 22.5
if w.tomorrow:
    print(w.tomorrow.precipitation.max_probability)  # 20
for alert in w.alerts:
    print(alert.title)
```

## 功能

| 功能 | 說明 |
| --- | --- |
| [綜合天氣](https://nolantw.github.io/cwa/guides/weather) | 一次取得預報、目前天氣及警特報 |
| [預報](https://nolantw.github.io/cwa/guides/forecast) | 一至七日鄉鎮預報，可依日期或時刻查詢 |
| [觀測值及測站](https://nolantw.github.io/cwa/guides/observations) | 鄰近測站的即時觀測值、測站清單 |
| [警特報](https://nolantw.github.io/cwa/guides/alerts) | 依縣市、鄉鎮或座標篩選生效中的警特報 |
| [地震](https://nolantw.github.io/cwa/guides/earthquakes) | 有感地震報告、各地震度、震央距離 |
| [颱風](https://nolantw.github.io/cwa/guides/typhoons) | 颱風位置及預測路徑 |
| [海嘯](https://nolantw.github.io/cwa/guides/tsunamis) | 海嘯報告、警報與解除通報 |
| [海象](https://nolantw.github.io/cwa/guides/marine) | 一個月潮汐預報、浮標與潮位站觀測 |
| [天文](https://nolantw.github.io/cwa/guides/astronomy) | 日出日沒、月出月沒 |
| [健康氣象](https://nolantw.github.io/cwa/guides/health) | 熱傷害、冷傷害與溫差提醒指數 |
| [氣候](https://nolantw.github.io/cwa/guides/climate) | 每日氣候、雨量紀錄、氣候平均值、測站沿革、臭氧 |
| [批次查詢與匯出](https://nolantw.github.io/cwa/advanced/batch) | 一次查詢多個地點，匯出為 Polars、Pandas 或 Arrow 表格 |
| [用戶端與快取](https://nolantw.github.io/cwa/advanced/clients) | 重複使用連線、非同步查詢、記憶體快取 |
| [原始資料集](https://nolantw.github.io/cwa/advanced/datasets) | 以資料集編號讀取 SDK 尚未包裝的資料 |

完整說明見[文件網站](https://nolantw.github.io/cwa/)。

## 貢獻

請見[貢獻指南](https://github.com/nolantw/cwa/blob/main/CONTRIBUTING.md)及[變更紀錄](https://github.com/nolantw/cwa/blob/main/CHANGELOG.md)。問題回報請至 [GitHub Issues](https://github.com/nolantw/cwa/issues)。

氣象資料來自[中央氣象署開放資料平臺](https://opendata.cwa.gov.tw/)。cwa 為非官方套件，與中央氣象署無關。

---

<p align="center"><i>cwa 以 <a href="https://github.com/nolantw/cwa/blob/main/LICENSE">MIT 授權</a>釋出。</i></p>
