A command-line Python application that fetches and displays real-time weather information for any specified city using the OpenWeatherMap API.
This project demonstrates clean API integration, JSON data parsing, and graceful error handling in Python.
- 🔗 API Integration – Makes GET requests to OpenWeatherMap using the
requestslibrary - 📊 Weather Metrics – Displays:
- Temperature (°C/°F)
- Feels Like
- Humidity
- Weather Description
- Sunrise & Sunset (Local Time)
- Wind Speed
- 🛡️ Error Handling – Gracefully handles invalid city names or failed responses
- 🧑💻 User Interaction – Accepts city name input from the user dynamically
- Python ≥ 3.6
requestslibrary
-
Clone the Repository
git clone https://github.com/Avnish1447/weather-api-integration.git cd weather-api-integration -
Install Dependencies
pip install requests
-
Get an API Key
- Sign up at OpenWeatherMap
- Create a file named
api_key(no extension) in the project directory and paste your API key into it
Run the script from your terminal:
python weather_app.pyYou'll be prompted to enter the name of a city. The app fetches and displays current weather info.
Enter the name of the city: Mumbai
City: Mumbai
Temperature: 32.99°C / 91.38°F
Feels Like: 38.79°C / 101.82°F
Humidity: 58%
Weather: Smoke
Sunrise (local time): 05:12:34
Sunset (local time): 20:45:21
Wind Speed: 4.12 m/s
weather-api-integration/
├── weather_app.py # Main application logic
├── api_key # Your personal OpenWeatherMap API key (not shared)
├── requirements.txt # Python dependencies
└── README.md # Project documentation
Contributions are welcome!
- Fork the repo
- Create a new branch
git checkout -b feature-name
- Make changes and commit
git commit -m "Add: Feature Description" - Push your branch and open a Pull Request
This project is licensed under the MIT License — see the LICENSE file for details.
📧 [email protected]
Feel free to reach out for collaboration, questions, or feedback!