Locationforecast: API Reference#
- class yr_weather.Locationforecast(headers: Dict[str, str], use_cache=True)#
Bases:
APIClientA client for interacting with the MET Locationforecast API.
The client has multiple functions which can be used for retrieving data from the API.
It must be initialized with a
headersdict, which at least includes a User-Agent. The headers will be used with therequestslibrary.For usage examples, see the documentation.
- get_air_temperature(lat: float, lon: float, altitude: int | None = None) float | None#
Retrieve the air temperature at a given location.
This function returns the latest data available, meaning it provides the current air temperature.
- Parameters:
- Returns:
The air temperature, given in the current scale used by the Yr Locationforecast API (this is usually degrees Celsius).
- Return type:
- get_forecast(lat: float, lon: float, forecast_type: Literal['complete', 'compact'] = 'complete') Forecast#
Retrieve a complete or compact forecast for a selected location.
- Parameters:
- Returns:
An instance of
Forecastwith helper functions and values from the API.- Return type:
- get_instant_data(lat: float, lon: float, altitude: int | None = None) ForecastTimeDetails#
Retrieve current weather information about a location.
This includes air pressure, temperature, humidity, wind and more.
- get_units() ForecastUnits#
Retrieve a list of units used by the MET Locationforecast API.
- Returns:
A dataclass with units currently used.
- Return type:
- class yr_weather.data.locationforecast.Forecast(forecast_data: APIForecast)#
A class holding a location forecast with multiple timeframes to choose from.
- geometry#
Geometry data for this forecast.
- Type:
- units#
The units used by this forecast.
- Type:
- get_forecast_time(time: datetime) ForecastTime | None#
Get a certain
ForecastTimeby specifying the time. The time will be rounded to the nearest hour.- Parameters:
time (datetime.datetime) – The datetime to use when retrieving the nearest forecast info.
- Return type:
ForecastTime| None
- now() ForecastTime#
Get the newest
ForecastTimefor this Forecast.- Return type:
- class yr_weather.data.locationforecast.ForecastTime(_data: APIForecastTime)#
A class holding data about a forecast for a specific time.
- details#
The forecast data for this ForecastTime.
- Type:
- next_hour#
A ForecastFuture with data about the forecast the next hour.
- Type:
- next_6_hours#
A ForecastFuture with data about the forecast the 6 hours.
- Type:
- next_12_hours#
A ForecastFuture with data about the forecast the 12 hours.
- Type:
- class yr_weather.data.locationforecast.ForecastFuture(summary: APIForecastFutureSummary | None = None, details: APIForecastFutureDetails | None = None)#
A class holding a forecast predicting the weather in the future from a specified time.
- summary#
A summary for this forecast.
- Type:
- details#
The forecast data for this forecast.
- Type:
Dataclasses#
- class yr_weather.data.locationforecast.ForecastGeometry(type: str | None = None, coordinates: List[int] | None = None)#
Geometry data for a forecast.
- class yr_weather.data.locationforecast.ForecastUnits(air_pressure_at_sea_level: str | None = None, air_temperature: str | None = None, air_temperature_max: str | None = None, air_temperature_min: str | None = None, air_temperature_percentile_10: str | None = None, air_temperature_percentile_90: str | None = None, cloud_area_fraction: str | None = None, cloud_area_fraction_high: str | None = None, cloud_area_fraction_low: str | None = None, cloud_area_fraction_medium: str | None = None, dew_point_temperature: str | None = None, fog_area_fraction: str | None = None, precipitation_amount: str | None = None, precipitation_amount_max: str | None = None, precipitation_amount_min: str | None = None, probability_of_precipitation: str | None = None, probability_of_thunder: str | None = None, relative_humidity: str | None = None, ultraviolet_index_clear_sky: str | None = None, wind_from_direction: str | None = None, wind_speed: str | None = None, wind_speed_of_gust: str | None = None, wind_speed_percentile_10: str | None = None, wind_speed_percentile_90: str | None = None)#
Class storing units used by a forecast.
- class yr_weather.data.locationforecast.ForecastTimeDetails(air_pressure_at_sea_level: float | None = None, air_temperature: float | None = None, air_temperature_percentile_10: float | None = None, air_temperature_percentile_90: float | None = None, cloud_area_fraction: float | None = None, cloud_area_fraction_high: float | None = None, cloud_area_fraction_low: float | None = None, cloud_area_fraction_medium: float | None = None, dew_point_temperature: float | None = None, fog_area_fraction: float | None = None, relative_humidity: float | None = None, ultraviolet_index_clear_sky: float | None = None, wind_from_direction: float | None = None, wind_speed: float | None = None, wind_speed_of_gust: float | None = None, wind_speed_percentile_10: float | None = None, wind_speed_percentile_90: float | None = None)#
Details of weather data for a forecast time.
- class yr_weather.data.locationforecast.ForecastFutureSummary(symbol_code: str | None = None, symbol_confidence: str | None = None)#
Summary for a forecast predicting the weather in the future.
- class yr_weather.data.locationforecast.ForecastFutureDetails(air_pressure_at_sea_level: float | None = None, air_temperature: float | None = None, air_temperature_max: float | None = None, air_temperature_min: float | None = None, air_temperature_percentile_10: float | None = None, air_temperature_percentile_90: float | None = None, cloud_area_fraction: float | None = None, cloud_area_fraction_high: float | None = None, cloud_area_fraction_low: float | None = None, cloud_area_fraction_medium: float | None = None, dew_point_temperature: float | None = None, fog_area_fraction: float | None = None, precipitation_amount: float | None = None, precipitation_amount_max: float | None = None, precipitation_amount_min: float | None = None, probability_of_precipitation: float | None = None, probability_of_thunder: float | None = None, relative_humidity: float | None = None, ultraviolet_index_clear_sky: float | None = None, wind_from_direction: float | None = None, wind_speed: float | None = None, wind_speed_of_gust: float | None = None, wind_speed_percentile_10: float | None = None, wind_speed_percentile_90: float | None = None)#
Details for a forecast predicting the weather in the future.