WEATHER APPLICATION API PROJECT
The Weather Application API Project is designed to provide real-time weather information for
any global location using an external weather data service. The application fetches data such as
temperature, humidity, wind speed, and climatic conditions using RESTful API calls. Users can
search by city name, pin code, or GPS location to view current weather details along with
forecast data.
The project integrates a weather API (e.g., OpenWeatherMap / WeatherAPI) to retrieve
formatted data, which is processed and displayed in a structured UI. The application includes
features like live weather updates, location-based results, and user-friendly visual indicators such
as icons and color themes representing weather conditions.
Error handling is implemented for invalid city names, incorrect user input, or network issues.
Additional features such as temperature unit (°C/°F) conversion, 5-day forecast, and search
history are included to enhance usability. The application ensures a responsive interface suitable
for both desktop and mobile screens.
This project demonstrates strong skills in API integration, JSON parsing, asynchronous
communication, and UI/UX implementation. It helps users quickly obtain accurate weather
information and brings together both front-end and back-end concepts to build a practical real-
world solution.
import tkinter as tk
from tkinter import messagebox
import requests
from io import BytesIO
from PIL import Image, ImageTk # You need to install Pillow: pip install pillow
# ---- API CONFIG ----
API_KEY = "cd89c6d89eb079083e096d648fd92b2c"
BASE_URL = "[Link]
# ---- FUNCTION TO FETCH WEATHER ----
def get_weather():
city = city_entry.get().strip()
if not city:
[Link]("Input Error", "Please enter a city name!")
return
response = [Link](BASE_URL, params={"q": city, "appid": API_KEY, "units": "metric"})
if response.status_code == 200:
data = [Link]()
city_name = data["name"]
country = data["sys"]["country"]
temperature = round(data["main"]["temp"], 1)
description = data["weather"][0]["description"].title()
icon_code = data["weather"][0]["icon"]
icon_url = f"[Link]
# Update labels
city_label.config(text=f"{city_name}, {country}")
temp_label.config(text=f"{temperature}°C")
desc_label.config(text=description)
# Display weather icon
icon_response = [Link](icon_url)
icon_data = icon_response.content
icon_image = [Link](BytesIO(icon_data))
icon_photo = [Link](icon_image)
weather_icon.config(image=icon_photo)
weather_icon.image = icon_photo
else:
[Link]("Error", "City not found! Please try again.")
# ---- GUI SETUP ----
root = [Link]()
[Link]("Real Weather App 🌦️")
[Link]("400x500")
[Link](False, False)
[Link](bg="#cce7ff") # Light blue background
# ---- TITLE ----
title_label = [Link](root, text="🌍 Real-Time Weather", font=("Helvetica", 18, "bold"), bg="#cce7ff",
fg="#003366")
title_label.pack(pady=15)
# ---- ENTRY FRAME ----
entry_frame = [Link](root, bg="#cce7ff")
entry_frame.pack(pady=10)
city_entry = [Link](entry_frame, font=("Helvetica", 14), width=20, bd=2, relief="flat", justify="center")
city_entry.grid(row=0, column=0, ipady=6, ipadx=5, padx=5)
get_btn = [Link](entry_frame, text="Get Weather", font=("Helvetica", 12, "bold"),
bg="#003366", fg="white", activebackground="#0055aa",
relief="flat", padx=10, pady=5, command=get_weather)
get_btn.grid(row=0, column=1, padx=5)
# ---- WEATHER DISPLAY ----
weather_frame = [Link](root, bg="#cce7ff")
weather_frame.pack(pady=30)
city_label = [Link](weather_frame, text="Enter a city", font=("Helvetica", 16, "bold"), bg="#cce7ff",
fg="#003366")
city_label.pack(pady=5)
weather_icon = [Link](weather_frame, bg="#cce7ff")
weather_icon.pack(pady=5)
temp_label = [Link](weather_frame, text="", font=("Helvetica", 40, "bold"), bg="#cce7ff",
fg="#000000")
temp_label.pack(pady=5)
desc_label = [Link](weather_frame, text="", font=("Helvetica", 16), bg="#cce7ff", fg="#003366")
desc_label.pack(pady=5)
# ---- FOOTER ----
footer = [Link](root, text="Developed by pavani 💻", font=("Helvetica", 10), bg="#cce7ff",
fg="#333333")
[Link](side="bottom", pady=10)
[Link]()
OUTPUT: