How to use Luna API

Luna API is a REST-service.

Versioning

For major changes to the api, we will add a new version number to the url, e.g /api/v2/. For smaller changes to the api, we will provide a beta service which includes those changes, before merging the changes into the production version.

Error handling

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. Some errors will respons 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.

Authentication

To be able to receive data via Luna API, you have to have an agreement on delivery of weather services from Luna.

Luna API uses OpenID connect to authenticate users. The authentication is a two-step process. First generate an access token by passing the client ID and client secret to the https://login.met.no/auth/realms/External/protocol/openid-connect/token endpoint and then use the access token to get the data from Luna API.

Example using curl:

Step 1, generate an access token:


curl -d 'grant_type=client_credentials&client_id=<client_id>&client_secret=<client_secret>' 'https://login.met.no/auth/realms/External/protocol/openid-connect/token'

Step 2, use the access token to get data:


curl -H 'Authorization: Bearer <access token>' 'https://api.luna.met.no/api/v1/offshore/<ID>/json'

Offshore endpoints

Available offshore forecasts
https://api.luna.met.no/api/v1/offshore/available
Forecast as JSON
https://api.luna.met.no/api/v1/offshore/<ID>/json
Forecast as CSV
https://api.luna.met.no/api/v1/offshore/<ID>/csv