SMHI Open Data for Dart
A Dart package for usage of the Swedish Meteorological and Hydrological Institute’s Open Data API. The API allows you to get the weather and other meterological data like air temperature & pressure. At the time of writing this, the Meteorological Forecasts API is available in the following countries:
- Sweden
- Norway
- Finland
- Denmark
- Estonia
And partly:
- Latvia
- Lithuania
Usage
This example shows how to get the air temperature at this time tomorrow in Stockholm:
import 'package:smhi/smhi.dart'; final MeteorologicalForecasts meteorologicalForecasts = MeteorologicalForecasts(); // Your request will automatically be cached. So if you make the same one again, it will return the cached version. final Forecast? forecast = await meteorologicalForecasts.forecast(GeoPoint(59.334591, 18.063240)); if (forecast != null) { // Forecasts are divided into moments where each moment represents a date & time. // Read more at SMHI's documentation: https://opendata.smhi.se/apidocs/metfcst/get-forecast.html final ForecastMoment moment = forecast.momentWhen(DateTime.now().add(const Duration(days: 1))); print(moment.valueOf(MetFcstParameter.airTemperature)); }
Supported SMHI Open Data APIs
API | Supported |
---|---|
Meteorological Forecasts |
Terms of use
You can find SMHI’s terms of use and their documentation on their website, written in Swedish and English respectively. Their open data follows the Creative Commons Attribution 4.0 International (CC BY 4.0) license.
To prevent high unnecessary usage of SMHI’s API, requests will automatically be cached. You can clear the cache manually:
SMHICache().clear();
Download source code for SMHI Open Data for Dart
Provides the list of the opensource Flutter apps collection with GitHub repository.