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.
- About The Project
- Built With
- Getting Started
- Prerequisites
- Installation
- Usage
- Contact
- Acknowledgments
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.
- Python 3.10+
- Flask
- Flask-Limiter (rate limiting)
- Redis (cache)
- Requests
- Pydantic
- Gunicorn
- Nginx
- Python 3.10 or later
- Redis server reachable from the app
- An internet connection to reach Open-Meteo geocoding and forecast endpoints
- Clone the repo and enter the directory:
git clone https://github.com/arakium/WeatherAPI.git
cd WeatherAPI- Create and activate a virtual environment:
python -m venv .venv
source .venv/bin/activate- Install dependencies:
pip install -r requirements.txt- Configure environment variables (example):
export REDIS_URL="redis://localhost:6379"- Start Gunicorn:
gunicorn -w 4 -b 127.0.0.1:8000 app:app --reload- 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.)
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"
}Project maintainer: arakium — https://github.com/arakium