In this blog, you'll learn how to create a simple command-line Weather App using Python and the OpenWeatherMap API — from setup to final output!
🔧 Tools You’ll Need:
-
Python installed on your computer
-
Internet connection
-
A free API key from OpenWeatherMap
🌐 Step 1: Get OpenWeatherMap API Key
-
Sign up for a free account
-
Navigate to the API keys section in your profile
-
Copy your API key (you’ll need it for the script)
📁 Step 2: Create a Python File
Create a file named weather_app.py
🧱 Step 3: Write the Python Code
🧪 Step 4: Test the App
-
Open your terminal or command prompt
-
Run:
-
Enter a city name (e.g.,
Delhi,London) -
See the current weather data appear in your console!
⚙️ How It Works
-
We use the requests library to send a GET request to OpenWeather's API.
-
The response is in JSON format. We extract specific data like temperature, weather condition, humidity, etc.
-
The app then prints that information in a user-friendly way.
🚀 Bonus: Add More Features
-
Convert it into a GUI using Tkinter or PyQt
-
Add weather forecast for 5 days
-
Log data to a file
-
Show icons for weather conditions
🔒 Don't Forget
✅ Replace "YOUR_API_KEY" with your actual OpenWeather API key
✅ Handle API errors and invalid city inputs properly
✅ Final Thoughts
This Weather App is a great introduction to APIs, Python requests, and JSON. It’s lightweight, beginner-friendly, and helps you build a project you can be proud of.
💬 Want a GUI
version with Tkinter? Or want to deploy it on the web using Flask? Comment below and I’ll help you build it!

Post a Comment