owned this note
owned this note
Published
Linked with GitHub
# GOSU BAR 天氣 API 教學
## [天氣 API](https://works.ioa.tw/weather/api/doc/index.html#api-Weather_API)
### API說明文件
https://works.ioa.tw/weather/api/doc/index.html#api-Weather_API
### 全台鄉鎮區編號
```
https://works.ioa.tw/weather/api/all.json
```
### 取得某鄉鎮區的[天氣狀況](https://works.ioa.tw/weather/api/doc/index.html#api-Weather_API-GetHttpsWorksIoaTwWeatherApiWeathersIdJson)
```
https://works.ioa.tw/weather/api/weathers/{{區域編號}}.json
ex: 1 = 中正區
https://works.ioa.tw/weather/api/weathers/1.json
```
### 台北市中正區天氣狀況:
``` json
{
img: "02@2x.png",
desc: "多雲",
temperature: 25,
felt_air_temp: 26,
humidity: 67,
rainfall: 0,
sunrise: "06:34",
sunset: "17:08",
at: "2018-12-21 11:35:02",
specials: [ ],
histories: [
{
img: "02@2x.png",
desc: "多雲",
temperature: 18,
felt_air_temp: 19,
humidity: 79,
rainfall: 0,
sunrise: "06:34",
sunset: "17:08",
at: "2018-12-21 06:05:01"
},
{
img: "02@2x.png",
desc: "多雲",
temperature: 18,
felt_air_temp: 19,
humidity: 79,
rainfall: 0,
sunrise: "06:34",
sunset: "17:08",
at: "2018-12-21 06:35:02"
},
{
img: "02@2x.png",
desc: "多雲",
temperature: 18,
felt_air_temp: 19,
humidity: 79,
rainfall: 0,
sunrise: "06:34",
sunset: "17:08",
at: "2018-12-21 07:05:02"
},
{
img: "02@2x.png",
desc: "多雲",
temperature: 19,
felt_air_temp: 19,
humidity: 78,
rainfall: 0,
sunrise: "06:34",
sunset: "17:08",
at: "2018-12-21 07:35:02"
},
{
img: "02@2x.png",
desc: "多雲",
temperature: 19,
felt_air_temp: 19,
humidity: 78,
rainfall: 0,
sunrise: "06:34",
sunset: "17:08",
at: "2018-12-21 08:05:03"
},
{
img: "02@2x.png",
desc: "多雲",
temperature: 19,
felt_air_temp: 20,
humidity: 77,
rainfall: 0,
sunrise: "06:34",
sunset: "17:08",
at: "2018-12-21 08:35:02"
},
{
img: "02@2x.png",
desc: "多雲",
temperature: 19,
felt_air_temp: 20,
humidity: 77,
rainfall: 0,
sunrise: "06:34",
sunset: "17:08",
at: "2018-12-21 09:05:02"
},
{
img: "02@2x.png",
desc: "多雲",
temperature: 22,
felt_air_temp: 23,
humidity: 72,
rainfall: 0,
sunrise: "06:34",
sunset: "17:08",
at: "2018-12-21 09:35:02"
},
{
img: "02@2x.png",
desc: "多雲",
temperature: 22,
felt_air_temp: 23,
humidity: 72,
rainfall: 0,
sunrise: "06:34",
sunset: "17:08",
at: "2018-12-21 10:05:02"
},
{
img: "02@2x.png",
desc: "多雲",
temperature: 24,
felt_air_temp: 25,
humidity: 72,
rainfall: 0,
sunrise: "06:34",
sunset: "17:08",
at: "2018-12-21 10:35:02"
},
{
img: "02@2x.png",
desc: "多雲",
temperature: 24,
felt_air_temp: 25,
humidity: 72,
rainfall: 0,
sunrise: "06:34",
sunset: "17:08",
at: "2018-12-21 11:05:03"
},
{
img: "02@2x.png",
desc: "多雲",
temperature: 25,
felt_air_temp: 26,
humidity: 67,
rainfall: 0,
sunrise: "06:34",
sunset: "17:08",
at: "2018-12-21 11:35:02"
}
]
}
```
### 執行 API 節點設定
![](https://i.imgur.com/pW2pDIT.png)
### 天氣示意圖
![](https://works.ioa.tw/weather/img/weathers/zeusdesign/02@2x.png)
圖片網址:
```
https://works.ioa.tw/weather/img/weathers/zeusdesign/${tmp.info.img}
```
### 發送訊息節點文字訊息:
```
天氣:${tmp.info.desc}
氣溫:${tmp.info.temperature}°C
體感:${tmp.info.felt_air_temp}°C
濕度:${tmp.info.humidity}
雨量:${tmp.info.rainfall}
日出:${tmp.info.sunrise}
日落:${tmp.info.sunset}
```
### 結果示意圖
![](https://i.imgur.com/Z7D1Z6l.jpg)
---