Skip to main content

Test pipeline Last commit Latest version in Codeberg Latest version in PyPi

Finnish Meteorological Institute Weather

Library for fetching weather information from Finnish Meteorological Institute (FMI).

If you want to know how FMI API works, you can check out their WFS Examples and Guidelines page.

For the current weather information, this library requests observations from the past 10 minutes using timestep 10. Based on my tests this gave pretty reliable results from different weather stations.

Originally, I created this for myself to get FMI weather data to Home Assistant. I am not a meteorologist so if you are more weather-savvy, feel free to contribute and provide improvements! 💖

FYI: I don't use Home Assistant or this library anymore, so I may not know if things are broken or need updating. However, I'm more than happy to maintain this library, so if you find a bug or a need to update a dependency, feel free to file an issue. Even better, file a pull request that fixes the issues! 😉 💖

How to use

Working example can be found in example.py.

Install

$ pip install fmi-weather-client 

Get weather, forecasts, and observations

You can get the weather using the following functions:

  • weather_by_place_name(place_name)
  • weather_by_coordinates(latitude, longitude)
  • observation_by_station_id(fmi_station_id)
  • observation_by_place(place_name)

Example:

import fmi_weather_client as fmi
from fmi_weather_client.errors import ClientError, ServerError

try:
    weather = fmi.weather_by_place_name("Jäppilä, Pieksämäki")
    if weather is not None:
        print(f"Temperature in {weather.place} is {weather.data.temperature}")
except ClientError as err:
    print(f"Client error with status {err.status_code}: {err.message}")
except ServerError as err:
    print(f"Server error with status {err.status_code}: {err.body}")

You can get the forecasts using the following functions:

  • forecast_by_place_name(place_name, [timestep_hours=24], [forecast_points = 4])
  • forecast_by_coordinates(latitude, longitude, [timestep_hours=24], [forecast_points = 4])

Example:

import fmi_weather_client as fmi
from fmi_weather_client.errors import ClientError, ServerError

try:
    forecast = fmi.forecast_by_coordinates(60.170998, 24.941325)
    for weather_data in forecast.forecasts:
        print(f"Temperature at {weather_data.time}: {weather_data.temperature}")
except ClientError as err:
    print(f"Client error with status {err.status_code}: {err.message}")
except ServerError as err:
    print(f"Server error with status {err.status_code}: {err.body}")

You can get the observation data from a station using the following functions:

  • observation_by_station_id(fmi_sid)

To get a weather observation from a station, you must provide a station ID. IDs can be found on FMI's station list. Note that weather observations are available only from weather stations. These are the ones with sää in the Ryhmä column.

Example:

import fmi_weather_client as fmi
from fmi_weather_client.errors import ClientError, ServerError

try:
    weather = fmi.observation_by_station_id(101794)
    if weather is not None:
         print(f"Temperature at {weather.place} is {weather.data.temperature}")
except ClientError as err:
    print(f"Client error with status {err.status_code}: {err.message}")
except ServerError as err:
    print(f"Server error with status {err.status_code}: {err.body}")

All functions have asynchronous versions available with async_ prefix.

Errors

ClientError

Happens if FMI service returns 400-499. This can happens for example if:

  • Provided coordinates are invalid
  • Provided place is not recognized
  • Weather data is not available

Error object contains status code and human-readable error message from FMI service.

ServerError

Happens if FMI service returns any other error.

Error object contains status code and raw response body from FMI service

Weather data

FMI provides the following commonly used information:

  • Temperature (°C)
  • Pressure (hPa)
  • Humidity (%)
  • Wind direction (°)
  • Wind speed (m/s)
  • Wind gust (m/s)
  • Dew point (°)
  • Cloud coverage (%)
  • Precipitation intensity (mm/h)
  • Symbol Documentation in Finnish
  • Feels like temperature (°C), calculated from weather data Documentation in Finnish

There are also other information available. Check models.py and FMI documentation for more info.

Development

Setup

Create and activate a virtual environment

$ python -m venv venv
$ source venv/bin/activate

Install required packages

$ make setup

Deactivate virtual environment when you are done

$ deactivate

Run tests

This will run unit tests and code quality checks

$ make test

Metadata

Release files for fmi-weather-client 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fmi-weather-client 1.0.0
File Size Uploaded
fmi_weather_client-1.0.0.tar.gz 30.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fmi-weather-client 1.0.0
File Interpreter ABI Platform
fmi_weather_client-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 53.7 kB

Release files / fmi_weather_client-1.0.0.tar.gz

Download URL fmi_weather_client-1.0.0.tar.gz
Size 30.6 kB
Tags Source
SHA-256 checksum
How to use checksums
22888b797718100080d4688b3be84f6dc6fdf1d5496efb39db73c0d9e853bcfb
BLAKE2b-256 checksum
How to use checksums
7fc1a6c847758c9853911a407250d1adf5a8d1c4ab27516e1c31bd35ffca7df9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release files / fmi_weather_client-1.0.0-py3-none-any.whl

Download URL fmi_weather_client-1.0.0-py3-none-any.whl
Size 23.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
979d3327e19497b1d4ed0c82c6e51abf59f81e48de9f9af366bb050f08396f3a
BLAKE2b-256 checksum
How to use checksums
e1ceb172f753bf830d7e33a2b0059c429a4c4723f2a30ef5e69822985cef2eef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page