A Python library to access weather data from the Swiss Federal Office of Meteorology and Climatology (MeteoSwiss).
To get the weather forecast for a specific postal code:
from swissweather.meteo import MeteoClient
client = MeteoClient()
forecast = client.get_forecast(6003) # For Lucerne
if forecast:
print(f"Current temperature in Lucerne: {forecast.current.currentTemperature[0]}°C")
for daily in forecast.dailyForecast:
print(f"Forecast for {daily.timestamp.date()}: {daily.condition}, max temp: {daily.temperatureMax[0]}°C, min temp: {daily.temperatureMin[0]}°C")
To get the current weather for a specific station:
from swissweather.meteo import MeteoClient
client = MeteoClient()
weather = client.get_current_weather_for_station("KLO") # For Zurich-Kloten
if weather:
print(f"Current weather at {weather.station}:")
print(f" Temperature: {weather.airTemperature[0]}°C")
print(f" Precipitation: {weather.precipitation[0]} mm")
print(f" Sunshine: {weather.sunshine[0]} min")
To get pollen information, you first need to get a list of pollen stations:
from swissweather.meteo import MeteoClient
client = MeteoClient()
pollen_stations = client.get_pollen_station_list()
if pollen_stations:
for station in pollen_stations:
print(station)
Then, you can get the current pollen data for a specific station:
from swissweather.meteo import MeteoClient
client = MeteoClient()
pollen_data = client.get_current_pollen_for_station("PBE") # For Bern
if pollen_data:
print(f"Current pollen data for {pollen_data.stationAbbr}:")
print(f" Birch: {pollen_data.birch[0]} No/m3")
print(f" Grasses: {pollen_data.grasses[0]} No/m3")
The data is provided by the Federal Office of Meteorology and Climatology MeteoSwiss. Please attribute them as the source of the data. For more information, please visit their website.