Locationforecast: API Reference#
- class yr_weather.Locationforecast(headers: dict, use_cache: bool | None = True)#
Bases:
BaseClientA client for interacting with the Yr 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.Example 1. Getting a location forecast for a specified location:
import yr_weather headers = { "User-Agent": "Your User-Agent" } yr_client = yr_weather.Locationforecast(headers=headers) # Get weather data for Oslo, Norway. weather_data = yr_client.get_forecast(59.91, 10.75)
- get_air_temperature(lat: float, lon: float, altitude: int | None = None) float#
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'] | None = 'complete') CompleteForecast | CompactForecast#
Retrieve a complete or compact forecast for a selected location.
- Parameters:
- Returns:
An object with all possible values from the API, including temperature, air pressure, humidity and so on.
- Return type:
- get_instant_data(lat: float, lon: float, altitude: int | None = None) CompactInstantDetails#
Retrieve current weather information about a location.
This includes air pressure, temperature, humidity, wind and more.
- get_units() CompleteUnits#
Retrieve a list of units used by the Yr Locationforecast API.
- Returns:
A typed dict with units currently used.
- Return type: