open-sky-telemetry
by Shadojus
README.md
# `@shadojus/open-sky-telemetry`
Zero-dependency orbital satellite passes, space weather / aurora visibility, and deterministic offline Sun & Moon ephemeris — shipped as a Node.js ESM library (with browser-safe core modules and TypeScript declarations), OpenAPI 3.1 REST server, CLI, Model Context Protocol (`2024-11-05`) stdio server, pure-stdlib Python 3.9+ package (`shadojus-sky-telemetry`), and static Dark-Instrument GitHub Pages visualizer.
---
## Highlights
- **100% Offline Deterministic Ephemeris (`src/ephemeris.mjs`)** — Solar altitude/azimuth (apparent & geometric), sunrise, solar noon, sunset, civil/nautical/astronomical twilight, golden & blue hours, polar day/night state, day/night terminator curves, plus lunar topocentric position, phase (`0..1`), illuminated fraction, lunar age, 8-phase name, and moonrise/moonset.
- **Keplerian + J2 Secular Orbit Propagator (`src/orbit.mjs`)** — Propagates NORAD GP/OMM JSON records or 2/3-line TLEs (including Alpha-5 catalogue IDs and checksum verification) with Brouwer mean-motion recovery, J2 secular nodal regression / apsidal precession, and `MEAN_MOTION_DOT` drag decay. Computes ECI/ECEF/WGS-84 sub-satellite state, eclipse (`sunlit`) status, observer topocentric `(azimuthDeg, elevationDeg, rangeKm)`, ground tracks, and `nextPasses()` (bisection AOS/LOS + golden-section TCA).
- **Space Weather & Aurora Oval (`src/spaceweather.mjs`)** — NOAA SWPC planetary `Kp` parser (both object and legacy array formats), NOAA `G0`–`G5` geomagnetic storm scale, solar wind summary (`speedKms`, `btNt`, `bzNt`), IGRF-14 centred-dipole geomagnetic coordinates, Feldstein–Starkov equatorward auroral boundary, and observer aurora likelihood (`polar-cap`, `overhead`, `horizon`, `unlikely`).
- **Bundled Seed + Strict HTTPS Live Adapters (`data/seed.json`, `data/SOURCES.json`)** — Ships with 42 real GP/OMM orbital element sets (ISS, CSS Tiangong, Crew Dragon, Hubble, Terra, Aqua, XRISM, NOAA-20/21, Suomi NPP, Meteor-M2 series, MetOp, GOES-18/19, Himawari-9, Meteosat-11, Starlink sample) and a baseline NOAA SWPC `Kp` + DSCOVR/ACE solar-wind snapshot. Optional live refresh enforces an HTTPS-only host allow-list (`celestrak.org`, `services.swpc.noaa.gov`) with `redirect: 'error'` and >= 2-hour CelesTrak group caching.
- **Browser-Safe Core & Cross-Language Parity** — `src/ephemeris.mjs`, `src/orbit.mjs`, and `src/spaceweather.mjs` import zero `node:*` modules and run identically in Node, Deno, Bun, and browsers. The Python port in `python/` (`shadojus-sky-telemetry`) is tested directly against Node reference fixtures (`python/tests/fixtures/parity.json`).
---
## Quickstart
### Node.js Library
```js
import {
SkyTelemetry,
ephemeris,
parseTLE,
satellitePosition,
nextPasses,
auroraVisibility,
} from '@shadojus/open-sky-telemetry';
// 1. Offline Sun & Moon ephemeris
const eph = ephemeris(52.52, 13.405, '2026-11-28T20:00:00Z');
console.log(eph.sun.sunrise, eph.sun.goldenHour.evening, eph.moon.phaseName);
// 2. Bundled catalogue: overhead satellites, passes & space weather
const sky = new SkyTelemetry();
const passes = sky.nextPasses('ISS', 52.52, 13.405, {
start: '2026-11-28T12:00:00Z',
hours: 24,
minElevationDeg: 10,
});
console.log(passes[0]); // { aos, tca, los, maxElevationDeg, visible, ... }
const sw = await sky.spaceWeather({ lat: 69.65, lng: 18.96 });
console.log(sw.kp, sw.aurora.likelihood);
// 3. Direct TLE parsing & propagation
const iss = parseTLE(
'1 25544U 98067A 26332.04031741 .00004674 00000+0 90938-4 0 9999',
'2 25544 51.6312 209.2135 0007395 72.8625 287.3173 15.49639368597158',
'ISS (ZARYA)',
);
console.log(satellitePosition(iss, '2026-11-28T12:00:00Z'));
console.log(auroraVisibility(69.65, 18.96, 5));
```
### CLI
```bash
node src/cli.mjs ephemeris --lat 52.52 --lng 13.405 --time 2026-11-28T20:00:00Z
node src/cli.mjs satellites --group stations
node src/cli.mjs position ISS --time 2026-11-28T12:00:00Z
node src/cli.mjs overhead --lat 52.52 --lng 13.405 --min-elevation 10
node src/cli.mjs passes ISS --lat 52.52 --lng 13.405 --hours 24
node src/cli.mjs space-weather --lat 69.65 --lng 18.96
node src/cli.mjs sources
```
Pass `--json` to any command for structured JSON output.
### REST API (`OpenAPI 3.1.0`)
```bash
node src/cli.mjs serve --port 8787
```
| Endpoint | Description |
| --- | --- |
| `GET /health` | Service status, tracked satellite count, and element age |
| `GET /openapi.json` | OpenAPI `3.1.0` specification |
| `GET /v1/ephemeris?lat=52.52&lng=13.405&t=...` | Offline Sun & Moon ephemeris |
| `GET /v1/satellites?group=weather` | List tracked satellites (or `?id=25544&lat=52.52&lng=13.405&passes=1`) |
| `GET /v1/satellites/overhead?lat=52.52&lng=13.405&minElevation=10` | Satellites currently above the observer |
| `GET /v1/space-weather?lat=69.65&lng=18.96&oval=1` | Planetary `Kp`, `G`-scale, solar wind, aurora verdict & oval |
| `GET /v1/sources` | Upstream operator attribution, licences, and HTTPS allow-list |
Includes weak/strong SHA-1 `ETag` (`304 Not Modified`), CORS headers, and per-IP / IPv6-`/64` fixed-window rate limiting (`429` with `Retry-After`).
### MCP Server (`2024-11-05` over stdio)
```json
{
"mcpServers": {
"open-sky-telemetry": {
"command": "node",
"args": ["/path/to/open-sky-telemetry/src/mcp.mjs"]
}
}
}
```
Tools exposed:
- `get_sun_moon_ephemeris` — Solar/lunar positions, rise/set, twilights, golden hour & phase.
- `find_satellites_overhead` — Satellites currently overhead (or next passes when `satellite` is supplied).
- `get_space_weather_aurora` — Planetary `Kp`, `G`-scale, solar wind & observer aurora visibility.
- `list_tracked_satellites` — Filterable catalogue of tracked satellites and orbital regimes.
### Python SDK (`python/`)
Zero-dependency Python 3.9+ stdlib package (`shadojus-sky-telemetry`):
```python
from shadojus_sky_telemetry import SkyTelemetry, ephemeris
sky = SkyTelemetry()
print(ephemeris(52.52, 13.405, "2026-11-28T20:00:00Z")["moon"]["phaseName"])
print(sky.next_passes("ISS", 52.52, 13.405, start="2026-11-28T12:00:00Z", hours=24)[0])
```
---
## Accuracy & Model Scope
- **Sun:** NOAA Solar Calculator / Meeus Ch. 25 (~`0.01°` in coordinates, ~`±1 min` for rise/set at mid-latitudes).
- **Moon:** Astronomical Almanac low-precision series (~`0.3°` in ecliptic longitude, `±1%` illumination).
- **Orbits:** Analytical Keplerian + WGS-72 `J2` secular perturbation propagator with Brouwer mean-motion recovery and first-order drag (`MEAN_MOTION_DOT`). Benchmarked in `test/contract.test.mjs` within `< 30 km` 3-D ECI error of reference SGP4 across LEO and GEO out to `+72 h` from epoch. Intended for pass scheduling, ground-track displays, and telemetry tooling — **not** for collision avoidance or safety-of-life navigation. Refresh GP elements regularly (`npm run build:data` or live mode) because LEO drag ages TLE/OMM sets within days.
---
## Development & Tests
```bash
# Node.js contract suite (28 tests: ephemeris, TLE/OMM, SGP4 error bound, aurora, HTTP, CLI, MCP)
npm test
# Python stdlib test suite + Node parity check
python -m unittest discover -s python/tests
# Check docs/ and python/ data/core mirrors have not drifted
npm run check
```
---
## Data Sources & Attribution
All live network calls are opt-in and restricted to `https://celestrak.org` and `https://services.swpc.noaa.gov` (see [`data/SOURCES.json`](./data/SOURCES.json)):
- **Orbital elements:** CelesTrak (Dr. T.S. Kelso), derived from the US Space Force public GP catalogue. Live mode caches each group for at least 2 hours in accordance with CelesTrak polling guidelines.
- **Space weather:** NOAA Space Weather Prediction Center (`noaa-planetary-k-index.json` and Real-Time Solar Wind summary, public domain under 17 U.S.C. 105).
- **Docs basemap:** Natural Earth 1:110m land outlines (public domain).
## License
Code is released under the [MIT License](./LICENSE). Upstream orbital elements and space-weather series retain the terms and attribution recorded in [`data/SOURCES.json`](./data/SOURCES.json).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues