1-Minute Observations API
home
Access
First things first, you'll need access. Our self sign-up page is coming soon, so in the meantime please email api.queries@metservice.com with the following information:
First Name:
Last Name:
Email Address:
Company/Organisation:
Intended Use (including whether commercial or non-commercial):
API of interest or Requested Data:
Observation data is received every minute from the network of Automatic Weather Stations, Road, and Runway sensors. This API makes the data accessible.
The 1 minute data is searchable for 60 days from the time of the observation. A range search prior to 60 days will return no results.
Supported calls
Four API calls are currently supported:
https://api.metservice.com/observations/nz/1-minute/weatherStation
https://api.metservice.com/observations/nz/1-minute/weatherStation/<stationId>/latest
https://api.metservice.com/observations/nz/1-minute/weatherStation/<stationId>/last/<minutes>/minutes
https://api.metservice.com/observations/nz/1-minute/weatherStation/<stationId>/range/<fromDateTime>/<toDateTime>
For more information about the supported calls refer to the individual endpoint overviews in the Specification section in the left hand column.
URI Parameters
Parameter | Example | Description |
---|---|---|
stationId | 93110 NZKTA | The unique identifier for the weather station, road or airport runway sensor. This can be specified as either the numeric World Meteorological Orcganisation (WMO) identifier or the aplhabetic International Civil Aviation Organization (ICAO) indetifier. Use the /weatherStation API call to retrieve a list of identifiers for which observations have been received in the last 60 minutes. |
minutes | 60 | The number of minutes back in time from now that a data query should search. Valid Value Range: 1-1440 for format type json 1-360 for format type cf-json |
fromDateTime | 2015-07-04T21:30:00Z | RFC-3339 format. The start of the date time range for which to perform the search. |
toDateTime | 2015-07-04T21:45:30Z | RFC-3339 format. The end of the date time range for which to perform the search. |
Allowable Date Time Range between fromDateTime and toDateTime: 1-1440 minutes for format type json 1-360 minutes for format type cf-json |
Query Parameters
Parameter | Example | Description |
---|---|---|
format | cf-json | An enumerated value specifying the format of the returned data. Not applicable for the weather station list call. Valid Values: json (default if format parameter is not supplied) cf-json (Specifying cf-json will give back the fields along with detailed descriptions of the fields and their values meaning.) |
vars | airtemp_01mnavg,windspd_01mnavg,rainfal_01mnacc | A comma separated list of individual observed variables to return in the response. The obs_timestamp variable will always be returned. |
Call Status Codes
Status | Description | Meaning |
---|---|---|
200 | OK | The request was successful. The requested data is returned in the body of the message. |
400 | Bad Request | Either the request was malformed or the parameters were incorrect. |
401 | Unauthorized | A valid apikey or bearer token was not supplied or authentication failed based upon apikey or bearer token provided. The supplied apikey is not authorised to access data for the supplied stationId. |
429 | Too Many Requests | You have either exceeded your daily quota of API requests or have exceeded the number of requests allowed per second based on your API Account Plan. |
500 | Internal Server Error | Some unexpected error has occurred. |
Response Data
The response data will be returned in json format whether that be the default json response format or the cf-json response format.
Note:
For a detailed description of the observation fields, their description and the data they contain, specify the format query parameter format=cf-json. See the cf-json sample response on the Sample Responses page of this documentaion.
Example Calls
curl --location --request GET 'https://test-api.metservice.com/observations/nz/1-minute/weatherStation' --header 'Authorization: Bearer <your bearer token goes here>'
curl --location --request GET 'https://test-api.metservice.com/observations/nz/1-minute/weatherStation/93968/latest?format=json&vars=airtemp_01mnavg,windspd_01mnavg,rainfal_01mnacc' -header 'Authorization: Bearer <your bearer token goes here>'
curl --location --request GET 'https://test-api.metservice.com/observations/nz/1-minute/weatherStation/NZKTA/last/10/minutes?format=cf-json' --header 'apikey: <your apikey goes here>'
curl --location --request GET 'https://test-api.metservice.com/observations/nz/1-minute/weatherStation/93110/range/2020-06-19T04:00:00Z/2020-06-19T04:48:00Z' --header 'apikey: <your apikey goes here>'
Security
The API is currently secured in two ways:
Authentication
- by provision of an API Key provided on an HTTP header of type "apikey".API Key authentication is performed against the Gateway Developer Portal database using standard gateway assertions. An API Key is assigned when an Application is configured within the Gateway Developer Portal for the API customer. The API customers Application must have this API assigned to it for use.
- by provision of a Bearer token provided on an HTTP header of type "Authorization"Bearer token authentication is performed by validating and decoding against a JWKS (JSON Web Key Set). Currently an OKTA and MetConnect JWKS are supported. The bearer token will have been assigned when the API user or application authenticated against another Authentication service.