A simple Python command-line weather application that fetches real-time weather data for Tirupati using the OpenWeatherMap API.
This project is beginner-friendly and demonstrates:
- Using APIs with
requests - Securing API keys using
.env - Parsing JSON responses
- Basic data formatting (temperature, wind speed, sunrise/sunset)
- Temperature & feels like (in °C)
- Weather condition
- Humidity
- Wind speed (km/h)
- Atmospheric pressure
- Visibility
- Sunrise & Sunset time
- Python 3
requestspython-dotenv- OpenWeatherMap API
git clone https://github.com/your-username/weather-cli.git
cd weather-clipip install requests python-dotenv- Create an account at OpenWeatherMap
- Generate an API key
- Create a
.envfile in the project root:
API_KEY=your_openweathermap_api_key_hereRun the script:
python weather.py Weather for Tirupati
Temperature: 29.45°C (Feels like 31.20°C)
Condition: Clouds
Humidity: 68%
Wind: 10.8 km/h
Pressure: 1012 hPa
Visibility: 6000 m
Sunrise: 06:22 AM
Sunset: 06:01 PM
weather-cli/
│── weather.py
│── .env
│── .gitignore
│── README.md
- Change the CITY_ID to get weather for another city
- Add forecast endpoint (
/forecast) for future weather - Convert into a full CLI tool using
argparse
This project is open-source and free to use for learning purposes.
Murali Krishna Merala Diploma in AI & ML | Python & AIML Learner