This project is a simple, beautiful, and functional weather forecast web application built with HTML, CSS, and JavaScript. It allows users to search for any city and get real-time weather information along with a 5-day forecast โ all powered by the OpenWeatherMap API.
Note: This is my very first time dealing with APIs, and I created this project to understand how to connect to external services, retrieve live data, and present it dynamically on the page.
-
๐ Search weather information by city name
-
โจ Search suggestions while typing
As you start typing a city name, the app suggests matching cities using the OpenWeather Geo API:
http://api.openweathermap.org/geo/1.0/direct?q=${query}&limit=5&appid=${apiKey} -
๐ Display current weather data including:
-
Temperature (ยฐC)
-
Weather condition (e.g., Clear, Rainy)
-
Wind speed (M/s)
-
Humidity (%)
-
-
๐ 5-day forecast at 12:00 PM for each day
-
๐ซ Handles invalid or empty input with a "City Not Found" error section
-
๐ Glassmorphism user interface for a clean and modern look
-
๐ฑ Fully responsive layout for desktop and mobile devices
-
HTML5
-
CSS3
-
JavaScript (ES6+)
-
OpenWeatherMap API (Weather + Geo)
-
Download or clone this project to your local machine.
-
Go to https://openweathermap.org/api and create a free account to get your API key.
-
Open the
script.jsfile and replace the default API key with your own:const apiKey = 'YOUR_API_KEY_HERE'; -
Open the
index.htmlfile in your browser to launch the app. -
Start typing a city name and choose a suggestion or press Enter to get the weather forecast.
-
assets/-
weather/โ Weather icons (SVG format) -
message/โ Message illustrations (Search & Not Found)
-
-
script.jsโ JavaScript logic: API fetch, DOM updates, and event handling -
index.htmlโ Main HTML file -
style.cssโ Styling, layout, and responsive behavior -
README.txtโ This documentation file
-
How to make API requests using
fetch() -
How to work with and parse JSON responses
-
How to use
async/awaitto handle asynchronous code -
How to dynamically manipulate the DOM
-
How to create HTML templates with
.insertAdjacentHTML() -
How to implement user input validation and error handling
-
How to use a second API (Geo API) to provide autocomplete suggestions
-
Add a toggle between Fahrenheit and Celsius
-
Display local time of the selected city
-
Show loading animations during API requests
-
Use Geolocation API to automatically detect userโs current city
-
Add light/dark mode toggle
This project is open-source and free to use for learning or inspiration.
FERKIOUI Akram
