• You need to register a client on MyPage before you can access the API.
  • Create an access token using client_credentials, and send this as a bearer token header.


Table of contents:

How to register your application

To use the BarentsWatch API you have to register your application with BarentsWatch. Please see: https://www.barentswatch.no/om/apnedata/ 

Information about how to obtain an API user: Please see www.barentswatch.no/om/api-vilkar (Norwegian) or send an e-mail to post@barentswatch.no 

Open ID Connect flows

The BarentsWatch API supports Open ID Connect flows like client credentials, authorization code, and device code. Self registered clients only supports client_credentials. You have to contact BarentsWatch to set up other types of clients.

The OpenID discovery document is here: https://id.barentswatch.no/.well-known/openid-configuration (production).

How to request an access token

You need ClientID and ClientSecret from self-registration on MyPage/Minside, or obtained from BarentsWatch.

How to use the access token

An application can obtain a token for use with the BarentsWatch API by posting a token request via HTTPS to https://id.barentswatch.no/connect/token:


Example request, using curl:

curl -X POST --header "Content-Type: application/x-www-form-urlencoded" -d "client_id=YOUR_CLIENT_ID&scope=api&client_secret=YOUR_CLIENT_SECRET&grant_type=client_credentials" https://id.barentswatch.no/connect/token


Example success response:

{
  "access_token":"MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3",
  "token_type":"bearer",
  "expires_in":3600
}

More information: https://www.oauth.com/oauth2-servers/access-tokens/access-token-response/

How to use your access token to access the API

This is an example request to the BarentsWatch API to get available forecast times for a particular fairway.

GET /bwapi/v1/geodata/waveforecast/available/?modelname=folda&fairwayid=1 HTTP/1.1
Host: www.barentswatch.no
User-Agent: My Application Name
Content-Type: application/x-www-form-urlencoded
Authorization: bearer MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3


The same request using curl:

curl -X GET "https://www.barentswatch.no/bwapi/v1/geodata/waveforecast/available?modelname=folda&fairwayid=1" --header  "accept: text/plain" --header  "Authorization: Bearer MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3"


These external websites might be useful for developers:


How to log in to the OpenAPI documentation

You can log in to the OpenAPI-documentation with your own client.

You are now logged in.

You can select the API documentation in the dropdown-menu in the upper-right corner.


Important information about API access

To use the BarentsWatch API application developers must first register their applications with BarentsWatch. Please see: https://www.barentswatch.no/om/apnedata/