Client reference¶
- class python_weather.client.Client(*, unit: ~enum.auto | None = <Unit [C, Kmph]>, locale: ~python_weather.enums.Locale | None = Locale.ENGLISH, session: ~aiohttp.client.ClientSession | None = None)¶
The class that lets you interact with the API.
- Parameters:
unit (Optional[
enum.auto
]) – Whether to use the metric or imperial/customary system (IMPERIAL
). Defaults toMETRIC
.locale (Optional[Locale]) – Whether to use a different locale/language as the description for the returned forecast. Defaults to
Locale.ENGLISH
.session (Optional[
aiohttp.ClientSession
]) – Whether to use an existing aiohttp client session for requesting or not. Defaults toNone
(creates a new one instead)
- Raises:
Error – If the
unit
argument is notNone
and it’s also notMETRIC
orIMPERIAL
, or if thelocale
argument is notNone
and it’s also not a part of theLocale
enum.
- async get(location: str, *, unit: auto | None = None, locale: Locale | None = None) Forecast ¶
Fetches a weather forecast for a specific location.
- Parameters:
location (str) – The requested location name for said weather forecast.
unit (Optional[
enum.auto
]) – Overrides the metric or imperial/customary system (IMPERIAL
) used by theClient
object. Defaults toNone
(uses the one from theClient
).locale (Optional[Locale]) – Overrides the locale/language used by the
Client
object. Defaults toNone
(uses the one from theClient
).
- Raises:
Error – If the aiohttp client session used by the
Client
object is already closed, if theunit
argument is notNone
and it’s also notMETRIC
orIMPERIAL
, if thelocale
argument is notNone
and it’s also not a part of theLocale
enum, or if theClient
cannot send a web request to the web server.- Returns:
The requested weather forecast.
- Return type:
- class python_weather.enums.Locale¶
Represents the list of supported locales/languages by this library.
- AFRIKAANS = 'af'¶
- AMHARIC = 'am'¶
- ARABIC = 'ar'¶
- ARMENIAN = 'hy'¶
- AZERBAIJANI = 'az'¶
- BANGLA = 'bn'¶
- BASQUE = 'eu'¶
- BELARUSIAN = 'be'¶
- BOSNIAN = 'bs'¶
- BULGARIAN = 'bg'¶
- CATALAN = 'ca'¶
- CHINESE_SIMPLIFIED = 'zh'¶
- CHINESE_SIMPLIFIED_CHINA = 'zh-cn'¶
- CHINESE_TRADITIONAL_TAIWAN = 'zh-tw'¶
- CROATIAN = 'hr'¶
- CZECH = 'cs'¶
- DANISH = 'da'¶
- DUTCH = 'nl'¶
- ENGLISH = 'en'¶
- ESPERANTO = 'eo'¶
- ESTONIAN = 'et'¶
- FINNISH = 'fi'¶
- FRENCH = 'fr'¶
- FRISIAN = 'fy'¶
- GALICIAN = 'gl'¶
- GEORGIAN = 'ka'¶
- GERMAN = 'de'¶
- GREEK = 'el'¶
- HINDI = 'hi'¶
- HIRI_MOTU = 'ho'¶
- HUNGARIAN = 'hu'¶
- ICELANDIC = 'is'¶
- INDONESIAN = 'id'¶
- INTERLINGUA = 'ia'¶
- IRISH = 'ga'¶
- ITALIAN = 'it'¶
- JAPANESE = 'ja'¶
- JAVANESE = 'jv'¶
- KAZAKH = 'kk'¶
- KISWAHILI = 'sw'¶
- KOREAN = 'ko'¶
- KYRGYZ = 'ky'¶
- LATVIAN = 'lv'¶
- LITHUANIAN = 'lt'¶
- MACEDONIAN = 'mk'¶
- MALAGASY = 'mg'¶
- MALAYALAM = 'ml'¶
- MARATHI = 'mr'¶
- NORWEGIAN_BOKMAL = 'nb'¶
- NORWEGIAN_NYNORSK = 'nn'¶
- OCCITAN = 'oc'¶
- PERSIAN = 'fa'¶
- POLISH = 'pl'¶
- PORTUGUESE = 'pt'¶
- PORTUGUESE_BRAZIL = 'pt-br'¶
- ROMANIAN = 'ro'¶
- RUSSIAN = 'ru'¶
- SERBIAN = 'sr'¶
- SERBIAN_LATIN = 'sr-lat'¶
- SLOVAK = 'sk'¶
- SLOVENIAN = 'sl'¶
- SPANISH = 'es'¶
- SWEDISH = 'sv'¶
- TAMIL = 'ta'¶
- TELUGU = 'te'¶
- THAI = 'th'¶
- TURKISH = 'tr'¶
- UKRAINIAN = 'uk'¶
- UZBEK = 'uz'¶
- VIETNAMESE = 'vi'¶
- WELSH = 'cy'¶
- ZULU = 'zu'¶