-
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
9 changed files
with
19,714 additions
and
1,467 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,37 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"os" | ||
|
||
"github.com/oscaromeu/meteocat" | ||
) | ||
|
||
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: "2023", | ||
Mes: "01", | ||
Dia: "06", | ||
} | ||
params, _ := meteocat.NewParameters( | ||
meteocat.OptionCodiEstacio("D5"), | ||
meteocat.OptionCodiVariable("32"), | ||
meteocat.OptionData(data), | ||
) | ||
|
||
// Call MeasurementByDay Method | ||
d.MeasurementByDay(params) | ||
fmt.Println(d.Measurements) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
``` | ||
curl -H "Content-Type: application/json" -H "X-Api-Key: $METEOCAT_API_KEY" https://api.meteo.cat/referencia/v1/municipis | ||
``` | ||
|
||
``` | ||
curl -H "Content-Type: application/json" -H "X-Api-Key: $METEOCAT_API_KEY" https://api.meteo.cat/xema/v1/estacions/metadades?estat=ope&data=2023-03-11Z | ||
``` | ||
|
||
``` | ||
cat testdata/metadades_totes_estacions.json| jq -r '.|sort_by(.nom)|.[]|([.nom, .codi])|@tsv' | ||
``` | ||
|
||
``` | ||
curl -H "Content-Type: application/json" -H "X-Api-Key: $METEOCAT_API_KEY" https://api.meteo.cat/xema/v1/estacions/D5/metadades | ||
``` | ||
|
||
``` | ||
curl -H "Content-Type: application/json" -H "X-Api-Key: $METEOCAT_API_KEY" https://api.meteo.cat/xema/v1/variables/mesurades/32/2023/03/12?codiEstacio=D5 | ||
``` |
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,293 @@ | ||
{ | ||
"codi": 32, | ||
"lectures": [ | ||
{ | ||
"data": "2023-03-12T00:00Z", | ||
"valor": 15.2, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T00:30Z", | ||
"valor": 15.7, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T01:00Z", | ||
"valor": 15.7, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T01:30Z", | ||
"valor": 15.4, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T02:00Z", | ||
"valor": 15.3, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T02:30Z", | ||
"valor": 15.2, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T03:00Z", | ||
"valor": 15.1, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T03:30Z", | ||
"valor": 15.2, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T04:00Z", | ||
"valor": 14.9, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T04:30Z", | ||
"valor": 14.3, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T05:00Z", | ||
"valor": 13.3, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T05:30Z", | ||
"valor": 13.3, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T06:00Z", | ||
"valor": 13.1, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T06:30Z", | ||
"valor": 13.7, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T07:00Z", | ||
"valor": 14.5, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T07:30Z", | ||
"valor": 15.2, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T08:00Z", | ||
"valor": 16.2, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T08:30Z", | ||
"valor": 16.4, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T09:00Z", | ||
"valor": 15.9, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T09:30Z", | ||
"valor": 16.7, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T10:00Z", | ||
"valor": 17.4, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T10:30Z", | ||
"valor": 17.9, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T11:00Z", | ||
"valor": 19, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T11:30Z", | ||
"valor": 19.4, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T12:00Z", | ||
"valor": 19.4, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T12:30Z", | ||
"valor": 19.4, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T13:00Z", | ||
"valor": 18.7, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T13:30Z", | ||
"valor": 18.8, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T14:00Z", | ||
"valor": 18.1, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T14:30Z", | ||
"valor": 18.6, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T15:00Z", | ||
"valor": 19.5, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T15:30Z", | ||
"valor": 19.3, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T16:00Z", | ||
"valor": 17.5, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T16:30Z", | ||
"valor": 16.6, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T17:00Z", | ||
"valor": 15.3, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T17:30Z", | ||
"valor": 13.4, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T18:00Z", | ||
"valor": 12.8, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T18:30Z", | ||
"valor": 13, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T19:00Z", | ||
"valor": 12.6, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T19:30Z", | ||
"valor": 12.8, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T20:00Z", | ||
"valor": 14.1, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T20:30Z", | ||
"valor": 14.4, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T21:00Z", | ||
"valor": 14.6, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T21:30Z", | ||
"valor": 14.3, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T22:00Z", | ||
"valor": 14.7, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T22:30Z", | ||
"valor": 15.2, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T23:00Z", | ||
"valor": 15.1, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
}, | ||
{ | ||
"data": "2023-03-12T23:30Z", | ||
"valor": 15.1, | ||
"estat": "V", | ||
"baseHoraria": "SH" | ||
} | ||
] | ||
} |
Oops, something went wrong.