kotajacob / metservice-go

Read-only mirror of https://git.sr.ht/~kota/metservice-go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

metservice-go godocs.io builds.sr.ht status

A go library for reading weather data from Metservice. Unfortunately this API isn't documented and probably not even intended for public usage. Reading through the godocs documentation will give you an idea of the values the API will return, but the best way to figure it out is just messing with it a bit.

For a longer more practical example see metweather a cli app built with this library.

Discussion and patches can be found here.

Example

import (
	"context"
	"fmt"

	"git.sr.ht/~kota/metservice-go"
)

func main() {
	client := NewClient()
	ctx := context.Background()

	forecast, _, err := client.GetForecast(ctx, "Dunedin")
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(*forecast.LocationIPS)
	for _, day := range forecast.Days {
		fmt.Printf("%v\nforecast: %v\nmax: %vC\nmin: %vC\n\n",
			*day.Date,
			*day.ForecastWord,
			*day.Max,
			*day.Min)
	}
}

About

Read-only mirror of https://git.sr.ht/~kota/metservice-go

License:GNU General Public License v3.0


Languages

Language:Go 100.0%