DEV Community

Cover image for A 30-Day Weather Dashboard: How I Built A Python Project for API Integration and Cloud Storage
Favour Onyeneke
Favour Onyeneke

Posted on

3

A 30-Day Weather Dashboard: How I Built A Python Project for API Integration and Cloud Storage

Overview

The 30days Weather Dashboard is a Python-based application designed to fetch weather data for multiple cities using the OpenWeather API. It saves the fetched weather data to an AWS S3 bucket for storage, demonstrating best practices in API integration, cloud resource management, and secure credentials handling.

Features

  • Fetches real-time weather data for specified cities.
  • Displays temperature, humidity, and weather conditions.
  • Saves weather data securely to an AWS S3 bucket.
  • Implements error handling for API and cloud service interactions.

Technologies Used

  • Programming Language: Python
  • API Service: OpenWeather API
  • Cloud Service: AWS S3
  • Libraries:
    • boto3 for AWS interactions
    • requests for HTTP requests to the OpenWeather API
    • dotenv for managing environment variables

Project Structure

weather-dashboard/
  src/
    __init__.py
    weather_dashboard.py
  tests/
  data/
  .env
  .gitignore
  requirements.txt
Enter fullscreen mode Exit fullscreen mode

File Descriptions

  • src/weather_dashboard.py: Main script for fetching weather data and interacting with AWS S3.
  • .env: Stores sensitive credentials such as API keys and AWS bucket names.
  • requirements.txt: Lists the dependencies required for the project.

Setup Instructions

Prerequisites

Ensure the following are installed:

  • Python 3.8+
  • AWS CLI
  • Git

Steps

1.Clone the repository:

   git clone https://github.com/onlyfave/30days-weather-dashboard.git
   cd 30days-weather-dashboard
Enter fullscreen mode Exit fullscreen mode

2.Install dependencies:

   pip install -r requirements.txt
Enter fullscreen mode Exit fullscreen mode

3.Configure environment variables in a .env file:

   OPENWEATHER_API_KEY=01a1ec452e4adb14c36d7121723ddc04
   AWS_BUCKET_NAME=weather-dashboard
   AWS_DEFAULT_REGION=us-east-1
Enter fullscreen mode Exit fullscreen mode

4.Configure AWS credentials:

   aws configure
Enter fullscreen mode Exit fullscreen mode

5.Run the application:

   python3 src/weather_dashboard.py
Enter fullscreen mode Exit fullscreen mode

Screenshots

1.Application Output:

Screenshot 2025-01-26 165945

2.AWS S3 Bucket Configuration:

Screenshot 2025-01-26 173554

3.Error Handling:

Screenshot 2025-01-26 174257

4.AWS S3 Output:

Screenshot 2025-01-26 173717

What I Learned

  • AWS S3 Bucket Management: Creating, managing, and integrating S3 buckets with Python.
  • Secure Credential Handling: Using environment variables to manage sensitive information securely.
  • API Integration: Best practices for consuming external APIs in Python.
  • Error Handling: Managing and logging errors in distributed systems.
  • Git Workflow: Managing version control for project development.

Future Enhancements

  • Add weather forecasting for upcoming days.
  • Implement a graphical user interface (GUI) for better usability.
  • Integrate advanced data visualizations using libraries like Matplotlib or Plotly.
  • Expand support for more cities and internationalization.
  • Automate testing using frameworks like Pytest.
  • Set up a CI/CD pipeline for streamlined deployments.

Acknowledgements

Special thanks to:

  • The DevOps and Python communities for their invaluable resources.
  • OpenWeather for providing weather data.
  • AWS for cloud storage and infrastructure.

Contact

For any questions or feedback, feel free to reach out:

Image of AssemblyAI

Automatic Speech Recognition with AssemblyAI

Experience near-human accuracy, low-latency performance, and advanced Speech AI capabilities with AssemblyAI's Speech-to-Text API. Sign up today and get $50 in API credit. No credit card required.

Try the API

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay