Skip to content

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WeatherAPI

A lightweight Flask-based REST API that fetches and normalizes weather data from external providers (Open-Meteo). It provides endpoints for current weather and short forecasts and caches responses in Redis.

(back to top)

Table of Contents

  • About The Project
  • Built With
  • Getting Started
    • Prerequisites
    • Installation
  • Usage
  • Contact
  • Acknowledgments

About The Project

WeatherAPI handles client requests for weather data, validates parameters with Pydantic models, resolves city coordinates via a geocoding API, requests forecast data from Open-Meteo, and caches normalized responses in Redis for improved latency and reduced provider calls.

(back to top)

Built With

  • Python 3.10+
  • Flask
  • Flask-Limiter (rate limiting)
  • Redis (cache)
  • Requests
  • Pydantic
  • Gunicorn
  • Nginx

(back to top)

Getting Started

Prerequisites

  • Python 3.10 or later
  • Redis server reachable from the app
  • An internet connection to reach Open-Meteo geocoding and forecast endpoints

Installation

  1. Clone the repo and enter the directory:
git clone https://github.com/arakium/WeatherAPI.git
cd WeatherAPI
  1. Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Configure environment variables (example):
export REDIS_URL="redis://localhost:6379"
  1. Start Gunicorn:
gunicorn -w 4 -b 127.0.0.1:8000 app:app --reload
  1. Start Nginx to work as reverse proxy and enable it on boot:
sudo systemctl enable --now nginx

(For local development you can also use Flask's runner: FLASK_APP=app.py flask run.)

(back to top)

Usage

Endpoints:

  • GET /weather?city=<city_name>
    • Returns normalized current weather and short daily forecasts for the requested city.

Example:

curl "http://localhost:8000/weather?city=Aleppo"

Response shape (example):

{
  "city": "aleppo",
  "daily": {
    "temperature_max": [
      33.8,
      35.1,
      35.2,
      36.1,
      37.5,
      38.4,
      39.0
    ],
    "temperature_min": [
      21.1,
      18.8,
      20.3,
      21.5,
      22.0,
      22.4,
      21.9
    ],
    "time": [
      "2026-09-08",
      "2026-09-09",
      "2026-09-10",
      "2026-09-11",
      "2026-09-12",
      "2026-09-13",
      "2026-09-14"
    ]
  },
  "humidity": 28,
  "time": "2026-09-08T01:00"
}

(back to top)

Contact

Project maintainer: arakium — https://github.com/arakium

(back to top)

(back to top)

About

A lightweight Flask-based REST API that fetches and normalizes weather data from external providers (Open-Meteo). It provides endpoints for current weather and short forecasts and caches responses in Redis.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages