🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101

Weather app with a free API

Search any city and see current weather and a 7-day forecast, using the free Open-Meteo API (no key needed).

Beginner⏱ 4–6 hoursđŸĒœ 7 stepsHTMLCSSJavaScriptFetch API

What you'll learn

  • ◆fetch, async/await and JSON
  • ◆Handling loading and errors
  • ◆Geolocation API

What you'll build

  • ✓City search with suggestions
  • ✓Current temperature, wind and condition icon
  • ✓7-day forecast
  • ✓Use my location button

Step-by-step guide

  1. 1

    Find the city

    Call https://geocoding-api.open-meteo.com/v1/search?name=Jaipur to get latitude and longitude.

  2. 2

    Get the weather

    Call https://api.open-meteo.com/v1/forecast?latitude=..&longitude=..&current=temperature_2m,weather_code,wind_speed_10m&daily=temperature_2m_max,temperature_2m_min,weather_code&timezone=auto.

  3. 3

    Map weather codes

    Open-Meteo returns WMO weather codes; map them to text and an emoji or icon (0 = clear, 61 = rain, ...).

  4. 4

    Render

    Build the current card and 7 forecast cards with template literals; format days with toLocaleDateString.

  5. 5

    Loading and errors

    Show a spinner while fetching; show "City not found" or "Network error" instead of failing silently.

  6. 6

    My location

    navigator.geolocation.getCurrentPosition gives coordinates; skip the geocoding step.

  7. 7

    Remember

    Save recent searches in localStorage and show them as chips.

🚀 Make it stand out

  • +Hourly chart with Chart.js
  • +°C/°F toggle
  • +Background that changes with the weather