Already using forecast.xml (varsel.xml)?

This guide will walk you through how to convert from forecast.xml to the new JSON-format. There are some changes in the new JSON-format that we want to point out. forecast.xml and forecast_hour_by_hour.xml was composed by several data sources: forecast, sun events, observations (Norway), location meta data and text forecast (Norway). Since the old API will seize to exist early next year, we will now make a few changes. This includes making an API that is cleaner and easier to use. The new API will be versioned and we strongly advise you to subscribe to our mailing list or RSS-feed, so you will keep up to future changes.

Elements that are no longer supported

Location meta information

Because the data now are fetched directly from the Norwegian Meteorological Institute's API, it does not contain any meta information regarding the location. This includes name, country, category and time zone. This data you will now have to add yourself.

Sun events

This information do not belong in a forecast. This is purely astrophysics data, which you can use other libraries to calculate sun up and down and other celestial events. It is no longer necessary to use this for finding the correct weather symbol as that is now included in the forecast; however if you want to display the exact times you can use the MET Sunrise API.

Next update

Since our data are constantly refreshed, we no longer seem it necessary to apply this meta information. The cache headers (see paragraph "Caching our data" below) will supply enough information to refresh when necessary, if you do your coding right.

Text forecast (Norway only)

This data was removed a while ago, because we now longer support text forecast for a position, only larger areas. These can be downloaded from the MET Textforecast API.

Observations

These data was also removed a while ago, and we highly want to point to the observation API (Frost) for observation data. This is mainly for Norwegian observation sites.

Caching our data

Earlier we urged you to cache our data statically for 1 hour. Now we recommend to use the cache headers in the HTTP response. Than you will get updated forecast, when it's available in the API. You can read all about it in the "Caching data" paragraph in our Getting Started documentation

Forecast

Below you will see excerpt from the new JSON structure and the old forecast_hour_by_hour.xml and how to map the old convention to the new. This is a result of calling https://api.met.no/weatherapi/locationforecast/2.0/compact?lat=59.93484&lon=10.72084&altitude=59

{
    "time": "2020-05-12T08:00:00Z",
    "data": {
        "instant": {
            "details": {
                "air_pressure_at_sea_level": 1003.1,
                "air_temperature": 6,
                "cloud_area_fraction": 94.6,
                "relative_humidity": 36.3,
                "wind_from_direction": 320.7,
                "wind_speed": 3.9
            }
        },
        "next_12_hours": {
            "summary": {
                "symbol_code": "cloudy"
            }
        },
        "next_1_hours": {
            "summary": {
                "symbol_code": "cloudy"
            },
            "details": {
                "precipitation_amount": 0
            }
        },
        "next_6_hours": {
            "summary": {
                "symbol_code": "cloudy"
            },
            "details": {
                "precipitation_amount": 0
            }
        }
    }
}

/api/forecast/v2/complete?lat=60&lon=10

<time from="2020-05-12T11:00:00" to="2020-05-12T12:00:00">
	<!-- Valid from 2020-05-12T11:00:00 to 2020-05-12T12:00:00 -->
	<symbol number="4" numberEx="4" name="Cloudy" var="04"/>
	<precipitation value="0"/>
	<!--  Valid at 2020-05-12T11:00:00  -->
	<windDirection deg="330.5" code="NNW" name="North-northwest"/>
	<windSpeed mps="4.2" name="Gentle breeze"/>
	<temperature unit="celsius" value="8"/>
	<pressure unit="hPa" value="1003.1"/>
</time>

forecast_hour_by_hour.xml

Mapping old and new time series

In the JSON-file, you will now find forecast data for 10 days. It contains both 1-hour, 6-hours data and 12-hours data. You will get approximately 2,5 days with 1 hour resolution and 10 days with 6 hours resolution. Previously you had to fetch both forcast.xml and forecast_hour_by_hour.xml and combine them yourself.

The new time series are devided into "instant", "next_1_hours", "next_6_hours" and "next_12_hours" with it's own "details" and/or "summary"

Units

You will find a list of all the units we are using in properties -> meta -> units

Time element

The start of the period is fetched from the time property. The end of the period depends if you are using 1-hour, 6-hours or 12-hours data. So you just add 1, 6 or 12 accordingly. Remember that all our data is issued in UTC-time, so you should convert it to your own time zone.

Symbol

The symbol code you will find in next_1_hours -> summary -> symbol_code, next_6_hours -> summary -> symbol_code or next_12_hours -> summary -> symbol_code depending if you are showing 1-, 6- or 12-hours data.

In forecast.xml and forecast_hour_by_hour.xml, the symbol object had several attributes, which combined gave you the symbol id you could lookup in our symbol set and file/directory structure. The new format will give you a symbol code directly and this will tell you if it's day, night or polar day. As you can see, the symbol is not an instant value (e.g. at 11:00) - it is valid over a period spanning from 11:00 - 12:00. The same rules applies for precipitation. You can read about and download the new symbol set from https://api.met.no/weatherapi/weathericon/2.0/documentation.

Precipitation

next_1_hours -> details -> precipitation_amount or next_6_hours -> details -> precipitation_amount gives the precipitation data for the actual period.

Wind

Both wind speed and wind direction are instant values, and can be found in the instant -> details section. We no longer support the Beaufort text, so you should map these values yourself.

Temperature

The temperature value can be found in instant -> details -> air_temperature. This is the temperature at the start of a period (e.g. at 09:00).

Pressure

This is also an instant value, and you will find it in instant -> details -> air_pressure_at_sea_level.

Other parameters

In addition you will find several other new parameters. These are described in the data model documentation.

  • Cloud area fraction (percentage value of the total cloud cover)
  • Relative humidity

If you would like to use our detailed forecast, with even more parameters, you can switch "compact" with "complete" in the call:

https://api.met.no/weatherapi/locationforecast/2.0/complete?lat=59.9348&lon=10.7208&altitude=59