Sign inSign up

letstool/http2sun

By letstool

•Updated 4 months ago

Fast & lightweight HTTP gateway that serves solar position algorithm as a JSON REST API.

Image
API management
Data science
Web servers
0

1.5K

letstool/http2sun repository overview

⁠http2sun

Lightweight HTTP gateway that returns solar position data through a JSON REST API.

Send a POST /api/v1/sun request with a location and optional timestamp, get sunrise, sunset, solar noon, twilight times, sun angles, and the instantaneous sun position back as structured JSON.

Covers all solar events: sunrise, sunset, solar noon, day length, civil / nautical / astronomical twilights, azimuth and elevation at solar noon and at any requested instant. Handles polar night and polar day conditions. All times are returned in the observer's timezone (IANA, default UTC).

The binary embeds a web UI (dark/light mode, 15 languages) and an OpenAPI 3.1 spec — no external files, no runtime dependencies, no database. Solar calculations use the NREL Solar Position Algorithm (go-spa⁠, Reda & Andreas, 2004), accurate to ±0.0003° in azimuth and zenith angle. Valid for years −2000 to 6000.

⁠Quick start

docker run -p 8080:8080 letstool/http2sun:latest

Open http://localhost:8080⁠ to use the web UI, or query the API directly:

curl -s -X POST http://localhost:8080/api/v1/sun \
  -H "Content-Type: application/json" \
  -d '{"latitude": 48.8566, "longitude": 2.3522, "timezone": "Europe/Paris"}' | jq
⁠Request fields
FieldRequiredDefaultDescription
latitude✅—Decimal degrees, −90 to +90
longitude✅—Decimal degrees, −180 to +180
timezone❌UTCIANA timezone of the observer's location
timestamp❌nowUnix timestamp in seconds (UTC epoch)
elevation❌0Observer altitude above sea level in metres
pressure❌1013.25Atmospheric pressure in hPa — affects refraction
temperature❌12.0Air temperature in °C — affects refraction
delta_t❌autoΔT = TT − UT1 in seconds — auto-estimated via Espenak & Meeus (2006) if omitted
⁠Example response
{
  "latitude": 48.86,
  "longitude": 2.35,
  "timezone": "Europe/Paris",
  "timestamp": 1745107200,
  "date": "2026-04-20",
  "observer_elevation_m": 0,
  "observer_pressure_hpa": 1013.25,
  "observer_temperature_c": 12,
  "delta_t_s": 75.27,
  "sunrise": "06:49:42",
  "sunset": "20:49:17",
  "solar_noon": "13:49:30",
  "day_length": "13:59:35",
  "civil_twilight_begin": "06:15:47",
  "civil_twilight_end": "21:23:12",
  "nautical_twilight_begin": "05:33:49",
  "nautical_twilight_end": "22:05:10",
  "astronomical_twilight_begin": "04:46:58",
  "astronomical_twilight_end": "22:52:02",
  "sunrise_azimuth_deg": 72.17,
  "sunset_azimuth_deg": 287.83,
  "noon_elevation_deg": 52.76,
  "noon_azimuth_deg": 180,
  "polar_day": false,
  "polar_night": false,
  "current_azimuth_deg": 182.67,
  "current_elevation_deg": 52.74,
  "current_time_local": "13:56:57"
}

⁠Configuration

CLI flagEnvironment variableDefault
--listen-addrLISTEN_ADDR127.0.0.1:8080

CLI flag takes priority over the environment variable.

docker run -p 9090:9090 \
  -e LISTEN_ADDR=0.0.0.0:9090 \
  letstool/http2sun:latest

⁠Repo

https://github.com/letstool/http2sun⁠


⁠License

This project is licensed under the Apache License, Version 2.0⁠.

Copyright (c) 2026 letstool.net

⁠See also

ProjectGitHubDocker HubDescription
http2dnsletstool/http2dns⁠letstool/http2dns⁠Fast & lightweight HTTP gateway that serves DNS queries as a JSON REST API
http2whoisletstool/http2whois⁠letstool/http2whois⁠Fast & lightweight HTTP gateway that serves WHOIS queries as a JSON REST API
http2rdapletstool/http2rdap⁠letstool/http2rdap⁠Fast & lightweight HTTP gateway that serves RDAP queries as a JSON REST API
http2geoipletstool/http2geoip⁠letstool/http2geoip⁠Fast & lightweight HTTP gateway that serves IP geolocation database as a JSON REST API
http2certletstool/http2cert⁠letstool/http2cert⁠Fast & lightweight HTTP gateway that serves X.509 certificate inspection as a JSON REST API
http2torletstool/http2tor⁠letstool/http2tor⁠Fast & lightweight HTTP gateway that serves Tor IP database as a JSON REST API
http2sunletstool/http2sun⁠letstool/http2sun⁠Fast & lightweight HTTP gateway that serves solar position algorithm as a JSON REST API
http2macletstool/http2mac⁠letstool/http2mac⁠Fast & lightweight HTTP gateway that serves MAC address OUI database as a JSON REST API
http2countryletstool/http2country⁠letstool/http2country⁠Fast & lightweight HTTP gateway that serves country database as a JSON REST API
http2prefixletstool/http2prefix⁠letstool/http2prefix⁠Fast & lightweight HTTP gateway that serves Internet BGP routing database as a JSON REST API
http2registryletstool/http2registry⁠letstool/http2registry⁠Fast & lightweight HTTP gateway that serves RIR/NIR Internet registry database as a JSON REST API

Tag summary

Content type

Image

Digest

sha256:80c6e1574…

Size

2.7 MB

Last updated

4 months ago

docker pull letstool/http2sun