https://github.com/minchao/go-cwb
Taiwan Central Weather Administration Open Data API library for Go (台灣中央氣象署放資料平臺)
https://github.com/minchao/go-cwb
cwa cwa-api cwb cwb-api go golang opendata taiwan tw-weather weather
Last synced: 6 months ago
JSON representation
Taiwan Central Weather Administration Open Data API library for Go (台灣中央氣象署放資料平臺)
- Host: GitHub
- URL: https://github.com/minchao/go-cwb
- Owner: minchao
- License: mit
- Created: 2017-02-23T13:48:58.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-04-27T13:47:19.000Z (over 1 year ago)
- Last Synced: 2025-03-25T01:43:49.153Z (7 months ago)
- Topics: cwa, cwa-api, cwb, cwb-api, go, golang, opendata, taiwan, tw-weather, weather
- Language: Go
- Homepage:
- Size: 61.5 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# go-cwb
[](https://github.com/minchao/go-cwb/actions/workflows/tests.yaml)
[](https://goreportcard.com/report/github.com/minchao/go-cwb)
[](https://codecov.io/gh/minchao/go-cwb)An unofficial Taiwan [Central Weather Bureau RESTful API](http://opendata.cwa.gov.tw/) library for Go.
This package is inspired by [go-github](https://github.com/google/go-github).
## Installation
```go
go get github.com/minchao/go-cwb
```## Usage
```go
import "github.com/minchao/go-cwb/cwb"
```You will need an account on opendata.cwa.gov.tw to get an API key.
Construct a new CWB client, then use to access the CWB API.
For example:```go
client := cwb.NewClient("APIKEY", nil)
```Get the 36 hour weather forecasts:
```go
forecast, _, err := client.Forecasts.Get36HourWeather(context.Background(), nil, nil)
if err != nil {
fmt.Println(err)
}
```Get the 2 day townships weather forecasts by specific country:
```go
forecast, _, err := client.Forecasts.GetTownshipsWeatherByDataId(context.Background(), cwb.FTW2DayTaipeiCity, nil, nil)
```Get the 7 day township weather forecasts by specific locations and elements:
```go
forecast, _, err := client.Forecasts.GetTownshipsWeatherByDataId(context.Background(),
cwb.FTW7DayChiayiCity,
[]string{"阿里山鄉"},
[]string{"MinT", "MaxT", "WeatherDescription"})
```## Implemented APIs
* 一般天氣預報 - 今明 36 小時天氣預報 (F-C0032-001)
* 鄉鎮天氣預報 - 單一鄉鎮市區預報資料 (F-D0047-001 - F-D0047-091)
* 鄉鎮天氣預報 - 全臺灣各鄉鎮市區預報資料 (F-D0047-093)
* 自動氣象站 - 氣象觀測資料 (O-A0001-001)
* 自動雨量站 - 雨量觀測資料 (O-A0002-001)
* 潮汐預報 - 未來 1 個月潮汐預報(F-A0021-001)[CWB Open data API documentation](https://opendata.cwa.gov.tw/dist/opendata-swagger.html#/)
## License
See the [LICENSE](LICENSE.md) file for license rights and limitations (MIT).