-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
207 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
# Meteocat API Client | ||
|
||
[](https://goreportcard.com/report/github.com/oscaromeu/meteocat) | ||
[](https://github.com/itchyny/meteocat/blob/master/LICENSE) | ||
[](https://pkg.go.dev/github.com/oscaromeu/meteocat) | ||
|
||
### Rest client implented in Go to send requests and inspect responses of the Meteocat API Rest | ||
|
||
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 include support of the all the API operations. See the TODO section for | ||
more information. | ||
|
||
## What kind of data can I get with Meteocat Go Library ? | ||
|
||
Access to forecasts, real-time and historical data from the Meteorological Service of Catalonia | ||
|
||
## Get started | ||
|
||
### API key | ||
|
||
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 OWM website Please notice that | ||
the free API subscription plan is subject to requests throttling. | ||
|
||
### Installation | ||
|
||
#### Build from source | ||
|
||
`go get github.com/oscaromeu/meteocat` | ||
|
||
### Examples | ||
|
||
#### Get value of Minimum subsoil temperature at 5 cm at the Viladecans station | ||
|
||
```go | ||
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 | ||
|
||
Documentation of the API can be found | ||
at [https://apidocs.meteocat.gencat.cat/documentacio/](https://apidocs.meteocat.gencat.cat/documentacio/). | ||
|
||
## TODO | ||
- [ ] Add trace request latency (DNSLookup, TCP Connection and so on) | ||
- [ ] Add example to ingest data on Elasticsearch and visualize it on Kibana | ||
- [ ] Add example to insert data on Influxdb and visualize on Grafana Dashboard | ||
- [ ] Add CLI example | ||
- [ ] Add support for the following API operations: | ||
- [x] Mesurades | ||
- [ ] Predicció | ||
- [ ] Representatives | ||
- [ ] Estacions | ||
- [ ] Estadistics | ||
- [ ] Càlcul multivariable | ||
- [ ] Xarxa de Detecció de Descàrregues Elèctriques | ||
- [ ] Referència | ||
- [ ] Quotes | ||
- [ ] Full code testing | ||
|
||
## Bug Tracker | ||
|
||
Report bug at [Issues・oscaromeu/meteocat - GitHub](https://github.com/oscaromeu/meteocat/issues). | ||
|
||
## Author | ||
|
||
oscaromeu (https://github.com/oscaromeu) | ||
|
||
## License | ||
|
||
This software is released under the MIT License, see LICENSE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters