This package allows you to use the API provided by Meteocat to retrieve weather data from its weather stations networks. The package is still in development and does not include support for all the API operations. See the TODO section for more information.
Access to forecasts, real-time and historical data from the Meteorological Service of Catalonia
As Meteocat APIs need a valid API key to allow responses, this library won't work if you don't provide one. This stands for both free and paid (pro) subscription plans. You can signup for a free API key on the Meteocat website. Please notice that both subscriptions plan are subject to requests throttling.
go get github.com/oscaromeu/meteocat
package main
import (
"fmt"
"github.com/oscaromeu/meteocat"
"log"
"os"
)
func main() {
// execute export METEOCAT_API_KEY=<API_KEY_VALUE> on a shell first
d, err := meteocat.NewMesurades(os.Getenv("METEOCAT_API_KEY"))
if err != nil {
log.Fatalln(err)
}
if meteocat.CheckAPIKeyExists(d.Key) == false {
fmt.Println("ApiKey is not set. ")
}
data := meteocat.Data{
Any: "2021",
Mes: "01",
Dia: "06",
}
params, _ := meteocat.NewParameters(
meteocat.OptionCodiEstacio("UG"),
meteocat.OptionCodiVariable("5"),
meteocat.OptionData(data),
)
// Call MeasurementByDay Method
d.MeasurementByDay(params)
fmt.Println(d.Measurements)
}
Documentation of the API can be found at https://apidocs.meteocat.gencat.cat/documentacio/.
- Add support for the following API operations:
- Mesurades
- Predicció
- Add more tests
Report bug at Issues・oscaromeu/meteocat - GitHub.
oscaromeu (https://github.com/oscaromeu)
This software is released under the MIT License, see LICENSE.