はじめに
以前から気象予報値をAPIで取得するサービスが欲しいな〜と思っていたけど、なかなか思い通りのサービスが見つからなかったので、作っちゃいました。
また、気象予報値を利用して予測した電力需要の予測値も取得できるようにしてみました。
ついでに、需要予測に必要な休日情報もAPIで取得できるようにしてみました。
とりあえず自社のために作ったものなのでかなり荒削りですが、他にも使いたい人がいるに違いないと思い、当面の間無料で使えるようにしてみようと思います。
今のところ利用制限はありませんが、自社の利用に支障をきたすようなことになれば何か検討をしようと考えています。
取得できるデータ
気象予報値
項目 | 内容 |
---|---|
期間 | 当日、翌日、翌々日 |
データ種類 | 気温、気圧、湿度、雲、日射量、風速、風向き |
電力需要予測値
項目 | 内容 |
---|---|
期間 | 翌々日 |
データ種類 | 電力量(万kW) |
祝祭日情報
項目 | 内容 |
---|---|
期間 | 前年、当年、翌年 |
データ種類 | 日付、名称 |
利用手順
利用手順は以下のとおりです。
- サイトにアクセス
- ユーザー登録
- トークンの発行
- WebAPIによるデータ取得
サイトにアクセス
以下のURLにアクセスします。
センシングプラザ ネクスト
次に、右上にある「SIGNUP」をクリックしてユーザー登録画面に進みます。
ユーザー登録
メールアドレスとパスワードを送信し、送られてきたメールのリンクをクリックして認証をします。
登録したメールアドレスとパスワードでログインします。
トークンの発行
それぞれのAPIについての説明ページにてトークンを発行できるので、利用するAPI用のトークンを発行します。
WebAPIによるデータ取得
説明のとおり気象予報値を取得してみます。
トークンの「*****」はそれぞれ取得したトークンに書き換えてご利用下さい。
curl -X GET \
-H 'Authorization: Token *****' \
-G -d point=Matsue \
https://iot.blueomega.jp/spnext/api/v1/weather/forecast
これを実行すると...
[{"forecast_time":"2020-12-07 00:00:00","temperature":8.1,"pressure":1007.98,"humidity":86.0,"clouds":19.4,"insolation":0.0,"wind_speed":2.46,"wind_direction":225.0},{"forecast_time":"2020-12-07 01:00:00","temperature":8.09,"pressure":1007.83,"humidity":86.0,"clouds":26.5,"insolation":0.0,"wind_speed":2.43,"wind_direction":225.0},{"forecast_time":"2020-12-07 02:00:00","temperature":8.15,"pressure":1007.86,"humidity":85.8,"clouds":35.1,"insolation":0.0,"wind_speed":2.45,"wind_direction":225.0},{"forecast_time":"2020-12-07 03:00:00","temperature":8.23,"pressure":1007.76,"humidity":85.7,"clouds":33.1,"insolation":0.0,"wind_speed":2.47,"wind_direction":225.0},{"forecast_time":"2020-12-07 04:00:00","temperature":8.29,"pressure":1007.64,"humidity":85.8,"clouds":31.7,"insolation":0.0,"wind_speed":2.48,"wind_direction":225.0},{"forecast_time":"2020-12-07 05:00:00","temperature":8.25,"pressure":1007.52,"humidity":85.9,"clouds":33.2,"insolation":0.0,"wind_speed":2.42,"wind_direction":225.0},{"forecast_time":"2020-12-07 06:00:00","temperature":8.14,"pressure":1007.83,"humidity":86.1,"clouds":32.9,"insolation":0.0,"wind_speed":2.31,"wind_direction":225.0},{"forecast_time":"2020-12-07 07:00:00","temperature":7.95,"pressure":1008.11,"humidity":86.8,"clouds":36.3,"insolation":0.0,"wind_speed":2.24,"wind_direction":225.0},{"forecast_time":"2020-12-07 08:00:00","temperature":8.36,"pressure":1008.19,"humidity":85.7,"clouds":36.6,"insolation":30.2,"wind_speed":2.2,"wind_direction":202.5},{"forecast_time":"2020-12-07 09:00:00","temperature":10.51,"pressure":1008.29,"humidity":75.5,"clouds":31.9,"insolation":155.7,"wind_speed":2.13,"wind_direction":225.0},{"forecast_time":"2020-12-07 10:00:00","temperature":11.81,"pressure":1008.24,"humidity":68.8,"clouds":28.5,"insolation":293.6,"wind_speed":2.54,"wind_direction":247.5},{"forecast_time":"2020-12-07 11:00:00","temperature":12.43,"pressure":1007.71,"humidity":65.5,"clouds":30.3,"insolation":401.1,"wind_speed":3.03,"wind_direction":270.0},{"forecast_time":"2020-12-07 12:00:00","temperature":12.69,"pressure":1006.8,"humidity":63.5,"clouds":40.9,"insolation":446.3,"wind_speed":3.57,"wind_direction":270.0},{"forecast_time":"2020-12-07 13:00:00","temperature":12.66,"pressure":1006.02,"humidity":62.5,"clouds":45.2,"insolation":407.7,"wind_speed":3.85,"wind_direction":270.0},{"forecast_time":"2020-12-07 14:00:00","temperature":12.48,"pressure":1005.71,"humidity":62.2,"clouds":52.8,"insolation":328.5,"wind_speed":3.89,"wind_direction":270.0},{"forecast_time":"2020-12-07 15:00:00","temperature":12.26,"pressure":1005.67,"humidity":62.4,"clouds":51.3,"insolation":253.1,"wind_speed":3.97,"wind_direction":270.0},{"forecast_time":"2020-12-07 16:00:00","temperature":11.84,"pressure":1005.88,"humidity":63.6,"clouds":50.3,"insolation":139.2,"wind_speed":3.98,"wind_direction":270.0},{"forecast_time":"2020-12-07 17:00:00","temperature":11.28,"pressure":1006.05,"humidity":65.6,"clouds":35.5,"insolation":26.7,"wind_speed":3.64,"wind_direction":270.0},{"forecast_time":"2020-12-07 18:00:00","temperature":10.84,"pressure":1006.42,"humidity":68.2,"clouds":38.6,"insolation":0.0,"wind_speed":3.47,"wind_direction":270.0},{"forecast_time":"2020-12-07 19:00:00","temperature":10.56,"pressure":1006.75,"humidity":70.1,"clouds":48.4,"insolation":0.0,"wind_speed":3.51,"wind_direction":270.0},{"forecast_time":"2020-12-07 20:00:00","temperature":10.56,"pressure":1007.06,"humidity":70.5,"clouds":59.4,"insolation":0.0,"wind_speed":3.64,"wind_direction":270.0},{"forecast_time":"2020-12-07 21:00:00","temperature":10.58,"pressure":1007.01,"humidity":70.9,"clouds":70.0,"insolation":0.0,"wind_speed":3.76,"wind_direction":270.0},{"forecast_time":"2020-12-07 22:00:00","temperature":10.61,"pressure":1006.76,"humidity":71.3,"clouds":84.2,"insolation":0.0,"wind_speed":3.78,"wind_direction":270.0},{"forecast_time":"2020-12-07 23:00:00","temperature":10.69,"pressure":1006.45,"humidity":71.9,"clouds":82.3,"insolation":0.0,"wind_speed":3.68,"wind_direction":270.0}]
JSON形式で1時間毎の気象予報値が取得できます。
基本は翌々日の予報値ですが、今日と明日のデータが必要であれば、日付を指定することで取得が可能です.
curl -X GET \
-H 'Authorization: Token *****' \
-G -d point=Matsue \
-G -d date=20201206 \
https://iot.blueomega.jp/spnext/api/v1/weather/forecast
上記を実行すると...
[{"forecast_time":"2020-12-06 00:00:00","temperature":7.22,"pressure":1008.64,"humidity":84.9,"clouds":50.5,"insolation":0.0,"wind_speed":1.44,"wind_direction":202.5},{"forecast_time":"2020-12-06 01:00:00","temperature":7.14,"pressure":1008.44,"humidity":84.4,"clouds":44.0,"insolation":0.0,"wind_speed":1.63,"wind_direction":202.5},{"forecast_time":"2020-12-06 02:00:00","temperature":7.12,"pressure":1008.26,"humidity":84.9,"clouds":37.6,"insolation":0.0,"wind_speed":1.78,"wind_direction":202.5},{"forecast_time":"2020-12-06 03:00:00","temperature":6.98,"pressure":1008.07,"humidity":84.7,"clouds":26.4,"insolation":0.0,"wind_speed":1.97,"wind_direction":202.5},{"forecast_time":"2020-12-06 04:00:00","temperature":6.82,"pressure":1007.73,"humidity":85.9,"clouds":22.3,"insolation":0.0,"wind_speed":2.14,"wind_direction":202.5},{"forecast_time":"2020-12-06 05:00:00","temperature":6.6,"pressure":1007.61,"humidity":86.2,"clouds":25.2,"insolation":0.0,"wind_speed":2.35,"wind_direction":202.5},{"forecast_time":"2020-12-06 06:00:00","temperature":6.42,"pressure":1007.83,"humidity":86.9,"clouds":32.2,"insolation":0.0,"wind_speed":2.51,"wind_direction":202.5},{"forecast_time":"2020-12-06 07:00:00","temperature":6.35,"pressure":1008.02,"humidity":86.7,"clouds":35.4,"insolation":0.0,"wind_speed":2.67,"wind_direction":202.5},{"forecast_time":"2020-12-06 08:00:00","temperature":7.05,"pressure":1008.29,"humidity":83.2,"clouds":40.9,"insolation":30.2,"wind_speed":2.6,"wind_direction":202.5},{"forecast_time":"2020-12-06 09:00:00","temperature":9.52,"pressure":1008.58,"humidity":70.4,"clouds":48.0,"insolation":147.3,"wind_speed":2.47,"wind_direction":225.0},{"forecast_time":"2020-12-06 10:00:00","temperature":10.65,"pressure":1008.6,"humidity":66.8,"clouds":54.2,"insolation":248.8,"wind_speed":2.8,"wind_direction":247.5},{"forecast_time":"2020-12-06 11:00:00","temperature":11.17,"pressure":1008.2,"humidity":66.5,"clouds":50.6,"insolation":325.0,"wind_speed":3.17,"wind_direction":270.0},{"forecast_time":"2020-12-06 12:00:00","temperature":11.55,"pressure":1007.44,"humidity":65.6,"clouds":38.9,"insolation":364.4,"wind_speed":3.45,"wind_direction":270.0},{"forecast_time":"2020-12-06 13:00:00","temperature":11.72,"pressure":1006.91,"humidity":65.4,"clouds":35.7,"insolation":400.9,"wind_speed":3.79,"wind_direction":270.0},{"forecast_time":"2020-12-06 14:00:00","temperature":11.68,"pressure":1006.76,"humidity":65.3,"clouds":27.4,"insolation":364.7,"wind_speed":3.87,"wind_direction":270.0},{"forecast_time":"2020-12-06 15:00:00","temperature":11.47,"pressure":1006.73,"humidity":65.9,"clouds":24.0,"insolation":284.1,"wind_speed":3.76,"wind_direction":270.0},{"forecast_time":"2020-12-06 16:00:00","temperature":11.01,"pressure":1006.95,"humidity":67.5,"clouds":23.3,"insolation":164.9,"wind_speed":3.57,"wind_direction":270.0},{"forecast_time":"2020-12-06 17:00:00","temperature":10.31,"pressure":1007.17,"humidity":70.8,"clouds":15.4,"insolation":32.4,"wind_speed":3.26,"wind_direction":270.0},{"forecast_time":"2020-12-06 18:00:00","temperature":9.74,"pressure":1007.61,"humidity":74.7,"clouds":15.0,"insolation":0.0,"wind_speed":2.96,"wind_direction":247.5},{"forecast_time":"2020-12-06 19:00:00","temperature":9.28,"pressure":1007.87,"humidity":78.3,"clouds":17.3,"insolation":0.0,"wind_speed":2.76,"wind_direction":247.5},{"forecast_time":"2020-12-06 20:00:00","temperature":8.91,"pressure":1008.09,"humidity":81.2,"clouds":17.5,"insolation":0.0,"wind_speed":2.63,"wind_direction":225.0},{"forecast_time":"2020-12-06 21:00:00","temperature":8.6,"pressure":1008.15,"humidity":83.5,"clouds":17.7,"insolation":0.0,"wind_speed":2.58,"wind_direction":225.0},{"forecast_time":"2020-12-06 22:00:00","temperature":8.37,"pressure":1008.14,"humidity":84.9,"clouds":18.2,"insolation":0.0,"wind_speed":2.55,"wind_direction":225.0},{"forecast_time":"2020-12-06 23:00:00","temperature":8.2,"pressure":1008.1,"humidity":85.7,"clouds":18.9,"insolation":0.0,"wind_speed":2.52,"wind_direction":225.0}]
翌日の予報値をJSON形式で取得できます。
できた!
自画自賛っぽいけど、便利!!
さて、このデータを使ってどんなサービスを作ろうかな〜。