Get Real-time, 3-Day or hourly forcast with WeatherAPI
This project provides a command-line interface to interact with weather forecast data using the RapidAPI Weather API. It allows users to fetch and display weather information for various cities, manage a list of favorite cities, and view current, daily, and hourly forecasts.
- Requirements
- Installation
- Configuration
- Usage
- Running the Application
- Main Menu Options
- Weather Options Menu
- Contributing
- License
- Contact
- Python 3.6 or higher
python-dotenv
: For loading environment variables from the .env file.requests
: For making HTTP requests to the RapidAPI Weather API.
- Clone the repository
git clone https://github.com/yourusername/weather-forecast-api.git
cd weather-forecast-api
- Create and activate a virtual environment (optional but recommended):
python -m venv .venv
source .venv/bin/activate
- Install dependencies:
pip install -r requirements.txt
- Create a .env file in the root directory with the following content:
- Obtain an API key 🔑 from WeatherAPI.
- Replace your_rapidapi_key with your actual RapidAPI key.
RAPIDAPI_KEY=your_rapidapi_key
RAPIDAPI_HOST=weatherapi-com.p.rapidapi.com
Ensure you have a .env
file with your RapidAPI key and host details as described in the Installation section. This file is necessary for the application to authenticate and fetch weather data from the RapidAPI Weather API.
To run the Weather Forecast API application, execute the following command:
python weather_app.py
Once the application is running, you will see the main menu with the following options:
- Enter a new city: Allows you to enter a new city and country, fetch the weather data for that city, and add it to the favorites list if the data is valid.
- View favorite cities: Displays the list of favorite cities stored in the favorite cities list.
- Remove a city from favorites: Allows you to remove a city from the favorites list.
- Exit: Exits the application.
After entering a new city, you can select from the following weather options:
- Check Current Weather: Displays the current weather for the specified city.
- Check Today's Forecast: Displays the weather forecast for today.
- Check Tomorrow's Forecast: Displays the weather forecast for tomorrow.
- Check Day After Tomorrow's Forecast: Displays the weather forecast for the day after tomorrow.
- Check Hourly Forecast: Displays the hourly weather forecast for the specified city.
- Exit: Returns to the main menu.
Contributions are welcome! Please fork the repository and submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.