Overview

This Project is a Python-based application designed to interact with the OpenWeather API to fetch and display real-time weather data. This project demonstrates how to consume a third-party API, handle HTTP requests, process JSON responses, and present weather data in a user-friendly manner.

Features

  • Retrieve current weather data for a specified location.
  • Display weather details such as temperature, humidity, wind speed, and weather conditions.
  • Automatically stores weather data in AWS S3
  • Supports multiple cities tracking
  • Timestamps all data for historical tracking
  • Handle errors gracefully, including invalid API keys, network issues, and unsupported locations.

Prerequisites

Before running this project, ensure the following requirements are met:

  • AWS Account
  • Python 3.8.10 installed on your system.
  • An active OpenWeather API key.
  • Required Python packages installed.

Project Structure

Open-Weather-API-Project/
├── src/
├── init.py # Package initializer
├── weather_dashboard.py # Main script to run the application
├── .gitignore # Git ignore file
├── README.md # Project documentation
├── requirements.txt # Python dependencies

Architecture Diagram

Setup Instructions

  • clone the repository:
git clone https://github.com/ameh0429/Open-Weather-API-Project.git
 cd Open-Weather-API-Project
  • Install Dependencies
pip install -r requirements.txt


The error indicates a dependency conflict between the version of request I specified (2.28.2) and the version required by jupyterlab-server (>=2.31)

Step to fix

since jupyterlab-server requires requests>=2.31, I upgraded requests to a version that satisfies this requirement by runnig this command:

pip install "requests>=2.31"

  • Configure environment variables (.env)
OPENWEATHER_API_KEY=your_api_key
AWS_BUCKET_NAME=your_bucket_name
  • Configure AWS credentials:
aws configure

  • Insert the python script in the weather_dashboard.py file


This Python script is building a class named WeatherDashboard to:

  1. Fetch environment variables using dotenv for API keys and S3 bucket names.
  2. Use boto3 (AWS SDK for Python) to interact with AWS S3.
  3. Set up functionality to fetch weather data, process it, and store it in an S3 bucket
  • Run the application:
python src/weather_dashboard.py

  • Confirm the weather data in S3 bucket

  • Future Improvements
  1. Add support for extended forecasts (e.g., 7-day weather data).
  2. Implement unit tests for better code coverage.
  3. Enable geolocation-based weather fetching.

Author Of article : Ameh Mathias Ejeh Read full article