Port of wttr.in
Find a file
2026-01-06 17:25:45 -08:00
.forgejo/workflows reference environment variable with actions syntax 2026-01-05 14:02:27 -08:00
build use git version in metno identifier 2026-01-05 13:34:37 -08:00
docker add ca-certificates for inclusion in docker image 2026-01-05 14:07:24 -08:00
scripts remove left over dead shell script 2026-01-05 10:06:10 -08:00
src more renaming 2026-01-06 17:17:43 -08:00
.gitignore remove GeoLite2 Db from gitignore - now stored in cache dir 2026-01-05 12:28:39 -08:00
.mise.toml clean up .gitignore/main.zig 2025-12-18 14:57:52 -08:00
.pre-commit-config.yaml reorder pre commit config to go fastest -> slowest 2025-12-19 14:38:33 -08:00
.travis.yml travis: pyflake only bin and lib 2019-12-29 17:50:14 +01:00
ARCHITECTURE.md documentation refresh (README still needs a lot of work) 2026-01-06 17:25:29 -08:00
build.zig use git version in metno identifier 2026-01-05 13:34:37 -08:00
build.zig.zon pin version of http.zig 2026-01-06 17:25:45 -08:00
LICENSE Initial commit 2015-12-26 23:03:43 +02:00
MISSING_FEATURES.md documentation refresh (README still needs a lot of work) 2026-01-06 17:25:29 -08:00
README.md documentation refresh (README still needs a lot of work) 2026-01-06 17:25:29 -08:00

wttr

Weather forecast service written in Zig, based on wttr.in.

Quick Start

# Build
zig build

# Run with defaults
./zig-out/bin/wttr

# With custom configuration
WTTR_LISTEN_PORT=8080 ./zig-out/bin/wttr

Usage

# Weather for your location (based on IP)
curl localhost:8002/

# Weather for a specific city
curl localhost:8002/London

# Weather for coordinates
curl localhost:8002/51.5074,-0.1278

# One-line format
curl localhost:8002/London?format=3

# JSON output
curl localhost:8002/London?format=j1

Configuration

All configuration is via environment variables:

Variable Default Description
WTTR_LISTEN_HOST 0.0.0.0 Listen address
WTTR_LISTEN_PORT 8002 Listen port
WTTR_CACHE_DIR ~/.cache/wttr Cache directory
WTTR_CACHE_SIZE 10000 Max cached responses
WTTR_GEOLITE_PATH ~/.cache/wttr/GeoLite2-City.mmdb GeoIP database path
IP2LOCATION_API_KEY (none) Optional IP geolocation fallback

External Services

Required (No API Key)

  • Met.no Weather API - Weather data provider (free, no registration)

Optional

  • IP2Location.io - Fallback IP geolocation

Auto-Downloaded

  • MaxMind GeoLite2 City - IP geolocation database
    • Downloaded automatically if missing
    • Stored in ~/.cache/wttr/GeoLite2-City.mmdb

Output Formats

  • ANSI (default) - Colored terminal output
  • Line formats (?format=1-4) - One-line weather
  • JSON (?format=j1) - Machine-readable
  • v2 (?format=v2) - Data-rich format
  • Custom (?format=%l:+%c+%t) - Custom format string

Query Parameters

  • ?u - Imperial units (°F, mph)
  • ?m - Metric units (°C, km/h)
  • ?format=N - Output format
  • ?lang=XX - Language (auto-detected by default)

Building

# Debug build
zig build

# Release build
zig build -Doptimize=ReleaseFast

# Run tests
zig build test

Docker

# Build image
docker build -t wttr -f docker/Dockerfile .

# Run container
docker run -p 8002:8002 wttr

Prometheus Integration

Note: Not yet implemented - see MISSING_FEATURES.md

# prometheus.yml
scrape_configs:
  - job_name: 'weather'
    static_configs:
      - targets: ['localhost:8002']
    metrics_path: '/London'
    params:
      format: ['p1']

Documentation

License

See LICENSE