MSN Weather Wrapper
A modern, production-ready Python wrapper for MSN Weather with a FastAPI backend and Next.js frontend.
Overview
MSN Weather Wrapper is a comprehensive weather data solution featuring:
- Python Library - Type-safe weather client with Pydantic models
- REST API - Production-ready FastAPI service with built-in OpenAPI docs
- Web Frontend - Modern Next.js 16 + React 19 + TypeScript 6
- Containerized - Podman/Docker deployment with Gunicorn, Uvicorn workers, and Nginx
Technology Stack:
- Backend: Python 3.10+, FastAPI 0.115+, Pydantic 2.12+, Uvicorn, Gunicorn 23.0+
- Frontend: Next.js 16, React 19.2, TypeScript 6+
- Testing: pytest 9.0+, Playwright, 168 tests (128 backend, 40 frontend E2E) with 97% coverage
- Quality: ruff 0.14+, mypy 1.19+, pre-commit hooks
- Security: Bandit, Semgrep, pip-audit, Trivy, Grype, weekly automated scans
- Deployment: Podman/Docker, Nginx, multi-stage builds
Quick Start
🚀 Containerized Deployment (Recommended)
git clone https://github.com/jim-wyatt/msn-weather-wrapper.git
cd msn-weather-wrapper
podman-compose up -d
# Access at http://localhost:8080
📦 Python Package
pip install msn-weather-wrapper
from msn_weather_wrapper import WeatherClient, Location
with WeatherClient() as client:
location = Location(city="London", country="UK")
weather = client.get_weather(location)
print(f"Temperature: {weather.temperature}°C")
🧪 Development Environment
./dev.sh setup # One-time setup
./dev.sh start # Start dev servers
./dev.sh status # Check health
# Frontend: http://localhost:3000
# API: http://localhost:5000
# Health: http://localhost:5000/api/v1/health
🧭 Start Here If You're New
If you're learning the codebase, explore it in this order:
backend/msn_weather_wrapper/— backend logic and the FastAPI appfrontend/— the Next.js UItests/— examples of expected behaviorscripts/— helper commands for setup, reports, and deployment tasks
A detailed walkthrough now lives in
docs/PROJECT_STRUCTURE.md.
Features
- 🌤️ Weather data extraction from MSN Weather
- 🌍 463+ cities worldwide with autocomplete
- 🔌 RESTful API with comprehensive validation
- 📚 Interactive API docs (Swagger UI at
/apidocs/) - ⚛️ Modern web interface with React + TypeScript
- 🚀 5-minute caching (90%+ faster repeated requests)
- 🔒 Rate limiting (30 req/min per IP, 200/hr global)
- 🛡️ Input validation & attack prevention (SQL injection, XSS, etc.)
- 🔐 Automated security scanning (Bandit, Semgrep, Trivy, Grype)
- 🔍 Type safety with mypy strict mode
- 📋 SBOM generation for supply chain security
- ♿ WCAG 2.1 Level AA accessible frontend
- 🔄 Modular CI/CD workflows - Reusable, maintainable architecture
- 🔄 Optimized CI/CD with Docker caching & conditional matrices
- 🏷️ Automated semantic versioning - Every PR auto-publishes to PyPI
Installation
Prerequisites
- Python 3.10+
- Node.js 24+ (for frontend development)
- Podman or Docker (for containerized deployment)
From Source
git clone https://github.com/jim-wyatt/msn-weather-wrapper.git
cd msn-weather-wrapper
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e ".[dev]"
pre-commit install
Usage
Python Library
from msn_weather_wrapper import WeatherClient, Location
with WeatherClient() as client:
location = Location(city="Seattle", country="USA")
weather = client.get_weather(location)
print(f"Temperature: {weather.temperature}°C")
print(f"Condition: {weather.condition}")
print(f"Humidity: {weather.humidity}%")
REST API
# Development
python api.py
# Production
gunicorn -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:5000 --workers 4 --timeout 120 api:app
# GET request
curl "http://localhost:5000/api/weather?city=London&country=UK"
# POST request
curl -X POST http://localhost:5000/api/weather \
-H "Content-Type: application/json" \
-d '{"city": "London", "country": "UK"}'
Web Frontend
cd frontend
npm install
npm run dev # http://localhost:3000
Features: City autocomplete (463+ cities), temperature unit toggle (°C/°F), geolocation support, responsive design, WCAG 2.1 Level AA accessibility
Development
# Setup & Run
./dev.sh setup # One-time setup
./dev.sh start # Start dev environment
./dev.sh test # Run tests
./dev.sh logs # View logs
# Code Quality
ruff format . # Format
ruff check . # Lint
mypy backend/msn_weather_wrapper # Type check
pre-commit run --all-files # Run all checks
# Testing
pytest # All tests
pytest --cov=backend --cov-report=html # With coverage
pytest tests/test_client.py -v # Specific file
Deployment
# Podman/Docker Compose
podman-compose up -d
podman-compose logs -f
podman-compose down
# Standalone Container
podman build -t msn-weather-wrapper .
podman run -p 8080:80 msn-weather-wrapper
Architecture: Unified container (Python + Node.js), Nginx reverse proxy, Gunicorn with Uvicorn workers, and Kubernetes-ready health checks
Documentation
- API Reference - Complete REST API documentation
- Interactive Swagger UI - Live API testing & exploration
- Development Guide - Setup & development workflow
- Testing Guide - Test suite & coverage
- Security Guide - Security features & automated scanning
- SBOM Guide - Software bill of materials
- Changelog - Version history
Project Structure
msn-weather-wrapper/
├── backend/msn_weather_wrapper/
│ ├── api/ # FastAPI app (main, routers, services, schemas)
│ ├── client.py # Core MSN weather client
│ ├── models.py # Shared Pydantic models
│ └── exceptions.py # Domain exceptions
├── frontend/ # React application
├── tests/ # Backend and integration tests
├── scripts/ # Dev, reporting, and deployment helpers
├── infra/ # Containers, compose files, and runtime config
├── docs/ # Docs and beginner walkthroughs
├── api.py # Local API entrypoint
├── dev.sh # Thin wrapper around `scripts/dev.sh`
└── pyproject.toml # Python project configuration
Contributing
Contributions are welcome! Please ensure:
- ✅ All tests pass:
pytest - 🎨 Code is formatted:
ruff format . - 🔍 Type checks pass:
mypy backend/ - 🪝 Pre-commit hooks pass
- 📝 Documentation is updated
See CONTRIBUTING.md for detailed guidelines.
License
MIT License - see LICENSE for details.
Links
Disclaimer
This project is an unofficial wrapper for MSN Weather data and is provided for educational and personal use only. This software is not affiliated with, endorsed by, or officially connected to Microsoft Corporation or MSN Weather in any way.
Metadata
Release files for msn-weather-wrapper 2.0.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| msn_weather_wrapper-2.0.12.tar.gz | 388.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| msn_weather_wrapper-2.0.12-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 411.5 kB
Release files / msn_weather_wrapper-2.0.12.tar.gz
| Download URL | msn_weather_wrapper-2.0.12.tar.gz |
|---|---|
| Size | 388.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
00541b96579c4bad66e259628bddebf85c0e249cc351626ab93995673611e7b4
|
|
BLAKE2b-256 checksum How to use checksums |
1aff14c733ae75bd5b5b97d2cd92620d749133ffaf88c19f2778424c9d65057b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 17, 2026.
Transparency logRelease files / msn_weather_wrapper-2.0.12-py3-none-any.whl
| Download URL | msn_weather_wrapper-2.0.12-py3-none-any.whl |
|---|---|
| Size | 23.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b93784000ddab07459f61aed50d855e337b0647175ad803bb3dd6a72eee65f6d
|
|
BLAKE2b-256 checksum How to use checksums |
6d4e66f25b61a2220bf4107f0b4f35ceb0f8c33b10073c1e2f6f020504b70540
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 17, 2026.
Transparency log