The response to the API request is in the JSON format.
"data": {
"tstype": "met.no/filter",
"tseries": [
{
"header": {
"id": {
"level": 10,
"parameterid": 211,
"sensor": 0,
"stationid": 18700
},
"extra": {
"element": {
"description": "Air temperature (default 2 m above ground), present value",
"id": "air_temperature",
"name": "Air temperature",
"unit": "degC"
},
"station": {
"location": [
{
"from": "1941-01-01T00:00:00Z",
"to": "9999-01-01T00:00:00Z",
"value": {
"elevation(masl/hs)": "94",
"latitude": "59.942300",
"longitude": "10.720000"
}
}
],
"shortname": "Oslo (Blindern)"
},
"timeseries": {
"geometry": {
"level": {
"unit": "m",
"value": "10"
}
},
"quality": {
"exposure": [
...
],
"performance": [
...
]
},
"timeoffset": "PT0H",
"timeresolution": "PT1H"
}
}
},
"observations": [
{
"time": "2022-10-20T08:00:00Z",
"body": {
"data": "2.9000001",
"qualitycode": "2"
}
},
...
]
},
...
]
}
{
"data": {
"tstype": "badevann",
"tseries": [
{
"header": {
"id": {
"buoyid": "1-34071",
"parameter": "temperature",
"source": "yr.no"
},
"extra": {
"name": "Kuvauen",
"pos": {
"lat": "10.83966",
"lon": "59.09197"
}
}
},
"observations": [
{
"time": "2020-07-29T16:00:00Z",
"body": {
"value": "17.0"
}
},
{
"time": "2020-07-31T12:29:00Z",
"body": {
"value": "19.5"
}
},
{
"time": "2020-08-01T08:44:00Z",
"body": {
"value": "18.5"
}
}
]
}
]
}
}
When you have made a request URL (or made a script to request data), you can add the hdrcsv and obscsv parameters to your request to get the result in the CSV hybrid format. hdrcsv defines the header, and obscsv defines the main CSV part.
The part you add to a URL:
&hdrcsv={"id":{"stationid":""}},{"id":{"sensor":""}},{"id":{"level":""}},{"extra":{"element":{"id":""}}}&obscsv={"time":""},{"body":{"data":""}}
The output format of the response is by default JSON, however you can specify a hybrid CSV format using the parameters: hdrcsv and obscsv.
The hybrid CSV format will consist of a header on top of comma separated columns of data. If you ask for observations from more than one
stationid or elementid, you will get a header/columns combination for each of the time series (try the example below to test it!).
You can use hdrcsv to define what the header should contain, and obscsv to specify what columns to include.
For example one can define that we want the stationid, sensor, level, and the elementid (from the "extra" metadata section) in the header:
hdrcsv={"id":{"stationid":""}},{"id":{"sensor":""}},{"id":{"level":""}},{"extra":{"element":{"id":""}}}
And the minimum one might need in the observation part is time and the data:
obscsv={"time":""},{"body":{"data":""}}
To put it all togehter, try this example url:
NB! If you use Firefox browser and it shows you a SyntaxError JSON error, you may have to click on the Raw Data option at the top of the browser window!
In other words, when you have made a request URL you can add the part with the hdrcsv and obscsv parameters at the end of your URL
to get the result in the CSV hybrid format!
The part you add:
&hdrcsv={"id":{"stationid":""}},{"id":{"sensor":""}},{"id":{"level":""}},{"extra":{"element":{"id":""}}}&obscsv={"time":""},{"body":{"data":""}}
We use regular 4xx and 5xx http status codes, as close as possible to the HTTP specification. Some errors will have a message of what went wrong in it. You will get an error message if there are no data matching your request but this does not mean there is anything wrong with your request in itself, only that you will have to change your search criteria. Some errors will respond with JSON. Do not encode those JSON error responses, as they might change without proper versioning as described above.
There might be cases where the service can give a successfull response, but the response object is missing some data. In that case, we will include one or more warning messages in the object.