https://github.com/qba73/meteo
Go client library for the Norwegian Meteorological Institute and the Norwegian Broadcasting Corporation weather API.
https://github.com/qba73/meteo
go golang golang-client meteorological-data meteorology weather weather-api weather-forecast yrno
Last synced: about 1 month ago
JSON representation
Go client library for the Norwegian Meteorological Institute and the Norwegian Broadcasting Corporation weather API.
- Host: GitHub
- URL: https://github.com/qba73/meteo
- Owner: qba73
- License: mit
- Created: 2019-10-25T20:56:24.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2025-04-07T08:23:06.000Z (about 1 month ago)
- Last Synced: 2025-04-15T22:56:28.085Z (about 1 month ago)
- Topics: go, golang, golang-client, meteorological-data, meteorology, weather, weather-api, weather-forecast, yrno
- Language: Go
- Homepage:
- Size: 7.53 MB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://pkg.go.dev/github.com/qba73/meteo)

# meteo
Meteo is a Go client library for the weather and meteorological forecast from [Yr](https://www.yr.no/en).
> Weather forecast from Yr, delivered by the Norwegian Meteorological Institute and NRK.
# Usage
You must register your user agent string in the [YR.NO service](https://developer.yr.no/doc/TermsOfService/) and your user name at the [GeoNames.org](https://www.geonames.org/login).
```go
package mainimport (
"fmt""github.com/qba73/meteo"
)func main() {
// Export GEO_USERNAME Env Var (you registered at geonames.org)// Get current weather for given location.
weather, err := meteo.GetWeather("Vilnius,LT")
if err != nil {
fmt.Println(err)
}fmt.Println(weather)
// Cloudy 4.2°Cfmt.Println(weather.Summary)
// cloudyfmt.Println(weather.Temp)
// 4.2
}
```The code sample below shows a basic example of how the meteo package can fetch weather statuses concurrently.
```go
package mainimport (
"fmt"
"time""github.com/qba73/meteo"
)func main() {
start := time.Now()
ch := make(chan string)locations := []string{
"Vilnius,LT", "Dublin,IE", "London,UK", "Berlin,DE",
"Belfast,UK", "Castlebar,IE", "Killarney,IE",
"Warsaw,PL", "Lodz,PL", "Vienna,AT"}for _, loc := range locations {
go getWeather(loc, ch)
}for range locations {
fmt.Println(<-ch)
}fmt.Printf("%.2fs elapsed\n", time.Since(start).Seconds())
}func getWeather(location string, ch chan<- string) {
start := time.Now()weather, err := meteo.GetWeather(location)
if err != nil {
ch <- fmt.Sprint(err)
return
}
sec := time.Since(start).Seconds()
ch <- fmt.Sprintf("%.2fs Location: %s, Weather: %s", sec, location, weather)
}
```# Installation
```
$ go install github.com/qba73/meteo/cmd/meteo@latest
```