Skip to content

API reference

Wttr

Wttr(
    *,
    base_url: AnyHttpUrl = build(
        scheme="https", host="wttr.in"
    ),
    session: Client | None = None,
)

Client for the wttr.in weather API.

Use it as a context manager or call close when done.

Parameters:

  • base_url (AnyHttpUrl, default: build(scheme='https', host='wttr.in') ) –

    Server to send requests to, e.g. a self-hosted wttr.in.

  • session (Client | None, default: None ) –

    HTTP client to send requests with. If None, one is created on the first request, with a 60 s timeout (5 s to connect). close closes it either way.

Examples:

import pywttr

with pywttr.Wttr() as wttr:
    weather = wttr.weather("Paris")

weather

weather(
    location: str, /, *, language: Language = EN
) -> AnyModel

Get the current weather and a forecast for 3 days.

Raises httpx2.HTTPStatusError if wttr.in responds with an error status, e.g. for an unknown location.

Parameters:

  • location (str) –

    City, airport code, ~landmark, latitude,longitude or anything else wttr.in accepts.

  • language (Language, default: EN ) –

    Language of the weather description. It also selects the return type, e.g. Language.RU gives pywttr.models.ru.Model.

Examples:

import pywttr

with pywttr.Wttr() as wttr:
    weather = wttr.weather("Paris", language=pywttr.Language.DE)
print(weather.current_condition[0].lang_de[0].value)

close

close() -> None

Close the HTTP client.

base_url property

base_url: AnyHttpUrl

Server the requests go to.

session property

session: Client | None

HTTP client; None until the first request if none was passed.

__enter__

__enter__() -> Self

Return the client itself.

__exit__

__exit__(*_: object) -> None

Close the HTTP client.

Language

Bases: StrEnum

Language of the weather description; values are wttr.in codes.

Examples:

Prefer the member: type checkers then know the exact response model.

language = Language.ZH_CN
language = Language["ZH_CN"]
language = Language("zh-cn")

AF

AF

Afrikaans.

AM

AM

Amharic.

AR

AR

Arabic.

AZ

AZ

Azerbaijani; untranslated descriptions come in English.

BA

BA

Bashkir; untranslated descriptions come in English.

BE

BE

Belarusian.

BG

BG

Bulgarian; untranslated descriptions come in English.

BN

BN

Bengali.

BS

BS

Bosnian; untranslated descriptions come in English.

BY

BY

Belarusian under the code by, translated less than BE.

CA

CA

Catalan.

CRK

CRK

Plains Cree.

CS

CS

Czech; untranslated descriptions come in English.

CY

CY

Welsh; untranslated descriptions come in English.

DA

DA

Danish.

DE

DE

German.

EL

EL

Greek.

EN

EN

English.

EO

EO

Esperanto; untranslated descriptions come in English.

ES

ES

Spanish; untranslated descriptions come in English.

ET

ET

Estonian.

EU

EU

Basque; untranslated descriptions come in English.

FA

FA

Persian.

FI

FI

Finnish; untranslated descriptions come in English.

FR

FR

French.

FY

FY

Frisian; untranslated descriptions come in English.

GA

GA

Irish; untranslated descriptions come in English.

GL

GL

Galician.

HE

HE

Hebrew; untranslated descriptions come in English.

HI

HI

Hindi.

HR

HR

Croatian; untranslated descriptions come in English.

HU

HU

Hungarian.

HY

HY

Armenian; untranslated descriptions come in English.

IA

IA

Interlingua.

ID

ID

Indonesian.

IS

IS

Icelandic; untranslated descriptions come in English.

IT

IT

Italian.

JA

JA

Japanese; untranslated descriptions come in English.

JV

JV

Javanese; untranslated descriptions come in English.

KA

KA

Georgian; untranslated descriptions come in English.

KK

KK

Kazakh; untranslated descriptions come in English.

KO

KO

Korean; untranslated descriptions come in English.

KY

KY

Kyrgyz; untranslated descriptions come in English.

LT

LT

Lithuanian.

LV

LV

Latvian; untranslated descriptions come in English.

MG

MG

Malagasy.

MK

MK

Macedonian; untranslated descriptions come in English.

ML

ML

Malayalam; untranslated descriptions come in English.

MR

MR

Marathi; untranslated descriptions come in English.

NB

NB

Norwegian Bokmål.

NL

NL

Dutch.

NN

NN

Norwegian Nynorsk; untranslated descriptions come in English.

OC

OC

Occitan.

PA

PA

Punjabi.

PL

PL

Polish.

PT

PT

Portuguese; untranslated descriptions come in English.

PT_BR

PT_BR

Brazilian Portuguese.

RO

RO

Romanian.

RU

RU

Russian.

SK

SK

Slovak; untranslated descriptions come in English.

SL

SL

Slovenian; untranslated descriptions come in English.

SR

SR

Serbian; untranslated descriptions come in English.

SR_LAT

SR_LAT

Serbian (Latin script); untranslated descriptions come in English.

SV

SV

Swedish; untranslated descriptions come in English.

SW

SW

Swahili; untranslated descriptions come in English.

TA

TA

Tamil.

TE

TE

Telugu; untranslated descriptions come in English.

TH

TH

Thai.

TR

TR

Turkish.

TS

TS

Tsonga; untranslated descriptions come in English.

UK

UK

Ukrainian.

VI

VI

Vietnamese.

ZH

ZH

Chinese; untranslated descriptions come in English.

ZH_CN

ZH_CN

Simplified Chinese.

ZH_TW

ZH_TW

Traditional Chinese.

ZU

ZU

Zulu; untranslated descriptions come in English.

Response models

Each language has its own module, such as pywttr.models.fr. Its CurrentConditionItem and HourlyItem add the translated description twice: as lang_fr and as lang_xx, which every language has.

Response models shared by all languages.

Model

Bases: FrozenModel, Generic[_TCurrentConditionItem, _THourlyItem]

Weather at a location: now and for 3 days.

current_condition

current_condition: tuple[_TCurrentConditionItem, ...]

Current weather, one item.

nearest_area

nearest_area: tuple[NearestAreaItem, ...]

The area nearest to the location, one item.

request

request: tuple[RequestItem, ...]

How wttr.in understood the location, one item.

weather

weather: tuple[WeatherItem[_THourlyItem], ...]

Forecast for today, tomorrow and the day after.

CurrentConditionItem

Bases: FrozenModel

Current weather.

feels_like_c

feels_like_c: int

Feels-like temperature, °C.

feels_like_f

feels_like_f: int

Feels-like temperature, °F.

cloudcover

cloudcover: int

Cloud cover, %.

humidity

humidity: int

Relative humidity, %.

observation_time

observation_time: str

Observation time in UTC, e.g. 04:33 AM.

precip_inches

precip_inches: float

Precipitation, inches.

precip_mm

precip_mm: float

Precipitation, mm.

pressure

pressure: int

Atmospheric pressure, hPa.

pressure_inches

pressure_inches: int

Atmospheric pressure, inHg.

temp_c

temp_c: int

Temperature, °C.

temp_f

temp_f: int

Temperature, °F.

uv_index

uv_index: int

UV index.

visibility

visibility: int

Visibility, km.

visibility_miles

visibility_miles: int

Visibility, miles.

weather_code

weather_code: int

WorldWeatherOnline condition code, e.g. 113 for clear sky.

weather_desc

weather_desc: tuple[WeatherDescItem, ...]

Weather description in English, one item.

weather_icon_url

weather_icon_url: tuple[WeatherIconUrlItem, ...]

Weather icon, one item.

winddir16_point

winddir16_point: str

Wind direction on a 16-point compass, e.g. SSW.

winddir_degree

winddir_degree: int

Wind direction, degrees.

windspeed_kmph

windspeed_kmph: int

Wind speed, km/h.

windspeed_miles

windspeed_miles: int

Wind speed, mph.

WeatherItem

Bases: FrozenModel, Generic[_THourlyItem]

Forecast for a day.

astronomy

astronomy: tuple[AstronomyItem, ...]

Sun and moon, one item.

avgtemp_c

avgtemp_c: int

Average temperature, °C.

avgtemp_f

avgtemp_f: int

Average temperature, °F.

date

date: str

Local date, e.g. 2026-10-15.

hourly

hourly: tuple[_THourlyItem, ...]

Forecast for every 3 hours, from 00:00 to 21:00 local time.

maxtemp_c

maxtemp_c: int

Maximum temperature, °C.

maxtemp_f

maxtemp_f: int

Maximum temperature, °F.

mintemp_c

mintemp_c: int

Minimum temperature, °C.

mintemp_f

mintemp_f: int

Minimum temperature, °F.

sun_hour

sun_hour: float

Hours of sunshine.

total_snow_cm

total_snow_cm: float

Snowfall, cm.

uv_index

uv_index: int

UV index.

HourlyItem

Bases: FrozenModel

Forecast for a 3-hour slot.

dew_point_c

dew_point_c: int

Dew point, °C.

dew_point_f

dew_point_f: int

Dew point, °F.

feels_like_c

feels_like_c: int

Feels-like temperature, °C.

feels_like_f

feels_like_f: int

Feels-like temperature, °F.

heat_index_c

heat_index_c: int

Heat index, °C.

heat_index_f

heat_index_f: int

Heat index, °F.

wind_chill_c

wind_chill_c: int

Wind chill, °C.

wind_chill_f

wind_chill_f: int

Wind chill, °F.

wind_gust_kmph

wind_gust_kmph: int

Wind gusts, km/h.

wind_gust_miles

wind_gust_miles: int

Wind gusts, mph.

chanceoffog

chanceoffog: int

Chance of fog, %.

chanceoffrost

chanceoffrost: int

Chance of frost, %.

chanceofhightemp

chanceofhightemp: int

Chance of high temperature, %.

chanceofovercast

chanceofovercast: int

Chance of overcast, %.

chanceofrain

chanceofrain: int

Chance of rain, %.

chanceofremdry

chanceofremdry: int

Chance of staying dry, %.

chanceofsnow

chanceofsnow: int

Chance of snow, %.

chanceofsunshine

chanceofsunshine: int

Chance of sunshine, %.

chanceofthunder

chanceofthunder: int

Chance of thunder, %.

chanceofwindy

chanceofwindy: int

Chance of wind, %.

cloudcover

cloudcover: int

Cloud cover, %.

diff_rad

diff_rad: float

Diffuse solar radiation, W/m².

humidity

humidity: int

Relative humidity, %.

precip_inches

precip_inches: float

Precipitation, inches.

precip_mm

precip_mm: float

Precipitation, mm.

pressure

pressure: int

Atmospheric pressure, hPa.

pressure_inches

pressure_inches: int

Atmospheric pressure, inHg.

short_rad

short_rad: float

Shortwave solar radiation, W/m².

temp_c

temp_c: int

Temperature, °C.

temp_f

temp_f: int

Temperature, °F.

time

time: int

Local start time, HHMM as a number: 0, 300, ..., 2100.

uv_index

uv_index: int

UV index.

visibility

visibility: int

Visibility, km.

visibility_miles

visibility_miles: int

Visibility, miles.

weather_code

weather_code: int

WorldWeatherOnline condition code, e.g. 113 for clear sky.

weather_desc

weather_desc: tuple[WeatherDescItem, ...]

Weather description in English, one item.

weather_icon_url

weather_icon_url: tuple[WeatherIconUrlItem, ...]

Weather icon, one item.

winddir16_point

winddir16_point: str

Wind direction on a 16-point compass, e.g. SSW.

winddir_degree

winddir_degree: int

Wind direction, degrees.

windspeed_kmph

windspeed_kmph: int

Wind speed, km/h.

windspeed_miles

windspeed_miles: int

Wind speed, mph.

AstronomyItem

Bases: FrozenModel

Sun and moon for a day.

moon_illumination

moon_illumination: int

Moon illumination, %.

moon_phase

moon_phase: str

Moon phase, e.g. Waxing Crescent.

moonrise

moonrise: str

Moonrise, local time, e.g. 01:47 PM.

moonset

moonset: str

Moonset, local time, e.g. 09:03 PM.

sunrise

sunrise: str

Sunrise, local time, e.g. 08:11 AM.

sunset

sunset: str

Sunset, local time, e.g. 07:01 PM.

NearestAreaItem

Bases: FrozenModel

The area nearest to the requested location.

area_name

area_name: tuple[AreaNameItem, ...]

Area name, one item.

country

country: tuple[CountryItem, ...]

Country, one item.

latitude

latitude: float

Latitude, degrees.

longitude

longitude: float

Longitude, degrees.

population

population: int

Population, 0 if unknown.

region

region: tuple[RegionItem, ...]

Region, one item.

weather_url

weather_url: tuple[WeatherUrlItem, ...]

Forecast page on WorldWeatherOnline, one item.

RequestItem

Bases: FrozenModel

How wttr.in understood the location.

query

query: str

Resolved location, e.g. Lat 48.86 and Lon 2.35.

type

type: str

Query type, e.g. LatLon.

WeatherDescItem

Bases: FrozenModel

Weather description, e.g. Sunny.

value

value: str

WeatherIconUrlItem

Bases: FrozenModel

URL of a weather icon.

value

value: str

AreaNameItem

Bases: FrozenModel

Area name, e.g. Saint-Merri.

value

value: str

CountryItem

Bases: FrozenModel

Country name, e.g. France.

value

value: str

RegionItem

Bases: FrozenModel

Region name, e.g. Ile-de-France.

value

value: str

WeatherUrlItem

Bases: FrozenModel

URL of the area's forecast on WorldWeatherOnline.

value

value: str

LangItem

LangItem

Alias of WeatherDescItem.

AnyModel

AnyModel: TypeAlias

Response model of any language.