Unofficial JMA weather forecast API wrapper in Python
Project description
aoirint_jmapy
Unofficial JMA weather forecast API wrapper in Python
気象庁天気予報データの非公式Pythonラッパー
2022-05-27時点のAPIに対応
- 気象庁の天気予報ページ: https://www.jma.go.jp/bosai/forecast/
Install
pip3 install aoirint_jmapy
Usage
東京都 東京地方のデータを見る例
from aoirint_jmapy import JmaApi
# UserAgentに含めるため、あなたのアプリケーション名、バージョンを設定することを推奨
# UserAgentは次のようになります: MyWeatherApp 0.1.0 / aoirint_jmapy 20220527.4
# アプリケーションを一般に配布する場合、不具合等により不特定多数の端末から
# 気象庁のサーバに負荷をかけることがないように、自分でキャッシュサーバを立てること等を推奨
jmaApi = JmaApi(
jma_url='https://www.jma.go.jp',
app_name='MyWeatherApp',
app_version='0.1.0',
)
# 東京都
forecast = jmaApi.forecast(area_id='130000')
print(forecast)
## 東京地方
print(forecast[0])
### 3日間予報
print(forecast[0].timeSeries[0])
### 週間予報
print(forecast[0].timeSeries[1])
### 3日間天気概況
overview_forecast = jmaApi.overview_forecast(area_id='130000')
print(overview_forecast.text)
### 週間天気概況
overview_week = jmaApi.overview_week(area_id='130000')
print(overview_week.text)
area_idを調べる
- ※ 単一の地点のみでいい場合、気象庁の天気予報ページから手動で選択して実際のリクエストURLから抽出する方が簡単
# エリアリスト
area = jmaApi.area()
## センターリスト(気象台リスト)
print(area.centers)
### 北海道地方: center_id=010100
#### 宗谷地方: area_id=011000
#### 上川・留萌地方: area_id=012000
print(area.centers['010100'])
### 関東甲信地方: center_id=010300
#### 東京都: area_id=130000
#### 神奈川県: area_id=140000
print(area.centers['010300'])
Development
Environment
python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txt
Lock dependencies
pip3 install pip-tools
pip-compile requirements.in
pip-compile requirements.test.in
Test
# Download some JMA API response for test
./get_testdata.sh
pip3 install -r requirements.test.txt
mypy aoirint_jmapy/
pytest tests/
Release
GitHub Releaseを作成するとGitHub Actionsにより自動でPyPIにリリースされる。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for aoirint_jmapy-20220527.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82ab8f00718626a58ffe9af3cb9191301bfc6859e33b876902ee26c8d4d479a9 |
|
MD5 | b14fcfe9550b25874ef64f1a0d3a5045 |
|
BLAKE2b-256 | dca658c402c346df9dcf43d816ef6a53d8751cea0b9a0e4c171c39a0fd14d97c |