Endpoint
Query parameters
City name to query. The app hardcodes
jaipur as the default location.Your OpenWeatherMap API key. Passed as a query parameter on every request.
Unit system for temperature values. Accepted values:
standard(default) — Kelvinmetric— Celsiusimperial— Fahrenheit
standard units and converts Kelvin to Celsius manually.Response fields
The following fields from the API response are used by the app.City name returned by the API. Mapped to
#location.Short text description of current weather conditions (e.g.,
light rain, clear sky). Mapped to #weather. Displayed in capitalize case via CSS.Icon code used to construct the weather icon URL. Mapped to the
src attribute of #icon.Temperature in Kelvin (when using default
standard units). The app converts this to Celsius before display. Mapped to #temp.Relative humidity percentage (0–100). Displayed as
Humidity: X%. Mapped to #humidity.Wind speed in metres per second. Displayed as
Wind Speed: X m/s. Mapped to #wind.Icon URL pattern
Weather icons are served by OpenWeatherMap using the icon code fromweather[0].icon:
10d resolves to:
Fetch example
The following is the full fetch call fromscript.js:
script.js
The API returns temperature in Kelvin by default (no
units parameter is set). The app converts to Celsius manually using Math.round(data.main.temp - 273.15). To avoid this conversion, set units=metric in the query string — the API will then return temperature directly in Celsius.