Skip to main content

MSN Weather Wrapper

A modern, production-ready Python wrapper for MSN Weather with a FastAPI backend and Next.js frontend.

CI/CD Pipeline PyPI version Python License Documentation Code style: ruff Checked with mypy Container


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
  • 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, TypeScript
  • Testing: pytest and Playwright (unit, security, integration, accessibility, and end-to-end suites)
  • Quality: ruff, mypy (strict), pre-commit hooks
  • Security: Bandit, Semgrep, pip-audit, Trivy, Grype, weekly automated scans
  • Deployment: Podman/Docker, Nginx, multi-stage builds

Quick Start

git clone https://github.com/jim-wyatt/msn-weather-wrapper.git
cd msn-weather-wrapper
export APP_SECRET_KEY="$(python3 -c 'import secrets; print(secrets.token_hex(32))')"
podman-compose -f infra/compose/podman-compose.yml up -d
# Access at http://localhost:8080

A prebuilt image is also published to GitHub Container Registry.

📦 Python Package

pip install msn-weather-wrapper
from backend import WeatherClient, Location

with WeatherClient() as client:
    location = Location(city="London", country="UK")
    weather = client.get_weather(location)
    print(f"Temperature: {weather.temperature}°C")

Note: the distribution is named msn-weather-wrapper, but the importable package is currently backend.

🧪 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:

  1. backend/ — the weather client, models, and the FastAPI app (backend/api/)
  2. frontend/ — the Next.js UI
  3. tests/ — examples of expected behavior
  4. scripts/ — 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 Next.js, React, and 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 - Merged PRs are versioned and published to PyPI automatically

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 backend 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
APP_ENV=development uvicorn backend.api.main:app --reload --port 5000

# Production (APP_SECRET_KEY is required)
gunicorn -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:5000 --workers 4 --timeout 120 backend.api.main:app

# GET request
curl "http://localhost:5000/api/v1/weather?city=London&country=UK"

# POST request
curl -X POST http://localhost:5000/api/v1/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                     # 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

export APP_SECRET_KEY="$(python3 -c 'import secrets; print(secrets.token_hex(32))')"

# Podman/Docker Compose
podman-compose -f infra/compose/podman-compose.yml up -d
podman-compose -f infra/compose/podman-compose.yml logs -f
podman-compose -f infra/compose/podman-compose.yml down

# Standalone Container
podman build -t msn-weather-wrapper -f infra/containers/Containerfile .
podman run -p 8080:80 -e APP_SECRET_KEY msn-weather-wrapper

APP_SECRET_KEY must be supplied at runtime in production. Set CORS_ORIGINS to a comma-separated list of explicit origins if the API is called cross-origin; see .env.example for all settings.

Architecture: Unified container (Python + Node.js), Nginx reverse proxy, Gunicorn with Uvicorn workers, and Kubernetes-ready health checks


Documentation

📚 Full Documentation


Project Structure

msn-weather-wrapper/
├── backend/
│   ├── api/                    # FastAPI app (main, routers, services, schemas)
│   ├── client.py               # Core MSN weather client
│   ├── models.py               # Shared Pydantic models
│   └── exceptions.py           # Domain exceptions
├── frontend/                   # Next.js application
├── tests/                      # Backend and integration tests
├── scripts/                    # Dev, reporting, and deployment helpers
├── infra/                      # Containers, compose files, and runtime config
├── docs/                       # Docs and beginner walkthroughs
├── dev.sh                      # Thin wrapper around `scripts/dev.sh`
└── pyproject.toml              # Python project configuration

Contributing

Contributions are welcome! Please ensure:

  1. ✅ All tests pass: pytest
  2. 🎨 Code is formatted: ruff format .
  3. 🔍 Type checks pass: mypy backend/
  4. 🪝 Pre-commit hooks pass
  5. 📝 Documentation is updated

See CONTRIBUTING.md for detailed guidelines and the Code of Conduct. To report a vulnerability, follow the security policy rather than opening a public issue.


License

MIT License - see LICENSE for details.



Disclaimer

This project is an unofficial wrapper for MSN Weather data and is provided for educational and personal use only. It works by parsing public MSN Weather pages, so it can break without notice when the upstream site changes, and you are responsible for complying with the upstream terms of use. 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.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for msn-weather-wrapper 2.0.13
File Size Uploaded
msn_weather_wrapper-2.0.13.tar.gz 394.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for msn-weather-wrapper 2.0.13
File Interpreter ABI Platform
msn_weather_wrapper-2.0.13-py3-none-any.whl Python 3 none any Details

Total release size: 418.9 kB

Release files / msn_weather_wrapper-2.0.13.tar.gz

Download URL msn_weather_wrapper-2.0.13.tar.gz
Size 394.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ccd9a6b38ebdb107319a9bc807a702673a4158313f76b5fdd626350ef489c7b4
BLAKE2b-256 checksum
How to use checksums
c06563838e6470e99ae96c55463894a524e49d3d7da3c05de0d98cf163db970a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 10, 2026.

Transparency log

Release files / msn_weather_wrapper-2.0.13-py3-none-any.whl

Download URL msn_weather_wrapper-2.0.13-py3-none-any.whl
Size 24.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
60519dd01f0b2e4179b730e187d4b2bb700240fa7b2249309c0982094c256eab
BLAKE2b-256 checksum
How to use checksums
0468d542fa8ac65f77a25fc06487427a1b5e8caca2089ff17c0e5217364218fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 10, 2026.

Transparency log

Release history Release notifications | RSS feed

2.0.14

2 release files

This release

2.0.13 This release

2 release files

2.0.12

2 release files

2.0.11

2 release files

2.0.10

2 release files

2.0.9

2 release files

2.0.8

2 release files

2.0.7

2 release files

2.0.6

2 release files

2.0.5

2 release files

2.0.4

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.9.16

2 release files

1.9.15

2 release files

1.9.14

2 release files

1.9.13

2 release files

1.9.12

2 release files

1.9.11

2 release files

1.9.10

2 release files

1.9.9

2 release files

1.9.8

2 release files

1.9.7

2 release files

1.9.6

2 release files

1.9.5

2 release files

1.9.4

2 release files

1.9.3

2 release files

1.9.2

2 release files

1.9.1

2 release files

1.9.0

2 release files

1.8.3

2 release files

1.8.2

2 release files

1.8.1

2 release files

1.7.8

2 release files

1.7.7

2 release files

1.7.6

2 release files

1.7.5

2 release files

1.7.4

2 release files

1.7.3

2 release files

1.7.2

2 release files

1.3.2

2 release files

1.3.0

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.5

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page